@@ -2273,15 +2273,17 @@ impl<'a> Resolver<'a> {
22732273 show_candidates ( & mut err, & candidates, def. is_some ( ) ) ;
22742274 } else if is_expected ( Def :: Enum ( DefId :: local ( CRATE_DEF_INDEX ) ) ) {
22752275 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 {
22782280 let msg = format ! ( "there is an enum variant `{}`, did you mean to use `{}`?" ,
22792281 variant_path,
22802282 enum_path) ;
2281- if suggestion . path . span == DUMMY_SP {
2283+ if sp == DUMMY_SP {
22822284 err. help ( & msg) ;
22832285 } else {
2284- err. span_help ( suggestion . path . span , & msg) ;
2286+ err. span_help ( sp , & msg) ;
22852287 }
22862288 }
22872289 }
@@ -3437,7 +3439,7 @@ fn path_names_to_string(path: &Path) -> String {
34373439}
34383440
34393441/// 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 ) {
34413443 let variant_path = & suggestion. path ;
34423444 let variant_path_string = path_names_to_string ( variant_path) ;
34433445
@@ -3448,7 +3450,7 @@ fn import_candidate_to_paths(suggestion: &ImportSuggestion) -> (String, String)
34483450 } ;
34493451 let enum_path_string = path_names_to_string ( & enum_path) ;
34503452
3451- ( variant_path_string, enum_path_string)
3453+ ( suggestion . path . span , variant_path_string, enum_path_string)
34523454}
34533455
34543456
0 commit comments