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.8 KiB54 linesraw
1error: associated item referring to unboxed trait object for its own trait
2  --> $DIR/object-unsafe-trait-should-use-self.rs:3:13
3   |
4LL | trait A: Sized {
5   |       - in this trait
6LL |     fn f(a: A) -> A;
7   |             ^     ^
8   |
9help: you might have meant to use `Self` to refer to the implementing type
10   |
11LL |     fn f(a: Self) -> Self;
12   |             ^^^^     ^^^^
13
14error[E0038]: the trait `A` cannot be made into an object
15  --> $DIR/object-unsafe-trait-should-use-self.rs:3:13
16   |
17LL | trait A: Sized {
18   |       -  ----- ...because it requires `Self: Sized`
19   |       |
20   |       this trait cannot be made into an object...
21LL |     fn f(a: A) -> A;
22   |             ^ the trait `A` cannot be made into an object
23
24error: associated item referring to unboxed trait object for its own trait
25  --> $DIR/object-unsafe-trait-should-use-self.rs:8:13
26   |
27LL | trait B {
28   |       - in this trait
29LL |     fn f(a: B) -> B;
30   |             ^     ^
31   |
32help: you might have meant to use `Self` to refer to the implementing type
33   |
34LL |     fn f(a: Self) -> Self;
35   |             ^^^^     ^^^^
36
37error[E0038]: the trait `B` cannot be made into an object
38  --> $DIR/object-unsafe-trait-should-use-self.rs:8:13
39   |
40LL | trait B {
41   |       - this trait cannot be made into an object...
42LL |     fn f(a: B) -> B;
43   |        -    ^ the trait `B` cannot be made into an object
44   |        |
45   |        ...because associated function `f` has no `self` parameter
46   |
47help: consider turning `f` into a method by giving it a `&self` argument or constraining it so it does not apply to trait objects
48   |
49LL |     fn f(a: B) -> B where Self: Sized;
50   |                     ^^^^^^^^^^^^^^^^^
51
52error: aborting due to 4 previous errors
53
54For more information about this error, try `rustc --explain E0038`.