File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed
src/tools/rust-analyzer/crates Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -1606,7 +1606,11 @@ impl ModCollector<'_, '_> {
16061606
16071607 // Prelude module is always considered to be `#[macro_use]`.
16081608 if let Some ( ( prelude_module, _use) ) = self . def_collector . def_map . prelude {
1609- if prelude_module. krate != krate && is_crate_root {
1609+ // Don't insert macros from the prelude into blocks, as they can be shadowed by other macros.
1610+ if prelude_module. krate != krate
1611+ && is_crate_root
1612+ && self . def_collector . def_map . block . is_none ( )
1613+ {
16101614 cov_mark:: hit!( prelude_is_macro_use) ;
16111615 self . def_collector . import_macros_from_extern_crate (
16121616 prelude_module. krate ,
Original file line number Diff line number Diff line change @@ -2731,4 +2731,23 @@ fn main() {
27312731"# ,
27322732 )
27332733 }
2734+
2735+ #[ test]
2736+ fn shadow_builtin_macro ( ) {
2737+ check (
2738+ r#"
2739+ //- minicore: column
2740+ //- /a.rs crate:a
2741+ #[macro_export]
2742+ macro_rules! column { () => {} }
2743+ // ^^^^^^
2744+
2745+ //- /b.rs crate:b deps:a
2746+ use a::column;
2747+ fn foo() {
2748+ $0column!();
2749+ }
2750+ "# ,
2751+ ) ;
2752+ }
27342753}
Original file line number Diff line number Diff line change 6363//! unsize: sized
6464//! todo: panic
6565//! unimplemented: panic
66+ //! column:
6667
6768#![ rustc_coherence_is_core]
6869
@@ -1617,6 +1618,14 @@ pub mod error {
16171618}
16181619// endregion:error
16191620
1621+ // region:column
1622+ #[ rustc_builtin_macro]
1623+ #[ macro_export]
1624+ macro_rules! column {
1625+ ( ) => { } ;
1626+ }
1627+ // endregion:column
1628+
16201629pub mod prelude {
16211630 pub mod v1 {
16221631 pub use crate :: {
You can’t perform that action at this time.
0 commit comments