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 @@ -426,17 +426,25 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
426
426
let ( main_trait_predicate, o) = if let ty:: PredicateKind :: Clause (
427
427
ty:: ClauseKind :: Trait ( root_pred)
428
428
) = root_obligation. predicate . kind ( ) . skip_binder ( )
429
+ && !trait_predicate. self_ty ( ) . skip_binder ( ) . has_escaping_bound_vars ( )
430
+ && !root_pred. self_ty ( ) . has_escaping_bound_vars ( )
429
431
// The type of the leaf predicate is (roughly) the same as the type
430
432
// from the root predicate, as a proxy for "we care about the root"
431
433
// FIXME: this doesn't account for trivial derefs, but works as a first
432
434
// approximation.
433
435
&& (
434
436
// `T: Trait` && `&&T: OtherTrait`, we want `OtherTrait`
435
- trait_predicate. self_ty ( ) . skip_binder ( )
436
- == root_pred. self_ty ( ) . peel_refs ( )
437
+ self . can_eq (
438
+ obligation. param_env ,
439
+ trait_predicate. self_ty ( ) . skip_binder ( ) ,
440
+ root_pred. self_ty ( ) . peel_refs ( ) ,
441
+ )
437
442
// `&str: Iterator` && `&str: IntoIterator`, we want `IntoIterator`
438
- || trait_predicate. self_ty ( ) . skip_binder ( )
439
- == root_pred. self_ty ( )
443
+ || self . can_eq (
444
+ obligation. param_env ,
445
+ trait_predicate. self_ty ( ) . skip_binder ( ) ,
446
+ root_pred. self_ty ( ) ,
447
+ )
440
448
)
441
449
// The leaf trait and the root trait are different, so as to avoid
442
450
// talking about `&mut T: Trait` and instead remain talking about
You can’t perform that action at this time.
0 commit comments