@@ -14,7 +14,7 @@ use rustc_middle::ty::adjustment::AllowTwoPhase;
14
14
use rustc_middle:: ty:: error:: { ExpectedFound , TypeError } ;
15
15
use rustc_middle:: ty:: fold:: BottomUpFolder ;
16
16
use rustc_middle:: ty:: print:: with_no_trimmed_paths;
17
- use rustc_middle:: ty:: { self , Article , AssocItem , Ty , TypeAndMut , TypeFoldable } ;
17
+ use rustc_middle:: ty:: { self , Article , AssocItem , Ty , TypeAndMut , TypeFoldable , TypeVisitableExt } ;
18
18
use rustc_span:: symbol:: sym;
19
19
use rustc_span:: { BytePos , Span , DUMMY_SP } ;
20
20
use rustc_trait_selection:: infer:: InferCtxtExt as _;
@@ -503,12 +503,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
503
503
// incompatible fix at the original mismatch site.
504
504
if matches ! ( source, TypeMismatchSource :: Ty ( _) )
505
505
&& let Some ( ideal_method) = ideal_method
506
+ && let ideal_arg_ty = self . resolve_vars_if_possible ( ideal_method. sig . inputs ( ) [ idx + 1 ] )
507
+ // HACK(compiler-errors): We don't actually consider the implications
508
+ // of our inference guesses in `emit_type_mismatch_suggestions`, so
509
+ // only suggest things when we know our type error is precisely due to
510
+ // a type mismatch, and not via some projection or something. See #116155.
511
+ && !ideal_arg_ty. has_non_region_infer ( )
506
512
{
507
513
self . emit_type_mismatch_suggestions (
508
514
err,
509
515
arg_expr,
510
516
arg_ty,
511
- self . resolve_vars_if_possible ( ideal_method . sig . inputs ( ) [ idx + 1 ] ) ,
517
+ ideal_arg_ty ,
512
518
None ,
513
519
None ,
514
520
) ;
0 commit comments