]> git.lizzy.rs Git - rust.git/blob - src/test/ui/match/match-incompat-type-semi.rs
Auto merge of #106349 - LeSeulArtichaut:dyn-star-tracking-issue, r=jackh726
[rust.git] / src / test / ui / match / match-incompat-type-semi.rs
1 // Diagnostic enhancement explained in issue #75418.
2 // Point at the last statement in the block if there's no tail expression,
3 // and suggest removing the semicolon if appropriate.
4
5 fn main() {
6     let _ = match Some(42) {
7         Some(x) => {
8             x
9         },
10         None => {
11             0;
12             //~^ ERROR incompatible types
13             //~| HELP consider removing this semicolon
14         },
15     };
16
17     let _ = if let Some(x) = Some(42) {
18         x
19     } else {
20         0;
21         //~^ ERROR incompatible types
22         //~| HELP consider removing this semicolon
23     };
24
25     let _ = match Some(42) {
26         Some(x) => {
27             x
28         },
29         None => {
30             ();
31             //~^ ERROR incompatible types
32         },
33     };
34
35     let _ = match Some(42) {
36         Some(x) => {
37             x
38         },
39         None => { //~ ERROR incompatible types
40         },
41     };
42
43     let _ = match Some(42) {
44         Some(x) => "rust-lang.org"
45             .chars()
46             .skip(1)
47             .chain(Some(x as u8 as char))
48             .take(10)
49             .any(char::is_alphanumeric),
50         None => {} //~ ERROR incompatible types
51     };
52 }