@@ -58,12 +58,11 @@ impl<'cx, 'tcx> AtExt<'tcx> for At<'cx, 'tcx> {
5858 cause : self . cause ,
5959 param_env : self . param_env ,
6060 obligations : vec ! [ ] ,
61- error : false ,
6261 cache : SsoHashMap :: new ( ) ,
6362 anon_depth : 0 ,
6463 } ;
6564
66- let result = value. fold_with ( & mut normalizer) . into_ok ( ) ;
65+ let result = value. fold_with ( & mut normalizer) ;
6766 debug ! (
6867 "normalize::<{}>: result={:?} with {} obligations" ,
6968 std:: any:: type_name:: <T >( ) ,
@@ -75,11 +74,7 @@ impl<'cx, 'tcx> AtExt<'tcx> for At<'cx, 'tcx> {
7574 std:: any:: type_name:: <T >( ) ,
7675 normalizer. obligations,
7776 ) ;
78- if normalizer. error {
79- Err ( NoSolution )
80- } else {
81- Ok ( Normalized { value : result, obligations : normalizer. obligations } )
82- }
77+ result. map ( |value| Normalized { value, obligations : normalizer. obligations } )
8378 }
8479}
8580
@@ -89,11 +84,12 @@ struct QueryNormalizer<'cx, 'tcx> {
8984 param_env : ty:: ParamEnv < ' tcx > ,
9085 obligations : Vec < PredicateObligation < ' tcx > > ,
9186 cache : SsoHashMap < Ty < ' tcx > , Ty < ' tcx > > ,
92- error : bool ,
9387 anon_depth : usize ,
9488}
9589
9690impl < ' cx , ' tcx > TypeFolder < ' tcx > for QueryNormalizer < ' cx , ' tcx > {
91+ type Error = NoSolution ;
92+
9793 fn tcx < ' c > ( & ' c self ) -> TyCtxt < ' tcx > {
9894 self . infcx . tcx
9995 }
@@ -170,39 +166,22 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
170166 . canonicalize_hr_query_hack ( self . param_env . and ( data) , & mut orig_values) ;
171167 debug ! ( "QueryNormalizer: c_data = {:#?}" , c_data) ;
172168 debug ! ( "QueryNormalizer: orig_values = {:#?}" , orig_values) ;
173- match tcx. normalize_projection_ty ( c_data) {
174- Ok ( result) => {
175- // We don't expect ambiguity.
176- if result. is_ambiguous ( ) {
177- self . error = true ;
178- ty
179- } else {
180- match self . infcx . instantiate_query_response_and_region_obligations (
181- self . cause ,
182- self . param_env ,
183- & orig_values,
184- result,
185- ) {
186- Ok ( InferOk { value : result, obligations } ) => {
187- debug ! ( "QueryNormalizer: result = {:#?}" , result) ;
188- debug ! ( "QueryNormalizer: obligations = {:#?}" , obligations) ;
189- self . obligations . extend ( obligations) ;
190- result. normalized_ty
191- }
192-
193- Err ( _) => {
194- self . error = true ;
195- ty
196- }
197- }
198- }
199- }
200-
201- Err ( NoSolution ) => {
202- self . error = true ;
203- ty
204- }
169+ let result = tcx. normalize_projection_ty ( c_data) ?;
170+ // We don't expect ambiguity.
171+ if result. is_ambiguous ( ) {
172+ return Err ( NoSolution ) ;
205173 }
174+ let InferOk { value : result, obligations } =
175+ self . infcx . instantiate_query_response_and_region_obligations (
176+ self . cause ,
177+ self . param_env ,
178+ & orig_values,
179+ result,
180+ ) ?;
181+ debug ! ( "QueryNormalizer: result = {:#?}" , result) ;
182+ debug ! ( "QueryNormalizer: obligations = {:#?}" , obligations) ;
183+ self . obligations . extend ( obligations) ;
184+ result. normalized_ty
206185 }
207186
208187 _ => ty,
0 commit comments