Skip to content

Commit fd28614

Browse files
Add regression test for #26681
1 parent 1f61f36 commit fd28614

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#![feature(associated_type_defaults)]
2+
3+
// This is a partial regression test for #26681, which used to fail to resolve
4+
// `Self` in the assoc. constant, and now fails with a type mismatch because
5+
// `Self::Fv` cannot be assumed to equal `u8` inside the trait.
6+
7+
trait Foo {
8+
type Bar;
9+
}
10+
11+
impl Foo for u8 {
12+
type Bar = ();
13+
}
14+
15+
trait Baz {
16+
type Fv: Foo = u8;
17+
const C: <Self::Fv as Foo>::Bar = 6665; //~ error: mismatched types
18+
}
19+
20+
fn main() {}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/issue-26681.rs:17:39
3+
|
4+
LL | const C: <Self::Fv as Foo>::Bar = 6665;
5+
| ^^^^ expected associated type, found integer
6+
|
7+
= note: expected type `<<Self as Baz>::Fv as Foo>::Bar`
8+
found type `{integer}`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)