@@ -17,12 +17,12 @@ use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitor};
1717
1818use std:: ops:: ControlFlow ;
1919
20- use super :: NoSolution ;
20+ use super :: NoSolutionOrAmbiguous ;
2121
2222pub use rustc_middle:: traits:: query:: NormalizationResult ;
2323
2424pub 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 >
2626 where
2727 T : TypeFoldable < ' tcx > ;
2828}
@@ -41,7 +41,7 @@ impl<'cx, 'tcx> AtExt<'tcx> for At<'cx, 'tcx> {
4141 /// normalizing, but for now should be used only when we actually
4242 /// know that normalization will succeed, since error reporting
4343 /// 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 >
4545 where
4646 T : TypeFoldable < ' tcx > ,
4747 {
@@ -96,7 +96,7 @@ impl<'cx, 'tcx> AtExt<'tcx> for At<'cx, 'tcx> {
9696 std:: any:: type_name:: <T >( ) ,
9797 normalizer. obligations,
9898 ) ;
99- result . map ( |value| Normalized { value, obligations : normalizer. obligations } )
99+ Ok ( Normalized { value : result? , obligations : normalizer. obligations } )
100100 }
101101}
102102
@@ -163,7 +163,7 @@ struct QueryNormalizer<'cx, 'tcx> {
163163}
164164
165165impl < ' cx , ' tcx > FallibleTypeFolder < ' tcx > for QueryNormalizer < ' cx , ' tcx > {
166- type Error = NoSolution ;
166+ type Error = NoSolutionOrAmbiguous ;
167167
168168 fn tcx < ' c > ( & ' c self ) -> TyCtxt < ' tcx > {
169169 self . infcx . tcx
@@ -253,7 +253,7 @@ impl<'cx, 'tcx> FallibleTypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
253253 let result = tcx. normalize_projection_ty ( c_data) ?;
254254 // We don't expect ambiguity.
255255 if result. is_ambiguous ( ) {
256- bug ! ( "unexpected ambiguity: {:?} {:?}" , c_data , result ) ;
256+ return Err ( NoSolutionOrAmbiguous :: Ambiguous ) ;
257257 }
258258 let InferOk { value : result, obligations } =
259259 self . infcx . instantiate_query_response_and_region_obligations (
@@ -296,7 +296,7 @@ impl<'cx, 'tcx> FallibleTypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
296296 let result = tcx. normalize_projection_ty ( c_data) ?;
297297 // We don't expect ambiguity.
298298 if result. is_ambiguous ( ) {
299- bug ! ( "unexpected ambiguity: {:?} {:?}" , c_data , result ) ;
299+ return Err ( NoSolutionOrAmbiguous :: Ambiguous ) ;
300300 }
301301 let InferOk { value : result, obligations } =
302302 self . infcx . instantiate_query_response_and_region_obligations (
0 commit comments