]> git.lizzy.rs Git - rust.git/blob - tests/ui/wf/wf-unsafe-trait-obj-match.stderr
Auto merge of #106520 - ehuss:update-mdbook, r=Mark-Simulacrum
[rust.git] / tests / ui / wf / wf-unsafe-trait-obj-match.stderr
1 error[E0308]: `match` arms have incompatible types
2   --> $DIR/wf-unsafe-trait-obj-match.rs:23:17
3    |
4 LL | /     match opt() {
5 LL | |         Some(()) => &S,
6    | |                     -- this is found to be of type `&S`
7 LL | |         None => &R,
8    | |                 ^^ expected struct `S`, found struct `R`
9 LL | |     }
10    | |_____- `match` arms have incompatible types
11    |
12    = note: expected reference `&S`
13               found reference `&R`
14
15 error[E0038]: the trait `Trait` cannot be made into an object
16   --> $DIR/wf-unsafe-trait-obj-match.rs:26:21
17    |
18 LL |         Some(()) => &S,
19    |                     ^^ `Trait` cannot be made into an object
20    |
21 note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
22   --> $DIR/wf-unsafe-trait-obj-match.rs:6:14
23    |
24 LL | trait Trait: Sized {}
25    |       -----  ^^^^^ ...because it requires `Self: Sized`
26    |       |
27    |       this trait cannot be made into an object...
28    = note: required for `&S` to implement `CoerceUnsized<&dyn Trait>`
29    = note: required by cast to type `&dyn Trait`
30
31 error[E0038]: the trait `Trait` cannot be made into an object
32   --> $DIR/wf-unsafe-trait-obj-match.rs:25:25
33    |
34 LL |       let t: &dyn Trait = match opt() {
35    |  _________________________^
36 LL | |         Some(()) => &S,
37 LL | |         None => &R,
38 LL | |     };
39    | |_____^ `Trait` cannot be made into an object
40    |
41 note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
42   --> $DIR/wf-unsafe-trait-obj-match.rs:6:14
43    |
44 LL | trait Trait: Sized {}
45    |       -----  ^^^^^ ...because it requires `Self: Sized`
46    |       |
47    |       this trait cannot be made into an object...
48    = note: required for `&R` to implement `CoerceUnsized<&dyn Trait>`
49    = note: required by cast to type `&dyn Trait`
50
51 error: aborting due to 3 previous errors
52
53 Some errors have detailed explanations: E0038, E0308.
54 For more information about an error, try `rustc --explain E0038`.