Skip to content

Commit 0d01d23

Browse files
authored
Unrolled build for rust-lang#129270
Rollup merge of rust-lang#129270 - compiler-errors:inner-generics-shadowing, r=petrochenkov Don't consider locals to shadow inner items' generics We don't want to consider the bindings from a `RibKind::Module` itself, because for an inner item that module will contain the local bindings from the function body or wherever else the inner item is being defined. Fixes rust-lang#129265 r? petrochenkov
2 parents 5aea140 + 78d0e08 commit 0d01d23

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

compiler/rustc_resolve/src/late.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2677,14 +2677,14 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
26772677
// We also can't shadow bindings from associated parent items.
26782678
for ns in [ValueNS, TypeNS] {
26792679
for parent_rib in self.ribs[ns].iter().rev() {
2680-
seen_bindings
2681-
.extend(parent_rib.bindings.keys().map(|ident| (*ident, ident.span)));
2682-
26832680
// Break at mod level, to account for nested items which are
26842681
// allowed to shadow generic param names.
26852682
if matches!(parent_rib.kind, RibKind::Module(..)) {
26862683
break;
26872684
}
2685+
2686+
seen_bindings
2687+
.extend(parent_rib.bindings.keys().map(|ident| (*ident, ident.span)));
26882688
}
26892689
}
26902690

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ check-pass
2+
3+
#![allow(non_camel_case_types)]
4+
5+
pub fn main() {
6+
let a = 1;
7+
struct Foo<a> { field: a, };
8+
}

0 commit comments

Comments
 (0)