Skip to content

Commit b919675

Browse files
committed
Added regression test for 117446
1 parent ef972a3 commit b919675

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//@ check-fail
2+
//
3+
// Regression for https://github.com/rust-lang/rust/issues/117446
4+
5+
pub struct Repeated<T>(Vec<T>);
6+
7+
trait Foo<'a> {
8+
fn outer<D>() -> Option<()>;
9+
}
10+
11+
impl<'a, T> Foo<'a> for Repeated<T> {
12+
fn outer() -> Option<()> {
13+
//~^ ERROR associated function `outer` has 0 type parameters but its trait declaration has 1 type parameter [E0049]
14+
//~^^ ERROR mismatched types [E0308]
15+
fn inner<Q>(value: Option<()>) -> Repeated<Q> {
16+
match value {
17+
_ => Self(unimplemented!()),
18+
//~^ ERROR can't reference `Self` constructor from outer item [E0401]
19+
}
20+
}
21+
}
22+
}
23+
24+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
error[E0049]: associated function `outer` has 0 type parameters but its trait declaration has 1 type parameter
2+
--> $DIR/ice-index-out-of-bounds-issue-117446.rs:12:13
3+
|
4+
LL | fn outer<D>() -> Option<()>;
5+
| - expected 1 type parameter
6+
...
7+
LL | fn outer() -> Option<()> {
8+
| ^ found 0 type parameters
9+
10+
error[E0308]: mismatched types
11+
--> $DIR/ice-index-out-of-bounds-issue-117446.rs:12:19
12+
|
13+
LL | fn outer() -> Option<()> {
14+
| ----- ^^^^^^^^^^ expected `Option<()>`, found `()`
15+
| |
16+
| implicitly returns `()` as its body has no tail or `return` expression
17+
|
18+
= note: expected enum `Option<()>`
19+
found unit type `()`
20+
21+
error[E0401]: can't reference `Self` constructor from outer item
22+
--> $DIR/ice-index-out-of-bounds-issue-117446.rs:17:22
23+
|
24+
LL | impl<'a, T> Foo<'a> for Repeated<T> {
25+
| ----------------------------------- the inner item doesn't inherit generics from this impl, so `Self` is invalid to reference
26+
...
27+
LL | _ => Self(unimplemented!()),
28+
| ^^^^ help: replace `Self` with the actual type: `Repeated`
29+
30+
error: aborting due to 3 previous errors
31+
32+
Some errors have detailed explanations: E0049, E0308, E0401.
33+
For more information about an error, try `rustc --explain E0049`.

0 commit comments

Comments
 (0)