mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 17:24:06 +00:00
8551cab7b7
Note the parentheses in the last suggestion: ``` error[E0277]: the size for values of type `(dyn Foo + Send + 'static)` cannot be known at compilation time --> $DIR/not-on-bare-trait.rs:7:8 | LL | fn foo(_x: Foo + Send) { | ^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn Foo + Send + 'static)` = help: unsized fn params are gated as an unstable feature help: you can use `impl Trait` as the argument type | LL | fn foo(_x: impl Foo + Send) { | ++++ help: function arguments must have a statically known size, borrowed types always have a known size | LL | fn foo(_x: &(Foo + Send)) { | ++ + ```
17 lines
396 B
Rust
17 lines
396 B
Rust
trait Foo {
|
|
fn dummy(&self) {}
|
|
}
|
|
|
|
// This should emit the less confusing error, not the more confusing one.
|
|
|
|
fn foo(_x: Foo + Send) {
|
|
//~^ ERROR the size for values of type
|
|
//~| WARN trait objects without an explicit `dyn` are deprecated
|
|
//~| WARN this is accepted in the current edition
|
|
}
|
|
fn bar(_x: (dyn Foo + Send)) {
|
|
//~^ ERROR the size for values of type
|
|
}
|
|
|
|
fn main() {}
|