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> {
25992599 }
26002600 _ => { }
26012601 } ,
2602- ( Def :: Enum ( ..) , PathSource :: TupleStruct ) => {
2602+ ( Def :: Enum ( ..) , PathSource :: TupleStruct )
2603+ | ( Def :: Enum ( ..) , PathSource :: Expr ( ..) ) => {
26032604 if let Some ( variants) = this. collect_enum_variants ( def) {
26042605 err. note ( & format ! ( "did you mean to use one \
26052606 of the following variants?\n {}",
26062607 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) )
26092610 . collect:: <Vec <_>>( )
26102611 . join( "\n " ) ) ) ;
26112612
@@ -3559,6 +3560,8 @@ impl<'a> Resolver<'a> {
35593560 }
35603561
35613562 self . find_module ( enum_def) . map ( |( enum_module, enum_import_suggestion) | {
3563+ self . populate_module_if_necessary ( enum_module) ;
3564+
35623565 let mut variants = Vec :: new ( ) ;
35633566 enum_module. for_each_child_stable ( |ident, _, name_binding| {
35643567 if let Def :: Variant ( ..) = name_binding. def ( ) {
Original file line number Diff line number Diff line change 88// option. This file may not be copied, modified, or distributed
99// except according to those terms.
1010
11+ enum Example { Ex ( String ) , NotEx }
12+
1113fn result_test ( ) {
1214 let x = Option ( 1 ) ;
1315
1416 if let Option ( _) = x {
1517 println ! ( "It is OK." ) ;
1618 }
19+
20+ let y = Example :: Ex ( String :: from ( "test" ) ) ;
21+
22+ if let Example ( _) = y {
23+ println ! ( "It is OK." ) ;
24+ }
1725}
1826
1927fn main ( ) { }
Original file line number Diff line number Diff line change 11error[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+ | ^^^^^^
36 |
4- 12 | let x = Option(1);
5- | ^^^^^^ not a function
67 = note: did you mean to use one of the following variants?
78 - `std::prelude::v1::Option::None`
89 - `std::prelude::v1::Option::Some`
910
1011error[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
1213 |
13- 14 | if let Option(_) = x {
14+ 16 | if let Option(_) = x {
1415 | ^^^^^^
1516 |
1617 = note: did you mean to use one of the following variants?
1718 - `std::prelude::v1::Option::None`
1819 - `std::prelude::v1::Option::Some`
1920
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
2132
You can’t perform that action at this time.
0 commit comments