@@ -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 _;
@@ -504,12 +504,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
504
504
// incompatible fix at the original mismatch site.
505
505
if matches ! ( source, TypeMismatchSource :: Ty ( _) )
506
506
&& let Some ( ideal_method) = ideal_method
507
+ && let ideal_arg_ty = self . resolve_vars_if_possible ( ideal_method. sig . inputs ( ) [ idx + 1 ] )
508
+ // HACK(compiler-errors): We don't actually consider the implications
509
+ // of our inference guesses in `emit_type_mismatch_suggestions`, so
510
+ // only suggest things when we know our type error is precisely due to
511
+ // a type mismatch, and not via some projection or something. See #116155.
512
+ && !ideal_arg_ty. has_non_region_infer ( )
507
513
{
508
514
self . emit_type_mismatch_suggestions (
509
515
err,
510
516
arg_expr,
511
517
arg_ty,
512
- self . resolve_vars_if_possible ( ideal_method . sig . inputs ( ) [ idx + 1 ] ) ,
518
+ ideal_arg_ty ,
513
519
None ,
514
520
None ,
515
521
) ;
0 commit comments