@@ -117,7 +117,7 @@ impl<'a> Resolver<'a> {
117117 }
118118
119119 fn report_with_use_injections ( & mut self , krate : & Crate ) {
120- for UseError { mut err, candidates, def_id, instead, suggestion } in
120+ for UseError { mut err, candidates, def_id, instead, suggestion, path } in
121121 self . use_injections . drain ( ..)
122122 {
123123 let ( span, found_use) = if let Some ( def_id) = def_id. as_local ( ) {
@@ -135,6 +135,7 @@ impl<'a> Resolver<'a> {
135135 if instead { Instead :: Yes } else { Instead :: No } ,
136136 found_use,
137137 IsPattern :: No ,
138+ path,
138139 ) ;
139140 } else if let Some ( ( span, msg, sugg, appl) ) = suggestion {
140141 err. span_suggestion ( span, msg, sugg, appl) ;
@@ -702,6 +703,7 @@ impl<'a> Resolver<'a> {
702703 Instead :: No ,
703704 FoundUse :: Yes ,
704705 IsPattern :: Yes ,
706+ vec ! [ ] ,
705707 ) ;
706708 }
707709 err
@@ -1482,6 +1484,7 @@ impl<'a> Resolver<'a> {
14821484 Instead :: No ,
14831485 FoundUse :: Yes ,
14841486 IsPattern :: No ,
1487+ vec ! [ ] ,
14851488 ) ;
14861489
14871490 if macro_kind == MacroKind :: Derive && ( ident. name == sym:: Send || ident. name == sym:: Sync ) {
@@ -2448,6 +2451,7 @@ fn show_candidates(
24482451 instead : Instead ,
24492452 found_use : FoundUse ,
24502453 is_pattern : IsPattern ,
2454+ path : Vec < Segment > ,
24512455) {
24522456 if candidates. is_empty ( ) {
24532457 return ;
@@ -2480,14 +2484,15 @@ fn show_candidates(
24802484 ( "one of these" , "items" , String :: new ( ) )
24812485 } ;
24822486
2487+ let tail = if path. len ( ) > 1 { "..." } else { "" } ;
24832488 let instead = if let Instead :: Yes = instead { " instead" } else { "" } ;
24842489 let mut msg = if let IsPattern :: Yes = is_pattern {
24852490 format ! (
2486- "if you meant to match on {}{}{}, use the full path in the pattern" ,
2487- kind, instead, name
2491+ "if you meant to match on {}{}{}, use the full path in the pattern{} " ,
2492+ kind, instead, name, tail
24882493 )
24892494 } else {
2490- format ! ( "consider importing {} {}{}" , determiner, kind, instead)
2495+ format ! ( "consider importing {} {}{}{} " , determiner, kind, instead, tail )
24912496 } ;
24922497
24932498 for note in accessible_path_strings. iter ( ) . flat_map ( |cand| cand. 3 . as_ref ( ) ) {
@@ -2515,6 +2520,14 @@ fn show_candidates(
25152520 accessible_path_strings. into_iter ( ) . map ( |a| a. 0 ) ,
25162521 Applicability :: MaybeIncorrect ,
25172522 ) ;
2523+ if let [ first, .., last] = & path[ ..] {
2524+ err. span_suggestion_verbose (
2525+ first. ident . span . until ( last. ident . span ) ,
2526+ "...and refer to it directly" ,
2527+ String :: new ( ) ,
2528+ Applicability :: Unspecified ,
2529+ ) ;
2530+ }
25182531 } else {
25192532 msg. push ( ':' ) ;
25202533
0 commit comments