@@ -17,12 +17,12 @@ use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitor};
17
17
18
18
use std:: ops:: ControlFlow ;
19
19
20
- use super :: NoSolution ;
20
+ use super :: NoSolutionOrAmbiguous ;
21
21
22
22
pub use rustc_middle:: traits:: query:: NormalizationResult ;
23
23
24
24
pub trait AtExt < ' tcx > {
25
- fn normalize < T > ( & self , value : T ) -> Result < Normalized < ' tcx , T > , NoSolution >
25
+ fn normalize < T > ( & self , value : T ) -> Result < Normalized < ' tcx , T > , NoSolutionOrAmbiguous >
26
26
where
27
27
T : TypeFoldable < ' tcx > ;
28
28
}
@@ -41,7 +41,7 @@ impl<'cx, 'tcx> AtExt<'tcx> for At<'cx, 'tcx> {
41
41
/// normalizing, but for now should be used only when we actually
42
42
/// know that normalization will succeed, since error reporting
43
43
/// and other details are still "under development".
44
- fn normalize < T > ( & self , value : T ) -> Result < Normalized < ' tcx , T > , NoSolution >
44
+ fn normalize < T > ( & self , value : T ) -> Result < Normalized < ' tcx , T > , NoSolutionOrAmbiguous >
45
45
where
46
46
T : TypeFoldable < ' tcx > ,
47
47
{
@@ -96,7 +96,7 @@ impl<'cx, 'tcx> AtExt<'tcx> for At<'cx, 'tcx> {
96
96
std:: any:: type_name:: <T >( ) ,
97
97
normalizer. obligations,
98
98
) ;
99
- result . map ( |value| Normalized { value, obligations : normalizer. obligations } )
99
+ Ok ( Normalized { value : result? , obligations : normalizer. obligations } )
100
100
}
101
101
}
102
102
@@ -163,7 +163,7 @@ struct QueryNormalizer<'cx, 'tcx> {
163
163
}
164
164
165
165
impl < ' cx , ' tcx > FallibleTypeFolder < ' tcx > for QueryNormalizer < ' cx , ' tcx > {
166
- type Error = NoSolution ;
166
+ type Error = NoSolutionOrAmbiguous ;
167
167
168
168
fn tcx < ' c > ( & ' c self ) -> TyCtxt < ' tcx > {
169
169
self . infcx . tcx
@@ -253,7 +253,7 @@ impl<'cx, 'tcx> FallibleTypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
253
253
let result = tcx. normalize_projection_ty ( c_data) ?;
254
254
// We don't expect ambiguity.
255
255
if result. is_ambiguous ( ) {
256
- bug ! ( "unexpected ambiguity: {:?} {:?}" , c_data , result ) ;
256
+ return Err ( NoSolutionOrAmbiguous :: Ambiguous ) ;
257
257
}
258
258
let InferOk { value : result, obligations } =
259
259
self . infcx . instantiate_query_response_and_region_obligations (
@@ -296,7 +296,7 @@ impl<'cx, 'tcx> FallibleTypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
296
296
let result = tcx. normalize_projection_ty ( c_data) ?;
297
297
// We don't expect ambiguity.
298
298
if result. is_ambiguous ( ) {
299
- bug ! ( "unexpected ambiguity: {:?} {:?}" , c_data , result ) ;
299
+ return Err ( NoSolutionOrAmbiguous :: Ambiguous ) ;
300
300
}
301
301
let InferOk { value : result, obligations } =
302
302
self . infcx . instantiate_query_response_and_region_obligations (
0 commit comments