File tree 3 files changed +29
-7
lines changed
ide_diagnostics/src/handlers
3 files changed +29
-7
lines changed Original file line number Diff line number Diff line change @@ -1890,7 +1890,7 @@ impl ModCollector<'_, '_> {
1890
1890
}
1891
1891
1892
1892
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 ( ) ) ;
1894
1894
1895
1895
// Case 1: try to resolve in legacy scope and expand macro_rules
1896
1896
let mut error = None ;
@@ -1941,11 +1941,6 @@ impl ModCollector<'_, '_> {
1941
1941
}
1942
1942
1943
1943
// 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
-
1949
1944
self . def_collector . unresolved_macros . push ( MacroDirective {
1950
1945
module_id : self . module_id ,
1951
1946
depth : self . macro_depth + 1 ,
Original file line number Diff line number Diff line change @@ -349,8 +349,10 @@ macro_rules! m {
349
349
"# ,
350
350
expect ! [ [ r#"
351
351
crate
352
+ S: t v
352
353
"# ] ] ,
353
354
) ;
355
+ // FIXME: should not expand. legacy macro scoping is not implemented.
354
356
}
355
357
356
358
#[ test]
@@ -427,6 +429,7 @@ macro_rules! baz {
427
429
"# ,
428
430
expect ! [ [ r#"
429
431
crate
432
+ NotFoundBefore: t v
430
433
Ok: t v
431
434
OkAfter: t v
432
435
OkShadowStop: t v
@@ -462,6 +465,7 @@ macro_rules! baz {
462
465
crate::m3::m5
463
466
"# ] ] ,
464
467
) ;
468
+ // FIXME: should not see `NotFoundBefore`
465
469
}
466
470
467
471
#[ test]
@@ -994,3 +998,26 @@ structs!(Foo);
994
998
"# ] ] ,
995
999
) ;
996
1000
}
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);
63
63
macro_rules! m { () => {} }
64
64
65
65
m!(); m2!();
66
- //^^ error: unresolved macro `self:: m2!`
66
+ //^^ error: unresolved macro `m2!`
67
67
"# ,
68
68
) ;
69
69
}
You can’t perform that action at this time.
0 commit comments