@@ -7,7 +7,7 @@ use rustc_type_ir::data_structures::HashMap;
7
7
use rustc_type_ir:: fold:: { TypeFoldable , TypeFolder , TypeSuperFoldable } ;
8
8
use rustc_type_ir:: inherent:: * ;
9
9
use rustc_type_ir:: lang_items:: TraitSolverLangItem ;
10
- use rustc_type_ir:: { self as ty, Interner , Upcast as _} ;
10
+ use rustc_type_ir:: { self as ty, elaborate , Interner , Upcast as _} ;
11
11
use rustc_type_ir_macros:: { TypeFoldable_Generic , TypeVisitable_Generic } ;
12
12
use tracing:: instrument;
13
13
@@ -671,11 +671,19 @@ where
671
671
{
672
672
let cx = ecx. cx ( ) ;
673
673
let mut requirements = vec ! [ ] ;
674
- requirements. extend (
674
+ // Elaborating all supertrait outlives obligations here is not soundness critical,
675
+ // since if we just used the unelaborated set, then the transitive supertraits would
676
+ // be reachable when proving the former. However, since we elaborate all supertrait
677
+ // outlives obligations when confirming impls, we would end up with a different set
678
+ // of outlives obligations here if we didn't do the same, leading to ambiguity.
679
+ // FIXME(-Znext-solver=coinductive): Adding supertraits here can be removed once we
680
+ // make impls coinductive always, since they'll always need to prove their supertraits.
681
+ requirements. extend ( elaborate:: elaborate (
682
+ cx,
675
683
cx. explicit_super_predicates_of ( trait_ref. def_id )
676
684
. iter_instantiated ( cx, trait_ref. args )
677
685
. map ( |( pred, _) | pred) ,
678
- ) ;
686
+ ) ) ;
679
687
680
688
// FIXME(associated_const_equality): Also add associated consts to
681
689
// the requirements here.
0 commit comments