@@ -117,7 +117,7 @@ impl<'a> Resolver<'a> {
117
117
}
118
118
119
119
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
121
121
self . use_injections . drain ( ..)
122
122
{
123
123
let ( span, found_use) = if let Some ( def_id) = def_id. as_local ( ) {
@@ -135,6 +135,7 @@ impl<'a> Resolver<'a> {
135
135
if instead { Instead :: Yes } else { Instead :: No } ,
136
136
found_use,
137
137
IsPattern :: No ,
138
+ path,
138
139
) ;
139
140
} else if let Some ( ( span, msg, sugg, appl) ) = suggestion {
140
141
err. span_suggestion ( span, msg, sugg, appl) ;
@@ -702,6 +703,7 @@ impl<'a> Resolver<'a> {
702
703
Instead :: No ,
703
704
FoundUse :: Yes ,
704
705
IsPattern :: Yes ,
706
+ vec ! [ ] ,
705
707
) ;
706
708
}
707
709
err
@@ -1482,6 +1484,7 @@ impl<'a> Resolver<'a> {
1482
1484
Instead :: No ,
1483
1485
FoundUse :: Yes ,
1484
1486
IsPattern :: No ,
1487
+ vec ! [ ] ,
1485
1488
) ;
1486
1489
1487
1490
if macro_kind == MacroKind :: Derive && ( ident. name == sym:: Send || ident. name == sym:: Sync ) {
@@ -2448,6 +2451,7 @@ fn show_candidates(
2448
2451
instead : Instead ,
2449
2452
found_use : FoundUse ,
2450
2453
is_pattern : IsPattern ,
2454
+ path : Vec < Segment > ,
2451
2455
) {
2452
2456
if candidates. is_empty ( ) {
2453
2457
return ;
@@ -2480,14 +2484,15 @@ fn show_candidates(
2480
2484
( "one of these" , "items" , String :: new ( ) )
2481
2485
} ;
2482
2486
2487
+ let tail = if path. len ( ) > 1 { "..." } else { "" } ;
2483
2488
let instead = if let Instead :: Yes = instead { " instead" } else { "" } ;
2484
2489
let mut msg = if let IsPattern :: Yes = is_pattern {
2485
2490
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
2488
2493
)
2489
2494
} else {
2490
- format ! ( "consider importing {} {}{}" , determiner, kind, instead)
2495
+ format ! ( "consider importing {} {}{}{} " , determiner, kind, instead, tail )
2491
2496
} ;
2492
2497
2493
2498
for note in accessible_path_strings. iter ( ) . flat_map ( |cand| cand. 3 . as_ref ( ) ) {
@@ -2515,6 +2520,14 @@ fn show_candidates(
2515
2520
accessible_path_strings. into_iter ( ) . map ( |a| a. 0 ) ,
2516
2521
Applicability :: MaybeIncorrect ,
2517
2522
) ;
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
+ }
2518
2531
} else {
2519
2532
msg. push ( ':' ) ;
2520
2533
0 commit comments