]> git.proxmox.com Git - rustc.git/blob - src/test/ui/try-on-option-diagnostics.rs
New upstream version 1.53.0+dfsg1
[rustc.git] / src / test / ui / try-on-option-diagnostics.rs
1 #![feature(try_trait)]
2 // edition:2018
3 fn main() {}
4
5 fn a_function() -> u32 {
6 let x: Option<u32> = None;
7 x?; //~ ERROR the `?` operator
8 22
9 }
10
11 fn a_closure() -> u32 {
12 let a_closure = || {
13 let x: Option<u32> = None;
14 x?; //~ ERROR the `?` operator
15 22
16 };
17 a_closure()
18 }
19
20 fn a_method() -> u32 {
21 struct S;
22
23 impl S {
24 fn a_method() {
25 let x: Option<u32> = None;
26 x?; //~ ERROR the `?` operator
27 }
28 }
29
30 S::a_method();
31 22
32 }
33
34 fn a_trait_method() -> u32 {
35 struct S;
36 trait T {
37 fn a_trait_method() {
38 let x: Option<u32> = None;
39 x?; //~ ERROR the `?` operator
40 }
41 }
42
43 impl T for S { }
44
45 S::a_trait_method();
46 22
47 }