]> git.lizzy.rs Git - rust.git/blob - tests/ui/wf/wf-unsafe-trait-obj-match.rs
Rollup merge of #106144 - tgross35:patch-1, r=Mark-Simulacrum
[rust.git] / tests / ui / wf / wf-unsafe-trait-obj-match.rs
1 // Check that we do not allow coercions to object
2 // unsafe trait objects in match arms
3
4 #![feature(object_safe_for_dispatch)]
5
6 trait Trait: Sized {}
7
8 struct S;
9
10 impl Trait for S {}
11
12 struct R;
13
14 impl Trait for R {}
15
16 fn opt() -> Option<()> {
17     Some(())
18 }
19
20 fn main() {
21     match opt() {
22         Some(()) => &S,
23         None => &R,  //~ ERROR E0308
24     }
25     let t: &dyn Trait = match opt() { //~ ERROR E0038
26         Some(()) => &S, //~ ERROR E0038
27         None => &R,
28     };
29 }