@@ -2273,15 +2273,17 @@ impl<'a> Resolver<'a> {
2273
2273
show_candidates ( & mut err, & candidates, def. is_some ( ) ) ;
2274
2274
} else if is_expected ( Def :: Enum ( DefId :: local ( CRATE_DEF_INDEX ) ) ) {
2275
2275
let enum_candidates = this. lookup_import_candidates ( name, ns, is_enum_variant) ;
2276
- for suggestion in enum_candidates {
2277
- let ( variant_path, enum_path) = import_candidate_to_paths ( & suggestion) ;
2276
+ let mut enum_candidates = enum_candidates. iter ( )
2277
+ . map ( |suggestion| import_candidate_to_paths ( & suggestion) ) . collect :: < Vec < _ > > ( ) ;
2278
+ enum_candidates. sort ( ) ;
2279
+ for ( sp, variant_path, enum_path) in enum_candidates {
2278
2280
let msg = format ! ( "there is an enum variant `{}`, did you mean to use `{}`?" ,
2279
2281
variant_path,
2280
2282
enum_path) ;
2281
- if suggestion . path . span == DUMMY_SP {
2283
+ if sp == DUMMY_SP {
2282
2284
err. help ( & msg) ;
2283
2285
} else {
2284
- err. span_help ( suggestion . path . span , & msg) ;
2286
+ err. span_help ( sp , & msg) ;
2285
2287
}
2286
2288
}
2287
2289
}
@@ -3437,7 +3439,7 @@ fn path_names_to_string(path: &Path) -> String {
3437
3439
}
3438
3440
3439
3441
/// Get the path for an enum and the variant from an `ImportSuggestion` for an enum variant.
3440
- fn import_candidate_to_paths ( suggestion : & ImportSuggestion ) -> ( String , String ) {
3442
+ fn import_candidate_to_paths ( suggestion : & ImportSuggestion ) -> ( Span , String , String ) {
3441
3443
let variant_path = & suggestion. path ;
3442
3444
let variant_path_string = path_names_to_string ( variant_path) ;
3443
3445
@@ -3448,7 +3450,7 @@ fn import_candidate_to_paths(suggestion: &ImportSuggestion) -> (String, String)
3448
3450
} ;
3449
3451
let enum_path_string = path_names_to_string ( & enum_path) ;
3450
3452
3451
- ( variant_path_string, enum_path_string)
3453
+ ( suggestion . path . span , variant_path_string, enum_path_string)
3452
3454
}
3453
3455
3454
3456
0 commit comments