@@ -15,8 +15,10 @@ use rustc_index::{Idx, IndexVec};
1515use rustc_middle:: arena:: ArenaAllocatable ;
1616use rustc_middle:: mir:: ConstraintCategory ;
1717use rustc_middle:: ty:: fold:: TypeFoldable ;
18+ use rustc_middle:: ty:: traverse:: AlwaysTraversable ;
1819use rustc_middle:: ty:: { self , BoundVar , GenericArg , GenericArgKind , Ty , TyCtxt } ;
1920use rustc_middle:: { bug, span_bug} ;
21+ use rustc_type_ir:: traverse:: OptTryFoldWith ;
2022use tracing:: { debug, instrument} ;
2123
2224use crate :: infer:: canonical:: instantiate:: { CanonicalExt , instantiate_value} ;
@@ -60,7 +62,7 @@ impl<'tcx> InferCtxt<'tcx> {
6062 fulfill_cx : & mut dyn TraitEngine < ' tcx , ScrubbedTraitError < ' tcx > > ,
6163 ) -> Result < CanonicalQueryResponse < ' tcx , T > , NoSolution >
6264 where
63- T : Debug + TypeFoldable < TyCtxt < ' tcx > > ,
65+ T : OptTryFoldWith < TyCtxt < ' tcx > > ,
6466 Canonical < ' tcx , QueryResponse < ' tcx , T > > : ArenaAllocatable < ' tcx > ,
6567 {
6668 let query_response = self . make_query_response ( inference_vars, answer, fulfill_cx) ?;
@@ -107,7 +109,7 @@ impl<'tcx> InferCtxt<'tcx> {
107109 fulfill_cx : & mut dyn TraitEngine < ' tcx , ScrubbedTraitError < ' tcx > > ,
108110 ) -> Result < QueryResponse < ' tcx , T > , NoSolution >
109111 where
110- T : Debug + TypeFoldable < TyCtxt < ' tcx > > ,
112+ T : OptTryFoldWith < TyCtxt < ' tcx > > ,
111113 {
112114 let tcx = self . tcx ;
113115
@@ -243,7 +245,7 @@ impl<'tcx> InferCtxt<'tcx> {
243245 output_query_region_constraints : & mut QueryRegionConstraints < ' tcx > ,
244246 ) -> InferResult < ' tcx , R >
245247 where
246- R : Debug + TypeFoldable < TyCtxt < ' tcx > > ,
248+ R : OptTryFoldWith < TyCtxt < ' tcx > > ,
247249 {
248250 let InferOk { value : result_args, mut obligations } = self
249251 . query_response_instantiation_guess (
@@ -326,8 +328,11 @@ impl<'tcx> InferCtxt<'tcx> {
326328 . map ( |p_c| instantiate_value ( self . tcx , & result_args, p_c. clone ( ) ) ) ,
327329 ) ;
328330
329- let user_result: R =
330- query_response. instantiate_projected ( self . tcx , & result_args, |q_r| q_r. value . clone ( ) ) ;
331+ let user_result: R = query_response
332+ . instantiate_projected ( self . tcx , & result_args, |q_r| {
333+ AlwaysTraversable ( q_r. value . clone ( ) )
334+ } )
335+ . 0 ;
331336
332337 Ok ( InferOk { value : user_result, obligations } )
333338 }
@@ -396,7 +401,7 @@ impl<'tcx> InferCtxt<'tcx> {
396401 query_response : & Canonical < ' tcx , QueryResponse < ' tcx , R > > ,
397402 ) -> InferResult < ' tcx , CanonicalVarValues < ' tcx > >
398403 where
399- R : Debug + TypeFoldable < TyCtxt < ' tcx > > ,
404+ R : OptTryFoldWith < TyCtxt < ' tcx > > ,
400405 {
401406 // For each new universe created in the query result that did
402407 // not appear in the original query, create a local
0 commit comments