parent
e89ce461d3
commit
5e23cc4960
4 changed files with 161 additions and 0 deletions
9
src/test/ui/traits/assoc_type_bound_with_struct.rs
Normal file
9
src/test/ui/traits/assoc_type_bound_with_struct.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
trait Bar {
|
||||
type Baz;
|
||||
}
|
||||
|
||||
struct Foo<T> where T: Bar, <T as Bar>::Baz: String { //~ ERROR expected trait, found struct
|
||||
t: T,
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
23
src/test/ui/traits/assoc_type_bound_with_struct.stderr
Normal file
23
src/test/ui/traits/assoc_type_bound_with_struct.stderr
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
error[E0404]: expected trait, found struct `String`
|
||||
--> $DIR/assoc_type_bound_with_struct.rs:5:46
|
||||
|
|
||||
LL | struct Foo<T> where T: Bar, <T as Bar>::Baz: String {
|
||||
| ^^^^^^ not a trait
|
||||
|
|
||||
::: $SRC_DIR/alloc/src/string.rs:LL:COL
|
||||
|
|
||||
LL | pub trait ToString {
|
||||
| ------------------ similarly named trait `ToString` defined here
|
||||
|
|
||||
help: constrain the associated type to `String`
|
||||
|
|
||||
LL | struct Foo<T> where T: Bar, T: Bar<Baz = String> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
help: a trait with a similar name exists
|
||||
|
|
||||
LL | struct Foo<T> where T: Bar, <T as Bar>::Baz: ToString {
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0404`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue