]> git.lizzy.rs Git - rust.git/blobdiff - crates/hir_ty/src/tests/macros.rs
Merge #11461
[rust.git] / crates / hir_ty / src / tests / macros.rs
index d14103aab145f1687cc425ecfc3f5511349318dd..344e7293c59343fc9faee4ee7b24ebf304da6756 100644 (file)
@@ -27,7 +27,7 @@ fn test() {
 } //^ (i32, {unknown}, i32, {unknown})
 
 //- /foo.rs crate:foo
-struct S;
+pub struct S;
 
 #[cfg(not(test))]
 impl S {
@@ -190,7 +190,6 @@ fn spam() {
             !0..6 '1isize': isize
             !0..6 '1isize': isize
             !0..6 '1isize': isize
-            !0..6 '1isize': isize
             39..442 '{     ...!(); }': ()
             73..94 'spam!(...am!())': {unknown}
             100..119 'for _ ...!() {}': ()
@@ -198,6 +197,7 @@ fn spam() {
             117..119 '{}': ()
             124..134 '|| spam!()': || -> isize
             140..156 'while ...!() {}': ()
+            146..153 'spam!()': bool
             154..156 '{}': ()
             161..174 'break spam!()': !
             180..194 'return spam!()': !
@@ -271,7 +271,6 @@ fn spam() {
             !0..6 '1isize': isize
             !0..6 '1isize': isize
             !0..6 '1isize': isize
-            !0..6 '1isize': isize
             53..456 '{     ...!(); }': ()
             87..108 'spam!(...am!())': {unknown}
             114..133 'for _ ...!() {}': ()
@@ -279,6 +278,7 @@ fn spam() {
             131..133 '{}': ()
             138..148 '|| spam!()': || -> isize
             154..170 'while ...!() {}': ()
+            160..167 'spam!()': bool
             168..170 '{}': ()
             175..188 'break spam!()': !
             194..208 'return spam!()': !
@@ -435,11 +435,11 @@ fn processes_impls_generated_by_macros() {
 macro_rules! m {
     ($ident:ident) => (impl Trait for $ident {})
 }
-trait Trait { fn foo(self) -> u128 {} }
+trait Trait { fn foo(self) -> u128 { 0 } }
 struct S;
 m!(S);
 fn test() { S.foo(); }
-                //^ u128
+          //^^^^^^^ u128
 "#,
     );
 }
@@ -457,7 +457,7 @@ impl S {
 }
 
 fn test() { S.foo(); }
-                //^ u128
+          //^^^^^^^ u128
 "#,
     );
 }
@@ -479,7 +479,7 @@ impl S {
 }
 
 fn test() { S.foo(); }
-                //^ u128
+          //^^^^^^^ u128
 "#,
     );
 }
@@ -743,7 +743,7 @@ macro_rules! include {() => {}}
 
 fn main() {
     bar();
-}     //^ u32
+} //^^^^^ u32
 
 //- /foo.rs
 fn bar() -> u32 {0}
@@ -781,7 +781,7 @@ macro_rules! include {() => {}}
 
 fn main() {
     bar::bar();
-}          //^ u32
+} //^^^^^^^^^^ u32
 
 //- /f/foo.rs
 pub mod bar;
@@ -853,7 +853,7 @@ macro_rules! include {() => {}}
 
 fn main() {
     RegisterBlock { };
-                  //^ RegisterBlock
+  //^^^^^^^^^^^^^^^^^ RegisterBlock
 }
     "#;
     let fixture = format!("{}\n//- /foo.rs\n{}", fixture, data);
@@ -879,7 +879,7 @@ macro_rules! concat {() => {}}
 
 fn main() {
     bar();
-}     //^ u32
+} //^^^^^ u32
 
 //- /foo.rs
 fn bar() -> u32 {0}
@@ -905,7 +905,7 @@ macro_rules! env {() => {}}
 
 fn main() {
     bar();
-}     //^ {unknown}
+} //^^^^^ {unknown}
 
 //- /foo.rs
 fn bar() -> u32 {0}
@@ -923,7 +923,7 @@ macro_rules! include {() => {}}
 include!("main.rs");
 
 fn main() {
-            0
+    0;
 } //^ i32
 "#,
     );
@@ -974,61 +974,12 @@ fn main() {
 fn infer_derive_clone_simple() {
     check_types(
         r#"
-//- /main.rs crate:main deps:core
+//- minicore: derive, clone
 #[derive(Clone)]
 struct S;
 fn test() {
     S.clone();
-}         //^ S
-
-//- /lib.rs crate:core
-pub mod prelude {
-    pub mod rust_2018 {
-        #[rustc_builtin_macro]
-        pub macro Clone {}
-        pub use crate::clone::Clone;
-    }
-}
-
-pub mod clone {
-    pub trait Clone {
-        fn clone(&self) -> Self;
-    }
-}
-"#,
-    );
-}
-
-#[test]
-fn infer_derive_clone_in_core() {
-    check_types(
-        r#"
-//- /lib.rs crate:core
-#[prelude_import]
-use prelude::rust_2018::*;
-
-pub mod prelude {
-    pub mod rust_2018 {
-        #[rustc_builtin_macro]
-        pub macro Clone {}
-        pub use crate::clone::Clone;
-    }
-}
-
-pub mod clone {
-    pub trait Clone {
-        fn clone(&self) -> Self;
-    }
-}
-
-#[derive(Clone)]
-pub struct S;
-
-//- /main.rs crate:main deps:core
-use core::S;
-fn test() {
-    S.clone();
-}         //^ S
+} //^^^^^^^^^ S
 "#,
     );
 }
@@ -1037,31 +988,17 @@ fn test() {
 fn infer_derive_clone_with_params() {
     check_types(
         r#"
-//- /main.rs crate:main deps:core
+//- minicore: clone, derive
 #[derive(Clone)]
 struct S;
 #[derive(Clone)]
 struct Wrapper<T>(T);
 struct NonClone;
 fn test() {
-    (Wrapper(S).clone(), Wrapper(NonClone).clone());
+    let x = (Wrapper(S).clone(), Wrapper(NonClone).clone());
+    x;
   //^ (Wrapper<S>, {unknown})
 }
-
-//- /lib.rs crate:core
-pub mod prelude {
-    pub mod rust_2018 {
-        #[rustc_builtin_macro]
-        pub macro Clone {}
-        pub use crate::clone::Clone;
-    }
-}
-
-pub mod clone {
-    pub trait Clone {
-        fn clone(&self) -> Self;
-    }
-}
 "#,
     );
 }
@@ -1071,7 +1008,7 @@ fn infer_custom_derive_simple() {
     // FIXME: this test current now do nothing
     check_types(
         r#"
-//- /main.rs crate:main
+//- minicore: derive
 use foo::Foo;
 
 #[derive(Foo)]
@@ -1079,7 +1016,7 @@ struct S{}
 
 fn test() {
     S{};
-}   //^ S
+} //^^^ S
 "#,
     );
 }