File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -387,7 +387,13 @@ impl DefMap {
387
387
. get_legacy_macro ( name)
388
388
. map_or_else ( PerNs :: none, |m| PerNs :: macros ( m, Visibility :: Public ) ) ;
389
389
let from_scope = self [ module] . scope . get ( name) ;
390
- let from_builtin = BUILTIN_SCOPE . get ( name) . copied ( ) . unwrap_or_else ( PerNs :: none) ;
390
+ let from_builtin = match self . block {
391
+ Some ( _) => {
392
+ // Only resolve to builtins in the root `DefMap`.
393
+ PerNs :: none ( )
394
+ }
395
+ None => BUILTIN_SCOPE . get ( name) . copied ( ) . unwrap_or_else ( PerNs :: none) ,
396
+ } ;
391
397
let from_scope_or_builtin = match shadow {
392
398
BuiltinShadowMode :: Module => from_scope. or ( from_builtin) ,
393
399
BuiltinShadowMode :: Other => {
Original file line number Diff line number Diff line change @@ -1764,6 +1764,24 @@ fn main() {
1764
1764
) ;
1765
1765
}
1766
1766
1767
+ #[ test]
1768
+ fn shadowing_primitive_with_inner_items ( ) {
1769
+ check_types (
1770
+ r#"
1771
+ struct i32;
1772
+ struct Foo;
1773
+
1774
+ impl i32 { fn foo(&self) -> Foo { Foo } }
1775
+
1776
+ fn main() {
1777
+ fn inner() {}
1778
+ let x: i32 = i32;
1779
+ x.foo();
1780
+ //^ Foo
1781
+ }"# ,
1782
+ ) ;
1783
+ }
1784
+
1767
1785
#[ test]
1768
1786
fn not_shadowing_primitive_by_module ( ) {
1769
1787
check_types (
You can’t perform that action at this time.
0 commit comments