Rollup merge of #105230 - cjgillot:issue-104312, r=petrochenkov

Skip recording resolution for duplicated generic params.

Turns out the fix was simpler than I thought.

Fixes https://github.com/rust-lang/rust/issues/104312
This commit is contained in:
Matthias Krüger 2022-12-05 20:43:44 +01:00 committed by GitHub
commit 4ebbb20dad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 3 deletions

View File

@ -2360,8 +2360,8 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
if let GenericParamKind::Lifetime = param.kind {
// Record lifetime res, so lowering knows there is something fishy.
self.record_lifetime_param(param.id, LifetimeRes::Error);
continue;
}
continue;
}
Entry::Vacant(entry) => {
entry.insert(param.ident.span);

View File

@ -0,0 +1,4 @@
trait Foo<const M: u8, const M: u8 = M> {}
//~^ ERROR the name `M` is already used for a generic parameter in this item's generic parameters
impl Foo<2> for () {}
fn main() {}

View File

@ -0,0 +1,11 @@
error[E0403]: the name `M` is already used for a generic parameter in this item's generic parameters
--> $DIR/self-referential.rs:1:30
|
LL | trait Foo<const M: u8, const M: u8 = M> {}
| - ^ already used
| |
| first use of `M`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0403`.

View File

@ -55,10 +55,10 @@ LL | impl<T,T> Qux<T,T> for Option<T> {}
| first use of `T`
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
--> $DIR/duplicate-type-parameter.rs:24:6
--> $DIR/duplicate-type-parameter.rs:24:8
|
LL | impl<T,T> Qux<T,T> for Option<T> {}
| ^ unconstrained type parameter
| ^ unconstrained type parameter
error: aborting due to 8 previous errors