@@ -83,6 +83,8 @@ struct ProbeContext<'a, 'tcx> {
83
83
unsatisfied_predicates : Vec < ( ty:: Predicate < ' tcx > , Option < ty:: Predicate < ' tcx > > ) > ,
84
84
85
85
is_suggestion : IsSuggestion ,
86
+
87
+ scope_expr_id : hir:: HirId ,
86
88
}
87
89
88
90
impl < ' a , ' tcx > Deref for ProbeContext < ' a , ' tcx > {
@@ -285,7 +287,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
285
287
self_ty,
286
288
scope_expr_id,
287
289
ProbeScope :: AllTraits ,
288
- |probe_cx| probe_cx. pick ( ) ,
290
+ |probe_cx| probe_cx. pick ( scope_expr_id ) ,
289
291
)
290
292
. ok ( )
291
293
. map ( |pick| pick. item )
@@ -317,7 +319,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
317
319
self_ty,
318
320
scope_expr_id,
319
321
scope,
320
- |probe_cx| probe_cx. pick ( ) ,
322
+ |probe_cx| probe_cx. pick ( scope_expr_id ) ,
321
323
)
322
324
}
323
325
@@ -448,6 +450,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
448
450
orig_values,
449
451
steps. steps ,
450
452
is_suggestion,
453
+ scope_expr_id,
451
454
) ;
452
455
453
456
probe_cx. assemble_inherent_candidates ( ) ;
@@ -547,6 +550,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
547
550
orig_steps_var_values : OriginalQueryValues < ' tcx > ,
548
551
steps : Lrc < Vec < CandidateStep < ' tcx > > > ,
549
552
is_suggestion : IsSuggestion ,
553
+ scope_expr_id : hir:: HirId ,
550
554
) -> ProbeContext < ' a , ' tcx > {
551
555
ProbeContext {
552
556
fcx,
@@ -564,6 +568,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
564
568
private_candidate : None ,
565
569
unsatisfied_predicates : Vec :: new ( ) ,
566
570
is_suggestion,
571
+ scope_expr_id,
567
572
}
568
573
}
569
574
@@ -1031,7 +1036,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1031
1036
///////////////////////////////////////////////////////////////////////////
1032
1037
// THE ACTUAL SEARCH
1033
1038
1034
- fn pick ( mut self ) -> PickResult < ' tcx > {
1039
+ fn pick ( mut self , scope_expr_id : hir :: HirId ) -> PickResult < ' tcx > {
1035
1040
assert ! ( self . method_name. is_some( ) ) ;
1036
1041
1037
1042
if let Some ( r) = self . pick_core ( ) {
@@ -1077,7 +1082,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1077
1082
if let Some ( ( kind, def_id) ) = private_candidate {
1078
1083
return Err ( MethodError :: PrivateMatch ( kind, def_id, out_of_scope_traits) ) ;
1079
1084
}
1080
- let lev_candidate = self . probe_for_lev_candidate ( ) ?;
1085
+ let lev_candidate = self . probe_for_lev_candidate ( scope_expr_id ) ?;
1081
1086
1082
1087
Err ( MethodError :: NoMatch ( NoMatchData :: new (
1083
1088
static_candidates,
@@ -1312,7 +1317,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1312
1317
) {
1313
1318
self . tcx . struct_span_lint_hir (
1314
1319
lint:: builtin:: UNSTABLE_NAME_COLLISIONS ,
1315
- self . fcx . body_id ,
1320
+ self . scope_expr_id ,
1316
1321
self . span ,
1317
1322
|lint| {
1318
1323
let def_kind = stable_pick. item . kind . as_def_kind ( ) ;
@@ -1580,7 +1585,10 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1580
1585
/// Similarly to `probe_for_return_type`, this method attempts to find the best matching
1581
1586
/// candidate method where the method name may have been misspelt. Similarly to other
1582
1587
/// Levenshtein based suggestions, we provide at most one such suggestion.
1583
- fn probe_for_lev_candidate ( & mut self ) -> Result < Option < ty:: AssocItem > , MethodError < ' tcx > > {
1588
+ fn probe_for_lev_candidate (
1589
+ & mut self ,
1590
+ scope_expr_id : hir:: HirId ,
1591
+ ) -> Result < Option < ty:: AssocItem > , MethodError < ' tcx > > {
1584
1592
debug ! ( "probing for method names similar to {:?}" , self . method_name) ;
1585
1593
1586
1594
let steps = self . steps . clone ( ) ;
@@ -1594,6 +1602,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1594
1602
self . orig_steps_var_values . clone ( ) ,
1595
1603
steps,
1596
1604
IsSuggestion ( true ) ,
1605
+ scope_expr_id,
1597
1606
) ;
1598
1607
pcx. allow_similar_names = true ;
1599
1608
pcx. assemble_inherent_candidates ( ) ;
0 commit comments