@@ -263,15 +263,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
263263 } ) => {
264264 let tcx = self . tcx ;
265265
266- let actual = self . resolve_vars_if_possible ( rcvr_ty) ;
267- let ty_str = self . ty_to_string ( actual ) ;
266+ let rcvr_ty = self . resolve_vars_if_possible ( rcvr_ty) ;
267+ let ty_str = self . ty_to_string ( rcvr_ty ) ;
268268 let is_method = mode == Mode :: MethodCall ;
269269 let item_kind = if is_method {
270270 "method"
271- } else if actual . is_enum ( ) {
271+ } else if rcvr_ty . is_enum ( ) {
272272 "variant or associated item"
273273 } else {
274- match ( item_name. as_str ( ) . chars ( ) . next ( ) , actual . is_fresh_ty ( ) ) {
274+ match ( item_name. as_str ( ) . chars ( ) . next ( ) , rcvr_ty . is_fresh_ty ( ) ) {
275275 ( Some ( name) , false ) if name. is_lowercase ( ) => "function or associated item" ,
276276 ( Some ( _) , false ) => "associated item" ,
277277 ( Some ( _) , true ) | ( None , false ) => "variant or associated item" ,
@@ -280,19 +280,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
280280 } ;
281281
282282 if self . suggest_wrapping_range_with_parens (
283- tcx, actual , source, span, item_name, & ty_str,
283+ tcx, rcvr_ty , source, span, item_name, & ty_str,
284284 ) || self . suggest_constraining_numerical_ty (
285- tcx, actual , source, span, item_kind, item_name, & ty_str,
285+ tcx, rcvr_ty , source, span, item_kind, item_name, & ty_str,
286286 ) {
287287 return None ;
288288 }
289289 span = item_name. span ;
290290
291291 // Don't show generic arguments when the method can't be found in any implementation (#81576).
292292 let mut ty_str_reported = ty_str. clone ( ) ;
293- if let ty:: Adt ( _, generics) = actual . kind ( ) {
293+ if let ty:: Adt ( _, generics) = rcvr_ty . kind ( ) {
294294 if generics. len ( ) > 0 {
295- let mut autoderef = self . autoderef ( span, actual ) ;
295+ let mut autoderef = self . autoderef ( span, rcvr_ty ) ;
296296 let candidate_found = autoderef. any ( |( ty, _) | {
297297 if let ty:: Adt ( adt_def, _) = ty. kind ( ) {
298298 self . tcx
@@ -321,16 +321,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
321321 "no {} named `{}` found for {} `{}` in the current scope" ,
322322 item_kind,
323323 item_name,
324- actual . prefix_string( self . tcx) ,
324+ rcvr_ty . prefix_string( self . tcx) ,
325325 ty_str_reported,
326326 ) ;
327- if actual . references_error ( ) {
327+ if rcvr_ty . references_error ( ) {
328328 err. downgrade_to_delayed_bug ( ) ;
329329 }
330330
331331 if let Mode :: MethodCall = mode && let SelfSource :: MethodCall ( cal) = source {
332332 self . suggest_await_before_method (
333- & mut err, item_name, actual , cal, span,
333+ & mut err, item_name, rcvr_ty , cal, span,
334334 ) ;
335335 }
336336 if let Some ( span) = tcx. resolutions ( ( ) ) . confused_type_with_std_module . get ( & span) {
@@ -341,7 +341,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
341341 Applicability :: MachineApplicable ,
342342 ) ;
343343 }
344- if let ty:: RawPtr ( _) = & actual . kind ( ) {
344+ if let ty:: RawPtr ( _) = & rcvr_ty . kind ( ) {
345345 err. note (
346346 "try using `<*const T>::as_ref()` to get a reference to the \
347347 type behind the pointer: https://doc.rust-lang.org/std/\
@@ -353,7 +353,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
353353 ) ;
354354 }
355355
356- let ty_span = match actual . kind ( ) {
356+ let ty_span = match rcvr_ty . kind ( ) {
357357 ty:: Param ( param_type) => Some (
358358 param_type. span_from_generics ( self . tcx , self . body_id . owner . to_def_id ( ) ) ,
359359 ) ,
@@ -365,7 +365,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
365365 span,
366366 format ! (
367367 "{item_kind} `{item_name}` not found for this {}" ,
368- actual . prefix_string( self . tcx)
368+ rcvr_ty . prefix_string( self . tcx)
369369 ) ,
370370 ) ;
371371 }
@@ -406,7 +406,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
406406 // original type that has the associated function for accurate suggestions.
407407 // (#61411)
408408 let ty = tcx. at ( span) . type_of ( * impl_did) ;
409- match ( & ty. peel_refs ( ) . kind ( ) , & actual . peel_refs ( ) . kind ( ) ) {
409+ match ( & ty. peel_refs ( ) . kind ( ) , & rcvr_ty . peel_refs ( ) . kind ( ) ) {
410410 ( ty:: Adt ( def, _) , ty:: Adt ( def_actual, substs) ) if def == def_actual => {
411411 // If there are any inferred arguments, (`{integer}`), we should replace
412412 // them with underscores to allow the compiler to infer them
@@ -451,7 +451,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
451451 _ => self . ty_to_value_string ( ty. peel_refs ( ) ) ,
452452 }
453453 } else {
454- self . ty_to_value_string ( actual . peel_refs ( ) )
454+ self . ty_to_value_string ( rcvr_ty . peel_refs ( ) )
455455 } ;
456456 if let SelfSource :: MethodCall ( _) = source {
457457 let first_arg = if let Some ( CandidateSource :: Impl ( impl_did) ) = static_candidates. get ( 0 ) &&
@@ -523,7 +523,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
523523 let mut bound_spans = vec ! [ ] ;
524524 let mut restrict_type_params = false ;
525525 let mut unsatisfied_bounds = false ;
526- if item_name. name == sym:: count && self . is_slice_ty ( actual , span) {
526+ if item_name. name == sym:: count && self . is_slice_ty ( rcvr_ty , span) {
527527 let msg = "consider using `len` instead" ;
528528 if let SelfSource :: MethodCall ( _expr) = source {
529529 err. span_suggestion_short (
@@ -537,7 +537,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
537537 }
538538 if let Some ( iterator_trait) = self . tcx . get_diagnostic_item ( sym:: Iterator ) {
539539 let iterator_trait = self . tcx . def_path_str ( iterator_trait) ;
540- err. note ( & format ! ( "`count` is defined on `{iterator_trait}`, which `{actual }` does not implement" ) ) ;
540+ err. note ( & format ! ( "`count` is defined on `{iterator_trait}`, which `{rcvr_ty }` does not implement" ) ) ;
541541 }
542542 } else if !unsatisfied_predicates. is_empty ( ) {
543543 let mut type_params = FxHashMap :: default ( ) ;
@@ -876,7 +876,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
876876 . map ( |( _, path) | path)
877877 . collect :: < Vec < _ > > ( )
878878 . join ( "\n " ) ;
879- let actual_prefix = actual . prefix_string ( self . tcx ) ;
879+ let actual_prefix = rcvr_ty . prefix_string ( self . tcx ) ;
880880 info ! ( "unimplemented_traits.len() == {}" , unimplemented_traits. len( ) ) ;
881881 let ( primary_message, label) =
882882 if unimplemented_traits. len ( ) == 1 && unimplemented_traits_only {
@@ -885,7 +885,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
885885 . next ( )
886886 . map ( |( _, ( trait_ref, obligation) ) | {
887887 if trait_ref. self_ty ( ) . references_error ( )
888- || actual . references_error ( )
888+ || rcvr_ty . references_error ( )
889889 {
890890 // Avoid crashing.
891891 return ( None , None ) ;
@@ -921,7 +921,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
921921 let label_span_not_found = |err : & mut Diagnostic | {
922922 if unsatisfied_predicates. is_empty ( ) {
923923 err. span_label ( span, format ! ( "{item_kind} not found in `{ty_str}`" ) ) ;
924- let is_string_or_ref_str = match actual . kind ( ) {
924+ let is_string_or_ref_str = match rcvr_ty . kind ( ) {
925925 ty:: Ref ( _, ty, _) => {
926926 ty. is_str ( )
927927 || matches ! (
@@ -957,7 +957,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
957957 // different from the received one
958958 // So we avoid suggestion method with Box<Self>
959959 // for instance
960- self . tcx . at ( span) . type_of ( * def_id) != actual
960+ self . tcx . at ( span) . type_of ( * def_id) != rcvr_ty
961961 && self . tcx . at ( span) . type_of ( * def_id) != rcvr_ty
962962 }
963963 ( Mode :: Path , false , _) => true ,
@@ -1017,18 +1017,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10171017 // Don't suggest (for example) `expr.field.clone()` if `expr.clone()`
10181018 // can't be called due to `typeof(expr): Clone` not holding.
10191019 if unsatisfied_predicates. is_empty ( ) {
1020- self . suggest_calling_method_on_field ( & mut err, source, span, actual, item_name) ;
1020+ self . suggest_calling_method_on_field (
1021+ & mut err, source, span, rcvr_ty, item_name,
1022+ ) ;
10211023 }
10221024
1023- self . check_for_inner_self ( & mut err, source, span, actual , item_name) ;
1025+ self . check_for_inner_self ( & mut err, source, span, rcvr_ty , item_name) ;
10241026
10251027 bound_spans. sort ( ) ;
10261028 bound_spans. dedup ( ) ;
10271029 for ( span, msg) in bound_spans. into_iter ( ) {
10281030 err. span_label ( span, & msg) ;
10291031 }
10301032
1031- if actual . is_numeric ( ) && actual . is_fresh ( ) || restrict_type_params {
1033+ if rcvr_ty . is_numeric ( ) && rcvr_ty . is_fresh ( ) || restrict_type_params {
10321034 } else {
10331035 self . suggest_traits_to_import (
10341036 & mut err,
@@ -1046,8 +1048,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10461048
10471049 // Don't emit a suggestion if we found an actual method
10481050 // that had unsatisfied trait bounds
1049- if unsatisfied_predicates. is_empty ( ) && actual . is_enum ( ) {
1050- let adt_def = actual . ty_adt_def ( ) . expect ( "enum is not an ADT" ) ;
1051+ if unsatisfied_predicates. is_empty ( ) && rcvr_ty . is_enum ( ) {
1052+ let adt_def = rcvr_ty . ty_adt_def ( ) . expect ( "enum is not an ADT" ) ;
10511053 if let Some ( suggestion) = lev_distance:: find_best_match_for_name (
10521054 & adt_def. variants ( ) . iter ( ) . map ( |s| s. name ) . collect :: < Vec < _ > > ( ) ,
10531055 item_name. name ,
@@ -1062,7 +1064,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10621064 }
10631065 }
10641066
1065- if item_name. name == sym:: as_str && actual . peel_refs ( ) . is_str ( ) {
1067+ if item_name. name == sym:: as_str && rcvr_ty . peel_refs ( ) . is_str ( ) {
10661068 let msg = "remove this method call" ;
10671069 let mut fallback_span = true ;
10681070 if let SelfSource :: MethodCall ( expr) = source {
0 commit comments