@@ -19,7 +19,7 @@ use rustc::ty::{self, TyCtxt};
19
19
pub fn codegen_fulfill_obligation < ' tcx > (
20
20
ty : TyCtxt < ' tcx > ,
21
21
( param_env, trait_ref) : ( ty:: ParamEnv < ' tcx > , ty:: PolyTraitRef < ' tcx > ) ,
22
- ) -> Vtable < ' tcx , ( ) > {
22
+ ) -> Option < Vtable < ' tcx , ( ) > > {
23
23
// Remove any references to regions; this helps improve caching.
24
24
let trait_ref = ty. erase_regions ( & trait_ref) ;
25
25
@@ -47,11 +47,15 @@ pub fn codegen_fulfill_obligation<'tcx>(
47
47
// leading to an ambiguous result. So report this as an
48
48
// overflow bug, since I believe this is the only case
49
49
// 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 ;
55
59
}
56
60
Err ( e) => {
57
61
bug ! ( "Encountered error `{:?}` selecting `{:?}` during codegen" , e, trait_ref)
@@ -71,7 +75,7 @@ pub fn codegen_fulfill_obligation<'tcx>(
71
75
let vtable = infcx. drain_fulfillment_cx_or_panic ( & mut fulfill_cx, & vtable) ;
72
76
73
77
info ! ( "Cache miss: {:?} => {:?}" , trait_ref, vtable) ;
74
- vtable
78
+ Some ( vtable)
75
79
} )
76
80
}
77
81
0 commit comments