@@ -58,12 +58,11 @@ impl<'cx, 'tcx> AtExt<'tcx> for At<'cx, 'tcx> {
58
58
cause : self . cause ,
59
59
param_env : self . param_env ,
60
60
obligations : vec ! [ ] ,
61
- error : false ,
62
61
cache : SsoHashMap :: new ( ) ,
63
62
anon_depth : 0 ,
64
63
} ;
65
64
66
- let result = value. fold_with ( & mut normalizer) . into_ok ( ) ;
65
+ let result = value. fold_with ( & mut normalizer) ;
67
66
debug ! (
68
67
"normalize::<{}>: result={:?} with {} obligations" ,
69
68
std:: any:: type_name:: <T >( ) ,
@@ -75,11 +74,7 @@ impl<'cx, 'tcx> AtExt<'tcx> for At<'cx, 'tcx> {
75
74
std:: any:: type_name:: <T >( ) ,
76
75
normalizer. obligations,
77
76
) ;
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 } )
83
78
}
84
79
}
85
80
@@ -89,11 +84,12 @@ struct QueryNormalizer<'cx, 'tcx> {
89
84
param_env : ty:: ParamEnv < ' tcx > ,
90
85
obligations : Vec < PredicateObligation < ' tcx > > ,
91
86
cache : SsoHashMap < Ty < ' tcx > , Ty < ' tcx > > ,
92
- error : bool ,
93
87
anon_depth : usize ,
94
88
}
95
89
96
90
impl < ' cx , ' tcx > TypeFolder < ' tcx > for QueryNormalizer < ' cx , ' tcx > {
91
+ type Error = NoSolution ;
92
+
97
93
fn tcx < ' c > ( & ' c self ) -> TyCtxt < ' tcx > {
98
94
self . infcx . tcx
99
95
}
@@ -170,39 +166,22 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
170
166
. canonicalize_hr_query_hack ( self . param_env . and ( data) , & mut orig_values) ;
171
167
debug ! ( "QueryNormalizer: c_data = {:#?}" , c_data) ;
172
168
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 ) ;
205
173
}
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
206
185
}
207
186
208
187
_ => ty,
0 commit comments