Don't consider RibKind::Module's bindings when checking generics shadowing

This commit is contained in:
Michael Goulet 2024-08-19 10:57:03 -04:00
parent c6f81a452e
commit 78d0e08504
2 changed files with 11 additions and 3 deletions

View file

@ -2677,14 +2677,14 @@ fn with_generic_param_rib<'c, F>(
// We also can't shadow bindings from associated parent items.
for ns in [ValueNS, TypeNS] {
for parent_rib in self.ribs[ns].iter().rev() {
seen_bindings
.extend(parent_rib.bindings.keys().map(|ident| (*ident, ident.span)));
// Break at mod level, to account for nested items which are
// allowed to shadow generic param names.
if matches!(parent_rib.kind, RibKind::Module(..)) {
break;
}
seen_bindings
.extend(parent_rib.bindings.keys().map(|ident| (*ident, ident.span)));
}
}

View file

@ -0,0 +1,8 @@
//@ check-pass
#![allow(non_camel_case_types)]
pub fn main() {
let a = 1;
struct Foo<a> { field: a, };
}