fork/rust

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

borsAuto merge of #71868 - Mark-Simulacrum:stable-1.43.1, r=pietroalbini8d69840ab92

1.43.1
1.5 KiB35 linesraw
1error[E0038]: the trait `Trait` cannot be made into an object
2  --> $DIR/object-unsafe-trait-should-use-where-sized.rs:9:11
3   |
4LL | trait Trait {
5   |       ----- this trait cannot be made into an object...
6LL |     fn foo() where Self: Other, { }
7   |        --- ...because associated function `foo` has no `self` parameter
8LL |     fn bar(self: ()) {}
9   |                  -- ...because method `bar`'s `self` parameter cannot be dispatched on
10...
11LL | fn bar(x: &dyn Trait) {}
12   |           ^^^^^^^^^^ the trait `Trait` cannot be made into an object
13   |
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: Other, Self: Sized, { }
17   |                               ^^^^^^^^^^^^^
18help: consider changing method `bar`'s `self` parameter to be `&self`
19   |
20LL |     fn bar(self: &Self) {}
21   |                  ^^^^^
22
23error[E0307]: invalid `self` parameter type: ()
24  --> $DIR/object-unsafe-trait-should-use-where-sized.rs:6:18
25   |
26LL |     fn bar(self: ()) {}
27   |                  ^^
28   |
29   = note: type of `self` must be `Self` or a type that dereferences to it
30   = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
31
32error: aborting due to 2 previous errors
33
34Some errors have detailed explanations: E0038, E0307.
35For more information about an error, try `rustc --explain E0038`.