From 26b092bd3b431559d7aafbf42882f978c0bb3dab Mon Sep 17 00:00:00 2001 From: uHOOCCOOHu Date: Sat, 7 Sep 2019 02:44:26 +0800 Subject: Resolve textual scoped macros inside item --- crates/ra_hir/src/ty/tests.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'crates/ra_hir/src/ty') diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index c4bddde85..f2d5b115e 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -2803,6 +2803,41 @@ fn main() { ); } +#[test] +fn infer_textual_scoped_macros_expanded() { + assert_snapshot!( + infer(r#" +struct Foo(Vec); + +#[macro_use] +mod m { + macro_rules! foo { + ($($item:expr),*) => { + { + Foo(vec![$($item,)*]) + } + }; + } +} + +fn main() { + let x = foo!(1,2); + let y = crate::foo!(1,2); +} +"#), + @r###" + ![0; 17) '{Foo(v...,2,])}': Foo + ![1; 4) 'Foo': Foo({unknown}) -> Foo + ![1; 16) 'Foo(vec![1,2,])': Foo + ![5; 15) 'vec![1,2,]': {unknown} + [195; 251) '{ ...,2); }': () + [205; 206) 'x': Foo + [228; 229) 'y': {unknown} + [232; 248) 'crate:...!(1,2)': {unknown} + "### + ); +} + #[ignore] #[test] fn method_resolution_trait_before_autoref() { -- cgit v1.2.3 From 92c07803cc0ce1d2008cc912f006d1cd66ff3f4a Mon Sep 17 00:00:00 2001 From: uHOOCCOOHu Date: Sun, 8 Sep 2019 00:37:54 +0800 Subject: Rename `textual_macro` -> `legacy_macro` Add comments --- crates/ra_hir/src/ty/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_hir/src/ty') diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index f2d5b115e..25716fe8c 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -2804,7 +2804,7 @@ fn main() { } #[test] -fn infer_textual_scoped_macros_expanded() { +fn infer_legacy_textual_scoped_macros_expanded() { assert_snapshot!( infer(r#" struct Foo(Vec); -- cgit v1.2.3