Skip recording resolution for duplicated generic params.

This commit is contained in:
Camille GILLOT 2022-12-03 22:40:30 +00:00
parent cab4fd678c
commit b1514108e2
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