@@ -92,23 +92,25 @@ where
9292 let impl_trait_ref = impl_trait_ref. instantiate ( cx, impl_args) ;
9393
9494 ecx. eq ( goal. param_env , goal. predicate . trait_ref , impl_trait_ref) ?;
95+ // Resolve inference variables here to improve the debug output :)
96+ let impl_trait_ref = ecx. resolve_vars_if_possible ( impl_trait_ref) ;
97+
9598 let where_clause_bounds = cx
9699 . predicates_of ( impl_def_id)
97100 . iter_instantiated ( cx, impl_args)
98101 . map ( |pred| goal. with ( cx, pred) ) ;
99102 ecx. add_goals ( GoalSource :: ImplWhereBound , where_clause_bounds) ;
100103
101- // We currently elaborate all supertrait outlives obligations from impls.
102- // This can be removed when we actually do coinduction correctly, and prove
103- // all supertrait obligations unconditionally.
104- let goal_clause: I :: Clause = goal. predicate . upcast ( cx) ;
105- for clause in elaborate:: elaborate ( cx, [ goal_clause] ) {
106- if matches ! (
107- clause. kind( ) . skip_binder( ) ,
108- ty:: ClauseKind :: TypeOutlives ( ..) | ty:: ClauseKind :: RegionOutlives ( ..)
109- ) {
110- ecx. add_goal ( GoalSource :: Misc , goal. with ( cx, clause) ) ;
111- }
104+ // When using an impl, we have to check that its super trait bounds are actually satisfied.
105+ // This is necessary as otherwise the impl `impl<T: Magic> Magic for T` would allow us to
106+ // incorrectly assume all super traits of `Magic`.
107+ for clause in elaborate:: elaborate (
108+ cx,
109+ cx. explicit_super_predicates_of ( impl_trait_ref. def_id )
110+ . iter_instantiated ( cx, impl_trait_ref. args )
111+ . map ( |( pred, _) | pred) ,
112+ ) {
113+ ecx. add_goal ( GoalSource :: Misc , goal. with ( cx, clause) ) ;
112114 }
113115
114116 ecx. evaluate_added_goals_and_make_canonical_response ( maximal_certainty)
0 commit comments