Skip to content

Commit def660c

Browse files
committed
UI unit test for note when matching tuple enum with struct pattern
1 parent 8a66362 commit def660c

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/test/ui/type-check/issue-41314.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
enum X {
12+
Y(u32)
13+
}
14+
15+
fn main() {
16+
match X::Y(0) {
17+
X::Y { number } => {}
18+
}
19+
}
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0026]: variant `X::Y` does not have a field named `number`
2+
--> $DIR/issue-41314.rs:17:16
3+
|
4+
17 | X::Y { number } => {}
5+
| ^^^^^^ variant `X::Y` does not have field `number`
6+
7+
error[E0027]: pattern does not mention field `0`
8+
--> $DIR/issue-41314.rs:17:9
9+
|
10+
17 | X::Y { number } => {}
11+
| ^^^^^^^^^^^^^^^ missing field `0`
12+
|
13+
= note: trying to match a tuple variant with a struct variant pattern
14+
15+
error: aborting due to 2 previous errors
16+

0 commit comments

Comments
 (0)