fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #71365 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum4fb7144ed15

1.43.0
1.4 KiB37 linesraw
1error[E0038]: the trait `Tr` cannot be made into an object
2  --> $DIR/trait-object-safety.rs:15:22
3   |
4LL | trait Tr {
5   |       -- this trait cannot be made into an object...
6LL |     fn foo();
7   |        --- ...because associated function `foo` has no `self` parameter
8...
9LL |     let _: &dyn Tr = &St;
10   |                      ^^^ the trait `Tr` cannot be made into an object
11   |
12   = note: required because of the requirements on the impl of `std::ops::CoerceUnsized<&dyn Tr>` for `&St`
13   = note: required by cast to type `&dyn Tr`
14help: consider turning `foo` into a method by giving it a `&self` argument or constraining it so it does not apply to trait objects
15   |
16LL |     fn foo() where Self: Sized;
17   |              ^^^^^^^^^^^^^^^^^
18
19error[E0038]: the trait `Tr` cannot be made into an object
20  --> $DIR/trait-object-safety.rs:15:12
21   |
22LL | trait Tr {
23   |       -- this trait cannot be made into an object...
24LL |     fn foo();
25   |        --- ...because associated function `foo` has no `self` parameter
26...
27LL |     let _: &dyn Tr = &St;
28   |            ^^^^^^^ the trait `Tr` cannot be made into an object
29   |
30help: consider turning `foo` into a method by giving it a `&self` argument or constraining it so it does not apply to trait objects
31   |
32LL |     fn foo() where Self: Sized;
33   |              ^^^^^^^^^^^^^^^^^
34
35error: aborting due to 2 previous errors
36
37For more information about this error, try `rustc --explain E0038`.