@@ -301,7 +301,7 @@ pub fn decl_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
301
301
self_type. repr( ccx. tcx( ) ) ) ;
302
302
( & function_type. sig , RustCall , Some ( llenvironment_type) )
303
303
}
304
- _ => panic ! ( "expected closure or fn" )
304
+ _ => ccx . sess ( ) . bug ( "expected closure or fn" )
305
305
} ;
306
306
307
307
let sig = ty:: erase_late_bound_regions ( ccx. tcx ( ) , sig) ;
@@ -2410,12 +2410,15 @@ fn register_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
2410
2410
node_id : ast:: NodeId ,
2411
2411
node_type : Ty < ' tcx > )
2412
2412
-> ValueRef {
2413
- match node_type. sty {
2414
- ty:: ty_bare_fn( _, ref f) => {
2415
- assert ! ( f. abi == Rust || f. abi == RustCall ) ;
2413
+ if let ty:: ty_bare_fn( _, ref f) = node_type. sty {
2414
+ if f. abi != Rust && f. abi != RustCall {
2415
+ ccx. sess ( ) . span_bug ( sp, & format ! ( "only `Rust` or `rust-call` calling conventions \
2416
+ are valid for this function, but it uses `{:?}`",
2417
+ f. abi. name) ) ;
2416
2418
}
2417
- _ => panic ! ( "expected bare rust fn" )
2418
- } ;
2419
+ } else {
2420
+ ccx. sess ( ) . span_bug ( sp, "expected bare rust function" )
2421
+ }
2419
2422
2420
2423
let llfn = decl_rust_fn ( ccx, node_type, & sym[ ..] ) ;
2421
2424
finish_register_fn ( ccx, sp, sym, node_id, llfn) ;
@@ -2802,7 +2805,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
2802
2805
llfn
2803
2806
}
2804
2807
2805
- _ => panic ! ( "get_item_val: weird result in table" )
2808
+ _ => ccx . sess ( ) . bug ( "get_item_val: weird result in table" )
2806
2809
} ;
2807
2810
2808
2811
match attr:: first_attr_value_str_by_name ( & i. attrs ,
@@ -2866,7 +2869,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
2866
2869
let args = match v. node . kind {
2867
2870
ast:: TupleVariantKind ( ref args) => args,
2868
2871
ast:: StructVariantKind ( _) => {
2869
- panic ! ( "struct variant kind unexpected in get_item_val" )
2872
+ ccx . sess ( ) . bug ( "struct variant kind unexpected in get_item_val" )
2870
2873
}
2871
2874
} ;
2872
2875
assert ! ( args. len( ) != 0 ) ;
@@ -2882,7 +2885,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
2882
2885
ast:: ItemEnum ( _, _) => {
2883
2886
register_fn ( ccx, ( * v) . span , sym, id, ty)
2884
2887
}
2885
- _ => panic ! ( "NodeVariant, shouldn't happen" )
2888
+ _ => ccx . sess ( ) . bug ( "NodeVariant, shouldn't happen" )
2886
2889
} ;
2887
2890
set_inline_hint ( llfn) ;
2888
2891
llfn
0 commit comments