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.7 KiB46 linesraw
1error[E0308]: `match` arms have incompatible types
2  --> $DIR/wf-unsafe-trait-obj-match.rs:23:17
3   |
4LL | /     match opt() {
5LL | |         Some(()) => &S,
6   | |                     -- this is found to be of type `&S`
7LL | |         None => &R,
8   | |                 ^^ expected struct `S`, found struct `R`
9LL | |     }
10   | |_____- `match` arms have incompatible types
11   |
12   = note:   expected type `&S`
13           found reference `&R`
14
15error[E0038]: the trait `Trait` cannot be made into an object
16  --> $DIR/wf-unsafe-trait-obj-match.rs:26:21
17   |
18LL | trait Trait: Sized {}
19   |       -----  ----- ...because it requires `Self: Sized`
20   |       |
21   |       this trait cannot be made into an object...
22...
23LL |         Some(()) => &S,
24   |                     ^^ the trait `Trait` cannot be made into an object
25   |
26   = note: required because of the requirements on the impl of `std::ops::CoerceUnsized<&dyn Trait>` for `&S`
27   = note: required by cast to type `&dyn Trait`
28
29error[E0038]: the trait `Trait` cannot be made into an object
30  --> $DIR/wf-unsafe-trait-obj-match.rs:25:25
31   |
32LL | trait Trait: Sized {}
33   |       -----  ----- ...because it requires `Self: Sized`
34   |       |
35   |       this trait cannot be made into an object...
36...
37LL |     let t: &dyn Trait = match opt() {
38   |                         ^^^^^^^^^^^ the trait `Trait` cannot be made into an object
39   |
40   = note: required because of the requirements on the impl of `std::ops::CoerceUnsized<&dyn Trait>` for `&R`
41   = note: required by cast to type `&dyn Trait`
42
43error: aborting due to 3 previous errors
44
45Some errors have detailed explanations: E0038, E0308.
46For more information about an error, try `rustc --explain E0038`.