Skip to content

Commit 4ebbb20

Browse files
authored
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 #104312
2 parents 66a4cb5 + b151410 commit 4ebbb20

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

compiler/rustc_resolve/src/late.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2360,8 +2360,8 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
23602360
if let GenericParamKind::Lifetime = param.kind {
23612361
// Record lifetime res, so lowering knows there is something fishy.
23622362
self.record_lifetime_param(param.id, LifetimeRes::Error);
2363-
continue;
23642363
}
2364+
continue;
23652365
}
23662366
Entry::Vacant(entry) => {
23672367
entry.insert(param.ident.span);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
trait Foo<const M: u8, const M: u8 = M> {}
2+
//~^ ERROR the name `M` is already used for a generic parameter in this item's generic parameters
3+
impl Foo<2> for () {}
4+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0403]: the name `M` is already used for a generic parameter in this item's generic parameters
2+
--> $DIR/self-referential.rs:1:30
3+
|
4+
LL | trait Foo<const M: u8, const M: u8 = M> {}
5+
| - ^ already used
6+
| |
7+
| first use of `M`
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0403`.

src/test/ui/duplicate/duplicate-type-parameter.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ LL | impl<T,T> Qux<T,T> for Option<T> {}
5555
| first use of `T`
5656

5757
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
58-
--> $DIR/duplicate-type-parameter.rs:24:6
58+
--> $DIR/duplicate-type-parameter.rs:24:8
5959
|
6060
LL | impl<T,T> Qux<T,T> for Option<T> {}
61-
| ^ unconstrained type parameter
61+
| ^ unconstrained type parameter
6262

6363
error: aborting due to 8 previous errors
6464

0 commit comments

Comments
 (0)