mirror of
https://github.com/openharmony/third_party_rust_rust.git
synced 2026-07-19 19:53:38 -04:00
Add more tests
This commit is contained in:
@@ -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() {}
|
||||
|
||||
@@ -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() {}
|
||||
@@ -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`.
|
||||
Reference in New Issue
Block a user