File tree Expand file tree Collapse file tree 3 files changed +29
-7
lines changed
ide_diagnostics/src/handlers Expand file tree Collapse file tree 3 files changed +29
-7
lines changed Original file line number Diff line number Diff line change @@ -1890,7 +1890,7 @@ impl ModCollector<'_, '_> {
18901890 }
18911891
18921892 fn collect_macro_call ( & mut self , mac : & MacroCall ) {
1893- let mut ast_id = AstIdWithPath :: new ( self . file_id ( ) , mac. ast_id , ( * mac. path ) . clone ( ) ) ;
1893+ let ast_id = AstIdWithPath :: new ( self . file_id ( ) , mac. ast_id , ( * mac. path ) . clone ( ) ) ;
18941894
18951895 // Case 1: try to resolve in legacy scope and expand macro_rules
18961896 let mut error = None ;
@@ -1941,11 +1941,6 @@ impl ModCollector<'_, '_> {
19411941 }
19421942
19431943 // Case 2: resolve in module scope, expand during name resolution.
1944- // We rewrite simple path `macro_name` to `self::macro_name` to force resolve in module scope only.
1945- if ast_id. path . is_ident ( ) {
1946- ast_id. path . kind = PathKind :: Super ( 0 ) ;
1947- }
1948-
19491944 self . def_collector . unresolved_macros . push ( MacroDirective {
19501945 module_id : self . module_id ,
19511946 depth : self . macro_depth + 1 ,
Original file line number Diff line number Diff line change @@ -349,8 +349,10 @@ macro_rules! m {
349349"# ,
350350 expect ! [ [ r#"
351351 crate
352+ S: t v
352353 "# ] ] ,
353354 ) ;
355+ // FIXME: should not expand. legacy macro scoping is not implemented.
354356}
355357
356358#[ test]
@@ -427,6 +429,7 @@ macro_rules! baz {
427429"# ,
428430 expect ! [ [ r#"
429431 crate
432+ NotFoundBefore: t v
430433 Ok: t v
431434 OkAfter: t v
432435 OkShadowStop: t v
@@ -462,6 +465,7 @@ macro_rules! baz {
462465 crate::m3::m5
463466 "# ] ] ,
464467 ) ;
468+ // FIXME: should not see `NotFoundBefore`
465469}
466470
467471#[ test]
@@ -994,3 +998,26 @@ structs!(Foo);
994998 "# ] ] ,
995999 ) ;
9961000}
1001+
1002+ #[ test]
1003+ fn macro_in_prelude ( ) {
1004+ check (
1005+ r#"
1006+ //- /lib.rs crate:lib deps:std
1007+ global_asm!();
1008+
1009+ //- /std.rs crate:std
1010+ pub mod prelude {
1011+ pub mod rust_2018 {
1012+ pub macro global_asm() {
1013+ pub struct S;
1014+ }
1015+ }
1016+ }
1017+ "# ,
1018+ expect ! [ [ r#"
1019+ crate
1020+ S: t v
1021+ "# ] ] ,
1022+ )
1023+ }
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ foo::bar!(92);
6363macro_rules! m { () => {} }
6464
6565m!(); m2!();
66- //^^ error: unresolved macro `self:: m2!`
66+ //^^ error: unresolved macro `m2!`
6767"# ,
6868 ) ;
6969 }
You can’t perform that action at this time.
0 commit comments