File tree 1 file changed +12
-4
lines changed
compiler/rustc_trait_selection/src/traits/error_reporting
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -419,17 +419,25 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
419
419
let ( main_trait_predicate, o) = if let ty:: PredicateKind :: Clause (
420
420
ty:: ClauseKind :: Trait ( root_pred)
421
421
) = root_obligation. predicate . kind ( ) . skip_binder ( )
422
+ && !trait_predicate. self_ty ( ) . skip_binder ( ) . has_escaping_bound_vars ( )
423
+ && !root_pred. self_ty ( ) . has_escaping_bound_vars ( )
422
424
// The type of the leaf predicate is (roughly) the same as the type
423
425
// from the root predicate, as a proxy for "we care about the root"
424
426
// FIXME: this doesn't account for trivial derefs, but works as a first
425
427
// approximation.
426
428
&& (
427
429
// `T: Trait` && `&&T: OtherTrait`, we want `OtherTrait`
428
- trait_predicate. self_ty ( ) . skip_binder ( )
429
- == root_pred. self_ty ( ) . peel_refs ( )
430
+ self . can_eq (
431
+ obligation. param_env ,
432
+ trait_predicate. self_ty ( ) . skip_binder ( ) ,
433
+ root_pred. self_ty ( ) . peel_refs ( ) ,
434
+ )
430
435
// `&str: Iterator` && `&str: IntoIterator`, we want `IntoIterator`
431
- || trait_predicate. self_ty ( ) . skip_binder ( )
432
- == root_pred. self_ty ( )
436
+ || self . can_eq (
437
+ obligation. param_env ,
438
+ trait_predicate. self_ty ( ) . skip_binder ( ) ,
439
+ root_pred. self_ty ( ) ,
440
+ )
433
441
)
434
442
// The leaf trait and the root trait are different, so as to avoid
435
443
// talking about `&mut T: Trait` and instead remain talking about
You can’t perform that action at this time.
0 commit comments