Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/ui/object-safety/assoc_const_bounds.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
trait Foo<T> {
const BAR: bool
where //~ ERROR: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found keyword `where`
Self: Sized;
}

trait Cake {}
impl Cake for () {}

fn foo(_: &dyn Foo<()>) {}
fn bar(_: &dyn Foo<i32>) {}

fn main() {}
15 changes: 15 additions & 0 deletions tests/ui/object-safety/assoc_const_bounds.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found keyword `where`
--> $DIR/assoc_const_bounds.rs:3:9
|
LL | trait Foo<T> {
| - while parsing this item list starting here
LL | const BAR: bool
| - expected one of 7 possible tokens
LL | where
| ^^^^^ unexpected token
LL | Self: Sized;
LL | }
| - the item list ends here

error: aborting due to previous error

9 changes: 9 additions & 0 deletions tests/ui/object-safety/assoc_const_bounds_sized.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
trait Foo {
const BAR: bool
where //~ ERROR: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found keyword `where`
Self: Sized;
}

fn foo(_: &dyn Foo) {}

fn main() {}
15 changes: 15 additions & 0 deletions tests/ui/object-safety/assoc_const_bounds_sized.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found keyword `where`
--> $DIR/assoc_const_bounds_sized.rs:3:9
|
LL | trait Foo {
| - while parsing this item list starting here
LL | const BAR: bool
| - expected one of 7 possible tokens
LL | where
| ^^^^^ unexpected token
LL | Self: Sized;
LL | }
| - the item list ends here

error: aborting due to previous error

13 changes: 13 additions & 0 deletions tests/ui/object-safety/assoc_type_bounds.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
trait Foo<T> {
type Bar
where
T: Cake;
}

trait Cake {}
impl Cake for () {}

fn foo(_: &dyn Foo<()>) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified
fn bar(_: &dyn Foo<i32>) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified

fn main() {}
21 changes: 21 additions & 0 deletions tests/ui/object-safety/assoc_type_bounds.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified
--> $DIR/assoc_type_bounds.rs:10:16
|
LL | type Bar
| -------- `Bar` defined here
...
LL | fn foo(_: &dyn Foo<()>) {}
| ^^^^^^^ help: specify the associated type: `Foo<(), Bar = Type>`

error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified
--> $DIR/assoc_type_bounds.rs:11:16
|
LL | type Bar
| -------- `Bar` defined here
...
LL | fn bar(_: &dyn Foo<i32>) {}
| ^^^^^^^^ help: specify the associated type: `Foo<i32, Bar = Type>`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0191`.
13 changes: 13 additions & 0 deletions tests/ui/object-safety/assoc_type_bounds2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
trait Foo<T> {
type Bar
where
Self: Foo<()>;
}

trait Cake {}
impl Cake for () {}

fn foo(_: &dyn Foo<()>) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified
fn bar(_: &dyn Foo<i32>) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified

fn main() {}
21 changes: 21 additions & 0 deletions tests/ui/object-safety/assoc_type_bounds2.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified
--> $DIR/assoc_type_bounds2.rs:10:16
|
LL | type Bar
| -------- `Bar` defined here
...
LL | fn foo(_: &dyn Foo<()>) {}
| ^^^^^^^ help: specify the associated type: `Foo<(), Bar = Type>`

error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified
--> $DIR/assoc_type_bounds2.rs:11:16
|
LL | type Bar
| -------- `Bar` defined here
...
LL | fn bar(_: &dyn Foo<i32>) {}
| ^^^^^^^^ help: specify the associated type: `Foo<i32, Bar = Type>`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0191`.
9 changes: 9 additions & 0 deletions tests/ui/object-safety/assoc_type_bounds_sized.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
trait Foo {
type Bar
where
Self: Sized;
}

fn foo(_: &dyn Foo) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified

fn main() {}
12 changes: 12 additions & 0 deletions tests/ui/object-safety/assoc_type_bounds_sized.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified
--> $DIR/assoc_type_bounds_sized.rs:7:16
|
LL | type Bar
| -------- `Bar` defined here
...
LL | fn foo(_: &dyn Foo) {}
| ^^^ help: specify the associated type: `Foo<Bar = Type>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0191`.