mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Update Tests
This commit is contained in:
parent
25acbbd12f
commit
102997a939
@ -4,7 +4,15 @@ error[E0782]: trait objects must include the `dyn` keyword
|
|||||||
LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
|
LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
|
|
||||||
help: add `dyn` keyword before this trait
|
help: use a new generic type parameter, constrained by `SomeTrait`
|
||||||
|
|
|
||||||
|
LL | fn function<T: SomeTrait>(x: &T, y: Box<SomeTrait>) {
|
||||||
|
| ++++++++++++++ ~
|
||||||
|
help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference
|
||||||
|
|
|
||||||
|
LL | fn function(x: &impl SomeTrait, y: Box<SomeTrait>) {
|
||||||
|
| ++++
|
||||||
|
help: alternatively, use a trait object to accept any type that implements `SomeTrait`, accessing its methods at runtime using dynamic dispatch
|
||||||
|
|
|
|
||||||
LL | fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) {
|
LL | fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) {
|
||||||
| +++
|
| +++
|
||||||
|
@ -0,0 +1,142 @@
|
|||||||
|
//@ edition:2021
|
||||||
|
|
||||||
|
trait Trait {}
|
||||||
|
|
||||||
|
struct IceCream;
|
||||||
|
|
||||||
|
impl IceCream {
|
||||||
|
fn foo(_: &Trait) {}
|
||||||
|
//~^ ERROR: trait objects must include the `dyn` keyword
|
||||||
|
|
||||||
|
fn bar(self, _: &'a Trait) {}
|
||||||
|
//~^ ERROR: trait objects must include the `dyn` keyword
|
||||||
|
//~| ERROR: use of undeclared lifetime name
|
||||||
|
|
||||||
|
fn alice<'a>(&self, _: &Trait) {}
|
||||||
|
//~^ ERROR: trait objects must include the `dyn` keyword
|
||||||
|
|
||||||
|
fn bob<'a>(_: &'a Trait) {}
|
||||||
|
//~^ ERROR: trait objects must include the `dyn` keyword
|
||||||
|
|
||||||
|
fn cat() -> &Trait {
|
||||||
|
//~^ ERROR: missing lifetime specifier
|
||||||
|
//~| ERROR: trait objects must include the `dyn` keyword
|
||||||
|
&Type
|
||||||
|
}
|
||||||
|
|
||||||
|
fn dog<'a>() -> &Trait {
|
||||||
|
//~^ ERROR: missing lifetime specifier
|
||||||
|
//~| ERROR: trait objects must include the `dyn` keyword
|
||||||
|
&Type
|
||||||
|
}
|
||||||
|
|
||||||
|
fn kitten() -> &'a Trait {
|
||||||
|
//~^ ERROR: use of undeclared lifetime name
|
||||||
|
//~| ERROR: trait objects must include the `dyn` keyword
|
||||||
|
&Type
|
||||||
|
}
|
||||||
|
|
||||||
|
fn puppy<'a>() -> &'a Trait {
|
||||||
|
//~^ ERROR: trait objects must include the `dyn` keyword
|
||||||
|
&Type
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parrot() -> &mut Trait {
|
||||||
|
//~^ ERROR: missing lifetime specifier
|
||||||
|
//~| ERROR: cannot return a mutable reference to a bare trait
|
||||||
|
&mut Type
|
||||||
|
//~^ ERROR: cannot return reference to temporary value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
trait Sing {
|
||||||
|
fn foo(_: &Trait);
|
||||||
|
//~^ ERROR: trait objects must include the `dyn` keyword
|
||||||
|
|
||||||
|
fn bar(_: &'a Trait);
|
||||||
|
//~^ ERROR: trait objects must include the `dyn` keyword
|
||||||
|
//~| ERROR: use of undeclared lifetime name
|
||||||
|
|
||||||
|
fn alice<'a>(_: &Trait);
|
||||||
|
//~^ ERROR: trait objects must include the `dyn` keyword
|
||||||
|
|
||||||
|
fn bob<'a>(_: &'a Trait);
|
||||||
|
//~^ ERROR: trait objects must include the `dyn` keyword
|
||||||
|
|
||||||
|
fn cat() -> &Trait;
|
||||||
|
//~^ ERROR: missing lifetime specifier
|
||||||
|
//~| ERROR: trait objects must include the `dyn` keyword
|
||||||
|
|
||||||
|
fn dog<'a>() -> &Trait {
|
||||||
|
//~^ ERROR: missing lifetime specifier
|
||||||
|
//~| ERROR: trait objects must include the `dyn` keyword
|
||||||
|
&Type
|
||||||
|
}
|
||||||
|
|
||||||
|
fn kitten() -> &'a Trait {
|
||||||
|
//~^ ERROR: use of undeclared lifetime name
|
||||||
|
//~| ERROR: trait objects must include the `dyn` keyword
|
||||||
|
&Type
|
||||||
|
}
|
||||||
|
|
||||||
|
fn puppy<'a>() -> &'a Trait {
|
||||||
|
//~^ ERROR: trait objects must include the `dyn` keyword
|
||||||
|
&Type
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parrot() -> &mut Trait {
|
||||||
|
//~^ ERROR: missing lifetime specifier
|
||||||
|
//~| ERROR: cannot return a mutable reference to a bare trait
|
||||||
|
&mut Type
|
||||||
|
//~^ ERROR: cannot return reference to temporary value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn foo(_: &Trait) {}
|
||||||
|
//~^ ERROR: trait objects must include the `dyn` keyword
|
||||||
|
|
||||||
|
fn bar(_: &'a Trait) {}
|
||||||
|
//~^ ERROR: trait objects must include the `dyn` keyword
|
||||||
|
//~| ERROR: use of undeclared lifetime name
|
||||||
|
|
||||||
|
fn alice<'a>(_: &Trait) {}
|
||||||
|
//~^ ERROR: trait objects must include the `dyn` keyword
|
||||||
|
|
||||||
|
fn bob<'a>(_: &'a Trait) {}
|
||||||
|
//~^ ERROR: trait objects must include the `dyn` keyword
|
||||||
|
|
||||||
|
struct Type;
|
||||||
|
|
||||||
|
impl Trait for Type {}
|
||||||
|
|
||||||
|
fn cat() -> &Trait {
|
||||||
|
//~^ ERROR: missing lifetime specifier
|
||||||
|
//~| ERROR: trait objects must include the `dyn` keyword
|
||||||
|
&Type
|
||||||
|
}
|
||||||
|
|
||||||
|
fn dog<'a>() -> &Trait {
|
||||||
|
//~^ ERROR: missing lifetime specifier
|
||||||
|
//~| ERROR: trait objects must include the `dyn` keyword
|
||||||
|
&Type
|
||||||
|
}
|
||||||
|
|
||||||
|
fn kitten() -> &'a Trait {
|
||||||
|
//~^ ERROR: use of undeclared lifetime name
|
||||||
|
//~| ERROR: trait objects must include the `dyn` keyword
|
||||||
|
&Type
|
||||||
|
}
|
||||||
|
|
||||||
|
fn puppy<'a>() -> &'a Trait {
|
||||||
|
//~^ ERROR: trait objects must include the `dyn` keyword
|
||||||
|
&Type
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parrot() -> &mut Trait {
|
||||||
|
//~^ ERROR: missing lifetime specifier
|
||||||
|
//~| ERROR: cannot return a mutable reference to a bare trait
|
||||||
|
&mut Type
|
||||||
|
//~^ ERROR: cannot return reference to temporary value
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
@ -0,0 +1,673 @@
|
|||||||
|
error[E0261]: use of undeclared lifetime name `'a`
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:11:22
|
||||||
|
|
|
||||||
|
LL | fn bar(self, _: &'a Trait) {}
|
||||||
|
| ^^ undeclared lifetime
|
||||||
|
|
|
||||||
|
help: consider introducing lifetime `'a` here
|
||||||
|
|
|
||||||
|
LL | fn bar<'a>(self, _: &'a Trait) {}
|
||||||
|
| ++++
|
||||||
|
help: consider introducing lifetime `'a` here
|
||||||
|
|
|
||||||
|
LL | impl<'a> IceCream {
|
||||||
|
| ++++
|
||||||
|
|
||||||
|
error[E0106]: missing lifetime specifier
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:21:17
|
||||||
|
|
|
||||||
|
LL | fn cat() -> &Trait {
|
||||||
|
| ^ expected named lifetime parameter
|
||||||
|
|
|
||||||
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
|
||||||
|
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
||||||
|
|
|
||||||
|
LL | fn cat() -> &'static Trait {
|
||||||
|
| +++++++
|
||||||
|
|
||||||
|
error[E0106]: missing lifetime specifier
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:27:21
|
||||||
|
|
|
||||||
|
LL | fn dog<'a>() -> &Trait {
|
||||||
|
| ^ expected named lifetime parameter
|
||||||
|
|
|
||||||
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
|
||||||
|
help: consider using the `'a` lifetime
|
||||||
|
|
|
||||||
|
LL | fn dog<'a>() -> &'a Trait {
|
||||||
|
| ++
|
||||||
|
|
||||||
|
error[E0261]: use of undeclared lifetime name `'a`
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:33:21
|
||||||
|
|
|
||||||
|
LL | fn kitten() -> &'a Trait {
|
||||||
|
| ^^ undeclared lifetime
|
||||||
|
|
|
||||||
|
help: consider introducing lifetime `'a` here
|
||||||
|
|
|
||||||
|
LL | fn kitten<'a>() -> &'a Trait {
|
||||||
|
| ++++
|
||||||
|
help: consider introducing lifetime `'a` here
|
||||||
|
|
|
||||||
|
LL | impl<'a> IceCream {
|
||||||
|
| ++++
|
||||||
|
|
||||||
|
error[E0106]: missing lifetime specifier
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:44:20
|
||||||
|
|
|
||||||
|
LL | fn parrot() -> &mut Trait {
|
||||||
|
| ^ expected named lifetime parameter
|
||||||
|
|
|
||||||
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
|
||||||
|
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
||||||
|
|
|
||||||
|
LL | fn parrot() -> &'static mut Trait {
|
||||||
|
| +++++++
|
||||||
|
|
||||||
|
error[E0261]: use of undeclared lifetime name `'a`
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:56:16
|
||||||
|
|
|
||||||
|
LL | fn bar(_: &'a Trait);
|
||||||
|
| ^^ undeclared lifetime
|
||||||
|
|
|
||||||
|
help: consider introducing lifetime `'a` here
|
||||||
|
|
|
||||||
|
LL | fn bar<'a>(_: &'a Trait);
|
||||||
|
| ++++
|
||||||
|
help: consider introducing lifetime `'a` here
|
||||||
|
|
|
||||||
|
LL | trait Sing<'a> {
|
||||||
|
| ++++
|
||||||
|
|
||||||
|
error[E0106]: missing lifetime specifier
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:66:17
|
||||||
|
|
|
||||||
|
LL | fn cat() -> &Trait;
|
||||||
|
| ^ expected named lifetime parameter
|
||||||
|
|
|
||||||
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
|
||||||
|
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
||||||
|
|
|
||||||
|
LL | fn cat() -> &'static Trait;
|
||||||
|
| +++++++
|
||||||
|
help: instead, you are more likely to want to return an owned value
|
||||||
|
|
|
||||||
|
LL - fn cat() -> &Trait;
|
||||||
|
LL + fn cat() -> Trait;
|
||||||
|
|
|
||||||
|
|
||||||
|
error[E0106]: missing lifetime specifier
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:70:21
|
||||||
|
|
|
||||||
|
LL | fn dog<'a>() -> &Trait {
|
||||||
|
| ^ expected named lifetime parameter
|
||||||
|
|
|
||||||
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
|
||||||
|
help: consider using the `'a` lifetime
|
||||||
|
|
|
||||||
|
LL | fn dog<'a>() -> &'a Trait {
|
||||||
|
| ++
|
||||||
|
|
||||||
|
error[E0261]: use of undeclared lifetime name `'a`
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:76:21
|
||||||
|
|
|
||||||
|
LL | fn kitten() -> &'a Trait {
|
||||||
|
| ^^ undeclared lifetime
|
||||||
|
|
|
||||||
|
help: consider introducing lifetime `'a` here
|
||||||
|
|
|
||||||
|
LL | fn kitten<'a>() -> &'a Trait {
|
||||||
|
| ++++
|
||||||
|
help: consider introducing lifetime `'a` here
|
||||||
|
|
|
||||||
|
LL | trait Sing<'a> {
|
||||||
|
| ++++
|
||||||
|
|
||||||
|
error[E0106]: missing lifetime specifier
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:87:20
|
||||||
|
|
|
||||||
|
LL | fn parrot() -> &mut Trait {
|
||||||
|
| ^ expected named lifetime parameter
|
||||||
|
|
|
||||||
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
|
||||||
|
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
||||||
|
|
|
||||||
|
LL | fn parrot() -> &'static mut Trait {
|
||||||
|
| +++++++
|
||||||
|
|
||||||
|
error[E0261]: use of undeclared lifetime name `'a`
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:98:12
|
||||||
|
|
|
||||||
|
LL | fn bar(_: &'a Trait) {}
|
||||||
|
| - ^^ undeclared lifetime
|
||||||
|
| |
|
||||||
|
| help: consider introducing lifetime `'a` here: `<'a>`
|
||||||
|
|
||||||
|
error[E0106]: missing lifetime specifier
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:112:13
|
||||||
|
|
|
||||||
|
LL | fn cat() -> &Trait {
|
||||||
|
| ^ expected named lifetime parameter
|
||||||
|
|
|
||||||
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
|
||||||
|
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
||||||
|
|
|
||||||
|
LL | fn cat() -> &'static Trait {
|
||||||
|
| +++++++
|
||||||
|
|
||||||
|
error[E0106]: missing lifetime specifier
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:118:17
|
||||||
|
|
|
||||||
|
LL | fn dog<'a>() -> &Trait {
|
||||||
|
| ^ expected named lifetime parameter
|
||||||
|
|
|
||||||
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
|
||||||
|
help: consider using the `'a` lifetime
|
||||||
|
|
|
||||||
|
LL | fn dog<'a>() -> &'a Trait {
|
||||||
|
| ++
|
||||||
|
|
||||||
|
error[E0261]: use of undeclared lifetime name `'a`
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:124:17
|
||||||
|
|
|
||||||
|
LL | fn kitten() -> &'a Trait {
|
||||||
|
| - ^^ undeclared lifetime
|
||||||
|
| |
|
||||||
|
| help: consider introducing lifetime `'a` here: `<'a>`
|
||||||
|
|
||||||
|
error[E0106]: missing lifetime specifier
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:135:16
|
||||||
|
|
|
||||||
|
LL | fn parrot() -> &mut Trait {
|
||||||
|
| ^ expected named lifetime parameter
|
||||||
|
|
|
||||||
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
|
||||||
|
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
||||||
|
|
|
||||||
|
LL | fn parrot() -> &'static mut Trait {
|
||||||
|
| +++++++
|
||||||
|
|
||||||
|
error[E0515]: cannot return reference to temporary value
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:47:9
|
||||||
|
|
|
||||||
|
LL | &mut Type
|
||||||
|
| ^^^^^----
|
||||||
|
| | |
|
||||||
|
| | temporary value created here
|
||||||
|
| returns a reference to data owned by the current function
|
||||||
|
|
||||||
|
error[E0515]: cannot return reference to temporary value
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:90:9
|
||||||
|
|
|
||||||
|
LL | &mut Type
|
||||||
|
| ^^^^^----
|
||||||
|
| | |
|
||||||
|
| | temporary value created here
|
||||||
|
| returns a reference to data owned by the current function
|
||||||
|
|
||||||
|
error[E0515]: cannot return reference to temporary value
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:138:5
|
||||||
|
|
|
||||||
|
LL | &mut Type
|
||||||
|
| ^^^^^----
|
||||||
|
| | |
|
||||||
|
| | temporary value created here
|
||||||
|
| returns a reference to data owned by the current function
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:53:16
|
||||||
|
|
|
||||||
|
LL | fn foo(_: &Trait);
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use a new generic type parameter, constrained by `Trait`
|
||||||
|
|
|
||||||
|
LL | fn foo<T: Trait>(_: &T);
|
||||||
|
| ++++++++++ ~
|
||||||
|
help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference
|
||||||
|
|
|
||||||
|
LL | fn foo(_: &impl Trait);
|
||||||
|
| ++++
|
||||||
|
help: alternatively, use a trait object to accept any type that implements `Trait`, accessing its methods at runtime using dynamic dispatch
|
||||||
|
|
|
||||||
|
LL | fn foo(_: &dyn Trait);
|
||||||
|
| +++
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:56:19
|
||||||
|
|
|
||||||
|
LL | fn bar(_: &'a Trait);
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use a new generic type parameter, constrained by `Trait`
|
||||||
|
|
|
||||||
|
LL | fn bar<T: Trait>(_: &'a T);
|
||||||
|
| ++++++++++ ~
|
||||||
|
help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference
|
||||||
|
|
|
||||||
|
LL | fn bar(_: &'a impl Trait);
|
||||||
|
| ++++
|
||||||
|
help: alternatively, use a trait object to accept any type that implements `Trait`, accessing its methods at runtime using dynamic dispatch
|
||||||
|
|
|
||||||
|
LL | fn bar(_: &'a dyn Trait);
|
||||||
|
| +++
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:60:22
|
||||||
|
|
|
||||||
|
LL | fn alice<'a>(_: &Trait);
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use a new generic type parameter, constrained by `Trait`
|
||||||
|
|
|
||||||
|
LL | fn alice<'a, T: Trait>(_: &T);
|
||||||
|
| ++++++++++ ~
|
||||||
|
help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference
|
||||||
|
|
|
||||||
|
LL | fn alice<'a>(_: &impl Trait);
|
||||||
|
| ++++
|
||||||
|
help: alternatively, use a trait object to accept any type that implements `Trait`, accessing its methods at runtime using dynamic dispatch
|
||||||
|
|
|
||||||
|
LL | fn alice<'a>(_: &dyn Trait);
|
||||||
|
| +++
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:63:23
|
||||||
|
|
|
||||||
|
LL | fn bob<'a>(_: &'a Trait);
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use a new generic type parameter, constrained by `Trait`
|
||||||
|
|
|
||||||
|
LL | fn bob<'a, T: Trait>(_: &'a T);
|
||||||
|
| ++++++++++ ~
|
||||||
|
help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference
|
||||||
|
|
|
||||||
|
LL | fn bob<'a>(_: &'a impl Trait);
|
||||||
|
| ++++
|
||||||
|
help: alternatively, use a trait object to accept any type that implements `Trait`, accessing its methods at runtime using dynamic dispatch
|
||||||
|
|
|
||||||
|
LL | fn bob<'a>(_: &'a dyn Trait);
|
||||||
|
| +++
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:66:18
|
||||||
|
|
|
||||||
|
LL | fn cat() -> &Trait;
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use `impl Trait` to return an opaque type, as long as you return a single underlying type
|
||||||
|
|
|
||||||
|
LL | fn cat<'a>() -> &'a impl Trait;
|
||||||
|
| ++++ +++++++
|
||||||
|
help: alternatively, you can return an owned trait object
|
||||||
|
|
|
||||||
|
LL | fn cat() -> Box<dyn Trait>;
|
||||||
|
| ~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:70:22
|
||||||
|
|
|
||||||
|
LL | fn dog<'a>() -> &Trait {
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use `impl Trait` to return an opaque type, as long as you return a single underlying type
|
||||||
|
|
|
||||||
|
LL | fn dog<'b, 'a>() -> &'b impl Trait {
|
||||||
|
| +++ +++++++
|
||||||
|
help: alternatively, you can return an owned trait object
|
||||||
|
|
|
||||||
|
LL | fn dog<'a>() -> Box<dyn Trait> {
|
||||||
|
| ~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:76:24
|
||||||
|
|
|
||||||
|
LL | fn kitten() -> &'a Trait {
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use `impl Trait` to return an opaque type, as long as you return a single underlying type
|
||||||
|
|
|
||||||
|
LL | fn kitten() -> &'a impl Trait {
|
||||||
|
| ++++
|
||||||
|
help: alternatively, you can return an owned trait object
|
||||||
|
|
|
||||||
|
LL | fn kitten() -> Box<dyn Trait> {
|
||||||
|
| ~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:82:27
|
||||||
|
|
|
||||||
|
LL | fn puppy<'a>() -> &'a Trait {
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use `impl Trait` to return an opaque type, as long as you return a single underlying type
|
||||||
|
|
|
||||||
|
LL | fn puppy<'a>() -> &'a impl Trait {
|
||||||
|
| ++++
|
||||||
|
help: alternatively, you can return an owned trait object
|
||||||
|
|
|
||||||
|
LL | fn puppy<'a>() -> Box<dyn Trait> {
|
||||||
|
| ~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
error[E0782]: cannot return a mutable reference to a bare trait
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:87:25
|
||||||
|
|
|
||||||
|
LL | fn parrot() -> &mut Trait {
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use `impl Trait` to return an opaque type, as long as you return a single underlying type
|
||||||
|
|
|
||||||
|
LL | fn parrot() -> impl Trait {
|
||||||
|
| ~~~~~~~~~~
|
||||||
|
help: alternatively, you can return an owned trait object
|
||||||
|
|
|
||||||
|
LL | fn parrot() -> Box<dyn Trait> {
|
||||||
|
| ~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:95:12
|
||||||
|
|
|
||||||
|
LL | fn foo(_: &Trait) {}
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use a new generic type parameter, constrained by `Trait`
|
||||||
|
|
|
||||||
|
LL | fn foo<T: Trait>(_: &T) {}
|
||||||
|
| ++++++++++ ~
|
||||||
|
help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference
|
||||||
|
|
|
||||||
|
LL | fn foo(_: &impl Trait) {}
|
||||||
|
| ++++
|
||||||
|
help: alternatively, use a trait object to accept any type that implements `Trait`, accessing its methods at runtime using dynamic dispatch
|
||||||
|
|
|
||||||
|
LL | fn foo(_: &dyn Trait) {}
|
||||||
|
| +++
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:98:15
|
||||||
|
|
|
||||||
|
LL | fn bar(_: &'a Trait) {}
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use a new generic type parameter, constrained by `Trait`
|
||||||
|
|
|
||||||
|
LL | fn bar<T: Trait>(_: &'a T) {}
|
||||||
|
| ++++++++++ ~
|
||||||
|
help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference
|
||||||
|
|
|
||||||
|
LL | fn bar(_: &'a impl Trait) {}
|
||||||
|
| ++++
|
||||||
|
help: alternatively, use a trait object to accept any type that implements `Trait`, accessing its methods at runtime using dynamic dispatch
|
||||||
|
|
|
||||||
|
LL | fn bar(_: &'a dyn Trait) {}
|
||||||
|
| +++
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:102:18
|
||||||
|
|
|
||||||
|
LL | fn alice<'a>(_: &Trait) {}
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use a new generic type parameter, constrained by `Trait`
|
||||||
|
|
|
||||||
|
LL | fn alice<'a, T: Trait>(_: &T) {}
|
||||||
|
| ++++++++++ ~
|
||||||
|
help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference
|
||||||
|
|
|
||||||
|
LL | fn alice<'a>(_: &impl Trait) {}
|
||||||
|
| ++++
|
||||||
|
help: alternatively, use a trait object to accept any type that implements `Trait`, accessing its methods at runtime using dynamic dispatch
|
||||||
|
|
|
||||||
|
LL | fn alice<'a>(_: &dyn Trait) {}
|
||||||
|
| +++
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:105:19
|
||||||
|
|
|
||||||
|
LL | fn bob<'a>(_: &'a Trait) {}
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use a new generic type parameter, constrained by `Trait`
|
||||||
|
|
|
||||||
|
LL | fn bob<'a, T: Trait>(_: &'a T) {}
|
||||||
|
| ++++++++++ ~
|
||||||
|
help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference
|
||||||
|
|
|
||||||
|
LL | fn bob<'a>(_: &'a impl Trait) {}
|
||||||
|
| ++++
|
||||||
|
help: alternatively, use a trait object to accept any type that implements `Trait`, accessing its methods at runtime using dynamic dispatch
|
||||||
|
|
|
||||||
|
LL | fn bob<'a>(_: &'a dyn Trait) {}
|
||||||
|
| +++
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:112:14
|
||||||
|
|
|
||||||
|
LL | fn cat() -> &Trait {
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use `impl Trait` to return an opaque type, as long as you return a single underlying type
|
||||||
|
|
|
||||||
|
LL | fn cat<'a>() -> &'a impl Trait {
|
||||||
|
| ++++ +++++++
|
||||||
|
help: alternatively, you can return an owned trait object
|
||||||
|
|
|
||||||
|
LL | fn cat() -> Box<dyn Trait> {
|
||||||
|
| ~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:118:18
|
||||||
|
|
|
||||||
|
LL | fn dog<'a>() -> &Trait {
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use `impl Trait` to return an opaque type, as long as you return a single underlying type
|
||||||
|
|
|
||||||
|
LL | fn dog<'b, 'a>() -> &'b impl Trait {
|
||||||
|
| +++ +++++++
|
||||||
|
help: alternatively, you can return an owned trait object
|
||||||
|
|
|
||||||
|
LL | fn dog<'a>() -> Box<dyn Trait> {
|
||||||
|
| ~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:124:20
|
||||||
|
|
|
||||||
|
LL | fn kitten() -> &'a Trait {
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use `impl Trait` to return an opaque type, as long as you return a single underlying type
|
||||||
|
|
|
||||||
|
LL | fn kitten() -> &'a impl Trait {
|
||||||
|
| ++++
|
||||||
|
help: alternatively, you can return an owned trait object
|
||||||
|
|
|
||||||
|
LL | fn kitten() -> Box<dyn Trait> {
|
||||||
|
| ~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:130:23
|
||||||
|
|
|
||||||
|
LL | fn puppy<'a>() -> &'a Trait {
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use `impl Trait` to return an opaque type, as long as you return a single underlying type
|
||||||
|
|
|
||||||
|
LL | fn puppy<'a>() -> &'a impl Trait {
|
||||||
|
| ++++
|
||||||
|
help: alternatively, you can return an owned trait object
|
||||||
|
|
|
||||||
|
LL | fn puppy<'a>() -> Box<dyn Trait> {
|
||||||
|
| ~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
error[E0782]: cannot return a mutable reference to a bare trait
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:135:21
|
||||||
|
|
|
||||||
|
LL | fn parrot() -> &mut Trait {
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use `impl Trait` to return an opaque type, as long as you return a single underlying type
|
||||||
|
|
|
||||||
|
LL | fn parrot() -> impl Trait {
|
||||||
|
| ~~~~~~~~~~
|
||||||
|
help: alternatively, you can return an owned trait object
|
||||||
|
|
|
||||||
|
LL | fn parrot() -> Box<dyn Trait> {
|
||||||
|
| ~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:8:16
|
||||||
|
|
|
||||||
|
LL | fn foo(_: &Trait) {}
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use a new generic type parameter, constrained by `Trait`
|
||||||
|
|
|
||||||
|
LL | fn foo<T: Trait>(_: &T) {}
|
||||||
|
| ++++++++++ ~
|
||||||
|
help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference
|
||||||
|
|
|
||||||
|
LL | fn foo(_: &impl Trait) {}
|
||||||
|
| ++++
|
||||||
|
help: alternatively, use a trait object to accept any type that implements `Trait`, accessing its methods at runtime using dynamic dispatch
|
||||||
|
|
|
||||||
|
LL | fn foo(_: &dyn Trait) {}
|
||||||
|
| +++
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:11:25
|
||||||
|
|
|
||||||
|
LL | fn bar(self, _: &'a Trait) {}
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use a new generic type parameter, constrained by `Trait`
|
||||||
|
|
|
||||||
|
LL | fn bar<T: Trait>(self, _: &'a T) {}
|
||||||
|
| ++++++++++ ~
|
||||||
|
help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference
|
||||||
|
|
|
||||||
|
LL | fn bar(self, _: &'a impl Trait) {}
|
||||||
|
| ++++
|
||||||
|
help: alternatively, use a trait object to accept any type that implements `Trait`, accessing its methods at runtime using dynamic dispatch
|
||||||
|
|
|
||||||
|
LL | fn bar(self, _: &'a dyn Trait) {}
|
||||||
|
| +++
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:15:29
|
||||||
|
|
|
||||||
|
LL | fn alice<'a>(&self, _: &Trait) {}
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use a new generic type parameter, constrained by `Trait`
|
||||||
|
|
|
||||||
|
LL | fn alice<'a, T: Trait>(&self, _: &T) {}
|
||||||
|
| ++++++++++ ~
|
||||||
|
help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference
|
||||||
|
|
|
||||||
|
LL | fn alice<'a>(&self, _: &impl Trait) {}
|
||||||
|
| ++++
|
||||||
|
help: alternatively, use a trait object to accept any type that implements `Trait`, accessing its methods at runtime using dynamic dispatch
|
||||||
|
|
|
||||||
|
LL | fn alice<'a>(&self, _: &dyn Trait) {}
|
||||||
|
| +++
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:18:23
|
||||||
|
|
|
||||||
|
LL | fn bob<'a>(_: &'a Trait) {}
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use a new generic type parameter, constrained by `Trait`
|
||||||
|
|
|
||||||
|
LL | fn bob<'a, T: Trait>(_: &'a T) {}
|
||||||
|
| ++++++++++ ~
|
||||||
|
help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference
|
||||||
|
|
|
||||||
|
LL | fn bob<'a>(_: &'a impl Trait) {}
|
||||||
|
| ++++
|
||||||
|
help: alternatively, use a trait object to accept any type that implements `Trait`, accessing its methods at runtime using dynamic dispatch
|
||||||
|
|
|
||||||
|
LL | fn bob<'a>(_: &'a dyn Trait) {}
|
||||||
|
| +++
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:21:18
|
||||||
|
|
|
||||||
|
LL | fn cat() -> &Trait {
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use `impl Trait` to return an opaque type, as long as you return a single underlying type
|
||||||
|
|
|
||||||
|
LL | fn cat<'a>() -> &'a impl Trait {
|
||||||
|
| ++++ +++++++
|
||||||
|
help: alternatively, you can return an owned trait object
|
||||||
|
|
|
||||||
|
LL | fn cat() -> Box<dyn Trait> {
|
||||||
|
| ~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:27:22
|
||||||
|
|
|
||||||
|
LL | fn dog<'a>() -> &Trait {
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use `impl Trait` to return an opaque type, as long as you return a single underlying type
|
||||||
|
|
|
||||||
|
LL | fn dog<'b, 'a>() -> &'b impl Trait {
|
||||||
|
| +++ +++++++
|
||||||
|
help: alternatively, you can return an owned trait object
|
||||||
|
|
|
||||||
|
LL | fn dog<'a>() -> Box<dyn Trait> {
|
||||||
|
| ~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:33:24
|
||||||
|
|
|
||||||
|
LL | fn kitten() -> &'a Trait {
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use `impl Trait` to return an opaque type, as long as you return a single underlying type
|
||||||
|
|
|
||||||
|
LL | fn kitten() -> &'a impl Trait {
|
||||||
|
| ++++
|
||||||
|
help: alternatively, you can return an owned trait object
|
||||||
|
|
|
||||||
|
LL | fn kitten() -> Box<dyn Trait> {
|
||||||
|
| ~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
error[E0782]: trait objects must include the `dyn` keyword
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:39:27
|
||||||
|
|
|
||||||
|
LL | fn puppy<'a>() -> &'a Trait {
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use `impl Trait` to return an opaque type, as long as you return a single underlying type
|
||||||
|
|
|
||||||
|
LL | fn puppy<'a>() -> &'a impl Trait {
|
||||||
|
| ++++
|
||||||
|
help: alternatively, you can return an owned trait object
|
||||||
|
|
|
||||||
|
LL | fn puppy<'a>() -> Box<dyn Trait> {
|
||||||
|
| ~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
error[E0782]: cannot return a mutable reference to a bare trait
|
||||||
|
--> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:44:25
|
||||||
|
|
|
||||||
|
LL | fn parrot() -> &mut Trait {
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
help: use `impl Trait` to return an opaque type, as long as you return a single underlying type
|
||||||
|
|
|
||||||
|
LL | fn parrot() -> impl Trait {
|
||||||
|
| ~~~~~~~~~~
|
||||||
|
help: alternatively, you can return an owned trait object
|
||||||
|
|
|
||||||
|
LL | fn parrot() -> Box<dyn Trait> {
|
||||||
|
| ~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
error: aborting due to 45 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0106, E0261, E0515, E0782.
|
||||||
|
For more information about an error, try `rustc --explain E0106`.
|
Loading…
Reference in New Issue
Block a user