Add more tests
This commit is contained in:
parent
62fbbac2d9
commit
ce3cff47e0
3 changed files with 59 additions and 0 deletions
|
@ -1,3 +1,6 @@
|
|||
//! This test checks that associated types only need to be
|
||||
//! mentioned in trait objects, if they don't require `Self: Sized`.
|
||||
|
||||
// check-pass
|
||||
|
||||
trait Foo {
|
||||
|
@ -8,4 +11,14 @@ trait Foo {
|
|||
|
||||
fn foo(_: &dyn Foo) {}
|
||||
|
||||
trait Other: Sized {}
|
||||
|
||||
trait Boo {
|
||||
type Assoc
|
||||
where
|
||||
Self: Other;
|
||||
}
|
||||
|
||||
fn boo(_: &dyn Boo) {}
|
||||
|
||||
fn main() {}
|
||||
|
|
25
tests/ui/object-safety/assoc_type_bounds_sized_others.rs
Normal file
25
tests/ui/object-safety/assoc_type_bounds_sized_others.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
//! This test checks that even if some associated types have
|
||||
//! `where Self: Sized` bounds, those without still need to be
|
||||
//! mentioned in trait objects.
|
||||
|
||||
trait Foo {
|
||||
type Bar
|
||||
where
|
||||
Self: Sized;
|
||||
type Bop;
|
||||
}
|
||||
|
||||
fn foo(_: &dyn Foo) {}
|
||||
//~^ ERROR the value of the associated type `Bop` (from trait `Foo`) must be specified
|
||||
|
||||
trait Bar {
|
||||
type Bop;
|
||||
type Bar
|
||||
where
|
||||
Self: Sized;
|
||||
}
|
||||
|
||||
fn bar(_: &dyn Bar) {}
|
||||
//~^ ERROR the value of the associated type `Bop` (from trait `Bar`) must be specified
|
||||
|
||||
fn main() {}
|
21
tests/ui/object-safety/assoc_type_bounds_sized_others.stderr
Normal file
21
tests/ui/object-safety/assoc_type_bounds_sized_others.stderr
Normal file
|
@ -0,0 +1,21 @@
|
|||
error[E0191]: the value of the associated type `Bop` (from trait `Foo`) must be specified
|
||||
--> $DIR/assoc_type_bounds_sized_others.rs:12:16
|
||||
|
|
||||
LL | type Bop;
|
||||
| -------- `Bop` defined here
|
||||
...
|
||||
LL | fn foo(_: &dyn Foo) {}
|
||||
| ^^^ help: specify the associated type: `Foo<Bop = Type>`
|
||||
|
||||
error[E0191]: the value of the associated type `Bop` (from trait `Bar`) must be specified
|
||||
--> $DIR/assoc_type_bounds_sized_others.rs:22:16
|
||||
|
|
||||
LL | type Bop;
|
||||
| -------- `Bop` defined here
|
||||
...
|
||||
LL | fn bar(_: &dyn Bar) {}
|
||||
| ^^^ help: specify the associated type: `Bar<Bop = Type>`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0191`.
|
Loading…
Add table
Reference in a new issue