@@ -83,6 +83,8 @@ struct ProbeContext<'a, 'tcx> {
8383 unsatisfied_predicates : Vec < ( ty:: Predicate < ' tcx > , Option < ty:: Predicate < ' tcx > > ) > ,
8484
8585 is_suggestion : IsSuggestion ,
86+
87+ scope_expr_id : hir:: HirId ,
8688}
8789
8890impl < ' a , ' tcx > Deref for ProbeContext < ' a , ' tcx > {
@@ -285,7 +287,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
285287 self_ty,
286288 scope_expr_id,
287289 ProbeScope :: AllTraits ,
288- |probe_cx| probe_cx. pick ( ) ,
290+ |probe_cx| probe_cx. pick ( scope_expr_id ) ,
289291 )
290292 . ok ( )
291293 . map ( |pick| pick. item )
@@ -317,7 +319,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
317319 self_ty,
318320 scope_expr_id,
319321 scope,
320- |probe_cx| probe_cx. pick ( ) ,
322+ |probe_cx| probe_cx. pick ( scope_expr_id ) ,
321323 )
322324 }
323325
@@ -448,6 +450,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
448450 orig_values,
449451 steps. steps ,
450452 is_suggestion,
453+ scope_expr_id,
451454 ) ;
452455
453456 probe_cx. assemble_inherent_candidates ( ) ;
@@ -547,6 +550,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
547550 orig_steps_var_values : OriginalQueryValues < ' tcx > ,
548551 steps : Lrc < Vec < CandidateStep < ' tcx > > > ,
549552 is_suggestion : IsSuggestion ,
553+ scope_expr_id : hir:: HirId ,
550554 ) -> ProbeContext < ' a , ' tcx > {
551555 ProbeContext {
552556 fcx,
@@ -564,6 +568,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
564568 private_candidate : None ,
565569 unsatisfied_predicates : Vec :: new ( ) ,
566570 is_suggestion,
571+ scope_expr_id,
567572 }
568573 }
569574
@@ -1031,7 +1036,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
10311036 ///////////////////////////////////////////////////////////////////////////
10321037 // THE ACTUAL SEARCH
10331038
1034- fn pick ( mut self ) -> PickResult < ' tcx > {
1039+ fn pick ( mut self , scope_expr_id : hir :: HirId ) -> PickResult < ' tcx > {
10351040 assert ! ( self . method_name. is_some( ) ) ;
10361041
10371042 if let Some ( r) = self . pick_core ( ) {
@@ -1077,7 +1082,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
10771082 if let Some ( ( kind, def_id) ) = private_candidate {
10781083 return Err ( MethodError :: PrivateMatch ( kind, def_id, out_of_scope_traits) ) ;
10791084 }
1080- let lev_candidate = self . probe_for_lev_candidate ( ) ?;
1085+ let lev_candidate = self . probe_for_lev_candidate ( scope_expr_id ) ?;
10811086
10821087 Err ( MethodError :: NoMatch ( NoMatchData :: new (
10831088 static_candidates,
@@ -1312,7 +1317,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
13121317 ) {
13131318 self . tcx . struct_span_lint_hir (
13141319 lint:: builtin:: UNSTABLE_NAME_COLLISIONS ,
1315- self . fcx . body_id ,
1320+ self . scope_expr_id ,
13161321 self . span ,
13171322 |lint| {
13181323 let def_kind = stable_pick. item . kind . as_def_kind ( ) ;
@@ -1580,7 +1585,10 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
15801585 /// Similarly to `probe_for_return_type`, this method attempts to find the best matching
15811586 /// candidate method where the method name may have been misspelt. Similarly to other
15821587 /// 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 > > {
15841592 debug ! ( "probing for method names similar to {:?}" , self . method_name) ;
15851593
15861594 let steps = self . steps . clone ( ) ;
@@ -1594,6 +1602,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
15941602 self . orig_steps_var_values . clone ( ) ,
15951603 steps,
15961604 IsSuggestion ( true ) ,
1605+ scope_expr_id,
15971606 ) ;
15981607 pcx. allow_similar_names = true ;
15991608 pcx. assemble_inherent_candidates ( ) ;
0 commit comments