File tree Expand file tree Collapse file tree 3 files changed +31
-9
lines changed Expand file tree Collapse file tree 3 files changed +31
-9
lines changed Original file line number Diff line number Diff line change @@ -2599,13 +2599,14 @@ impl<'a> Resolver<'a> {
2599
2599
}
2600
2600
_ => { }
2601
2601
} ,
2602
- ( Def :: Enum ( ..) , PathSource :: TupleStruct ) => {
2602
+ ( Def :: Enum ( ..) , PathSource :: TupleStruct )
2603
+ | ( Def :: Enum ( ..) , PathSource :: Expr ( ..) ) => {
2603
2604
if let Some ( variants) = this. collect_enum_variants ( def) {
2604
2605
err. note ( & format ! ( "did you mean to use one \
2605
2606
of the following variants?\n {}",
2606
2607
variants. iter( )
2607
- . map( |suggestion| format! ( "- `{}`" ,
2608
- path_names_to_string ( suggestion) ) )
2608
+ . map( |suggestion| path_names_to_string ( suggestion ) )
2609
+ . map ( |suggestion| format! ( "- `{}`" , suggestion) )
2609
2610
. collect:: <Vec <_>>( )
2610
2611
. join( "\n " ) ) ) ;
2611
2612
@@ -3559,6 +3560,8 @@ impl<'a> Resolver<'a> {
3559
3560
}
3560
3561
3561
3562
self . find_module ( enum_def) . map ( |( enum_module, enum_import_suggestion) | {
3563
+ self . populate_module_if_necessary ( enum_module) ;
3564
+
3562
3565
let mut variants = Vec :: new ( ) ;
3563
3566
enum_module. for_each_child_stable ( |ident, _, name_binding| {
3564
3567
if let Def :: Variant ( ..) = name_binding. def ( ) {
Original file line number Diff line number Diff line change 8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
+ enum Example { Ex ( String ) , NotEx }
12
+
11
13
fn result_test ( ) {
12
14
let x = Option ( 1 ) ;
13
15
14
16
if let Option ( _) = x {
15
17
println ! ( "It is OK." ) ;
16
18
}
19
+
20
+ let y = Example :: Ex ( String :: from ( "test" ) ) ;
21
+
22
+ if let Example ( _) = y {
23
+ println ! ( "It is OK." ) ;
24
+ }
17
25
}
18
26
19
27
fn main ( ) { }
Original file line number Diff line number Diff line change 1
1
error[E0423]: expected function, found enum `Option`
2
- --> $DIR/issue-43871-enum-instead-of-variant.rs:12:13
2
+ --> $DIR/issue-43871-enum-instead-of-variant.rs:14:13
3
+ |
4
+ 14 | let x = Option(1);
5
+ | ^^^^^^
3
6
|
4
- 12 | let x = Option(1);
5
- | ^^^^^^ not a function
6
7
= note: did you mean to use one of the following variants?
7
8
- `std::prelude::v1::Option::None`
8
9
- `std::prelude::v1::Option::Some`
9
10
10
11
error[E0532]: expected tuple struct/variant, found enum `Option`
11
- --> $DIR/issue-43871-enum-instead-of-variant.rs:14 :12
12
+ --> $DIR/issue-43871-enum-instead-of-variant.rs:16 :12
12
13
|
13
- 14 | if let Option(_) = x {
14
+ 16 | if let Option(_) = x {
14
15
| ^^^^^^
15
16
|
16
17
= note: did you mean to use one of the following variants?
17
18
- `std::prelude::v1::Option::None`
18
19
- `std::prelude::v1::Option::Some`
19
20
20
- error: aborting due to previous error
21
+ error[E0532]: expected tuple struct/variant, found enum `Example`
22
+ --> $DIR/issue-43871-enum-instead-of-variant.rs:22:12
23
+ |
24
+ 22 | if let Example(_) = y {
25
+ | ^^^^^^^
26
+ |
27
+ = note: did you mean to use one of the following variants?
28
+ - `Example::Ex`
29
+ - `Example::NotEx`
30
+
31
+ error: aborting due to 3 previous errors
21
32
You can’t perform that action at this time.
0 commit comments