aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_hir_def/src/nameres/tests.rs32
-rw-r--r--crates/ra_hir_ty/src/tests/macros.rs29
2 files changed, 61 insertions, 0 deletions
diff --git a/crates/ra_hir_def/src/nameres/tests.rs b/crates/ra_hir_def/src/nameres/tests.rs
index 87fcd617c..61cdd768e 100644
--- a/crates/ra_hir_def/src/nameres/tests.rs
+++ b/crates/ra_hir_def/src/nameres/tests.rs
@@ -558,3 +558,35 @@ fn cfg_test() {
558 ⋮Foo: t v 558 ⋮Foo: t v
559 "###); 559 "###);
560} 560}
561
562#[test]
563fn infer_multiple_namespace() {
564 let map = def_map(
565 r#"
566//- /main.rs
567mod a {
568 pub type T = ();
569 pub use crate::b::*;
570}
571
572use crate::a::T;
573
574mod b {
575 pub const T: () = ();
576}
577"#,
578 );
579
580 assert_snapshot!(map, @r###"
581 ⋮crate
582 ⋮T: t v
583 ⋮a: t
584 ⋮b: t
585
586 ⋮crate::b
587 ⋮T: v
588
589 ⋮crate::a
590 ⋮T: t v
591"###);
592}
diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs
index 9c29a054e..812f171db 100644
--- a/crates/ra_hir_ty/src/tests/macros.rs
+++ b/crates/ra_hir_ty/src/tests/macros.rs
@@ -211,6 +211,35 @@ pub fn baz() -> usize { 31usize }
211} 211}
212 212
213#[test] 213#[test]
214fn infer_type_value_non_legacy_macro_use_as() {
215 assert_snapshot!(
216 infer(r#"
217mod m {
218 macro_rules! _foo {
219 ($x:ident) => { type $x = u64; }
220 }
221 pub(crate) use _foo as foo;
222}
223
224m::foo!(foo);
225use foo as bar;
226fn f() -> bar { 0 }
227fn main() {
228 let _a = f();
229}
230"#),
231 @r###"
232 [159; 164) '{ 0 }': u64
233 [161; 162) '0': u64
234 [175; 199) '{ ...f(); }': ()
235 [187; 189) '_a': u64
236 [193; 194) 'f': fn f() -> u64
237 [193; 196) 'f()': u64
238 "###
239 );
240}
241
242#[test]
214fn infer_builtin_macros_line() { 243fn infer_builtin_macros_line() {
215 assert_snapshot!( 244 assert_snapshot!(
216 infer(r#" 245 infer(r#"