@@ -19,7 +19,7 @@ use rustc::ty::{self, TyCtxt};
1919pub fn codegen_fulfill_obligation < ' tcx > (
2020 ty : TyCtxt < ' tcx > ,
2121 ( param_env, trait_ref) : ( ty:: ParamEnv < ' tcx > , ty:: PolyTraitRef < ' tcx > ) ,
22- ) -> Vtable < ' tcx , ( ) > {
22+ ) -> Option < Vtable < ' tcx , ( ) > > {
2323 // Remove any references to regions; this helps improve caching.
2424 let trait_ref = ty. erase_regions ( & trait_ref) ;
2525
@@ -47,11 +47,15 @@ pub fn codegen_fulfill_obligation<'tcx>(
4747 // leading to an ambiguous result. So report this as an
4848 // overflow bug, since I believe this is the only case
4949 // where ambiguity can result.
50- bug ! (
51- "Encountered ambiguity selecting `{:?}` during codegen, \
52- presuming due to overflow",
53- trait_ref
54- )
50+ infcx. tcx . sess . delay_span_bug (
51+ rustc_span:: DUMMY_SP ,
52+ & format ! (
53+ "encountered ambiguity selecting `{:?}` during codegen, presuming due to \
54+ overflow or prior type error",
55+ trait_ref
56+ ) ,
57+ ) ;
58+ return None ;
5559 }
5660 Err ( e) => {
5761 bug ! ( "Encountered error `{:?}` selecting `{:?}` during codegen" , e, trait_ref)
@@ -71,7 +75,7 @@ pub fn codegen_fulfill_obligation<'tcx>(
7175 let vtable = infcx. drain_fulfillment_cx_or_panic ( & mut fulfill_cx, & vtable) ;
7276
7377 info ! ( "Cache miss: {:?} => {:?}" , trait_ref, vtable) ;
74- vtable
78+ Some ( vtable)
7579 } )
7680}
7781
0 commit comments