Skip to content

Commit fc3a5dc

Browse files
committed
Add test for issue-74816
1 parent c266c07 commit fc3a5dc

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#![feature(associated_type_defaults)]
2+
#![feature(generic_associated_types)]
3+
#![allow(incomplete_features)]
4+
5+
trait Trait1 {
6+
fn foo();
7+
}
8+
9+
trait Trait2 {
10+
type Associated: Trait1 = Self;
11+
//~^ ERROR: the trait bound `Self: Trait1` is not satisfied
12+
//~| the size for values of type `Self` cannot be known
13+
}
14+
15+
impl Trait2 for () {}
16+
17+
fn call_foo<T: Trait2>() {
18+
T::Associated::foo()
19+
}
20+
21+
fn main() {
22+
call_foo::<()>()
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
error[E0277]: the trait bound `Self: Trait1` is not satisfied
2+
--> $DIR/issue-74816.rs:10:5
3+
|
4+
LL | type Associated: Trait1 = Self;
5+
| ^^^^^^^^^^^^^^^^^------^^^^^^^^
6+
| | |
7+
| | required by this bound in `Trait2::Associated`
8+
| the trait `Trait1` is not implemented for `Self`
9+
|
10+
help: consider further restricting `Self`
11+
|
12+
LL | trait Trait2: Trait1 {
13+
| ^^^^^^^^
14+
15+
error[E0277]: the size for values of type `Self` cannot be known at compilation time
16+
--> $DIR/issue-74816.rs:10:5
17+
|
18+
LL | type Associated: Trait1 = Self;
19+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20+
| |
21+
| doesn't have a size known at compile-time
22+
| required by this bound in `Trait2::Associated`
23+
|
24+
help: consider further restricting `Self`
25+
|
26+
LL | trait Trait2: Sized {
27+
| ^^^^^^^
28+
29+
error: aborting due to 2 previous errors
30+
31+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)