@@ -18,8 +18,6 @@ use middle::trans::debuginfo;
18
18
use middle:: trans:: cleanup;
19
19
use middle:: trans:: cleanup:: CleanupMethods ;
20
20
use middle:: trans:: expr;
21
- use middle:: ty;
22
- use util:: ppaux;
23
21
use util:: ppaux:: Repr ;
24
22
25
23
use middle:: trans:: type_:: Type ;
@@ -327,67 +325,23 @@ pub fn trans_ret<'a>(bcx: &'a Block<'a>,
327
325
return bcx;
328
326
}
329
327
330
- pub fn trans_fail_expr < ' a > (
331
- bcx : & ' a Block < ' a > ,
332
- sp_opt : Option < Span > ,
333
- fail_expr : Option < @ast:: Expr > )
334
- -> & ' a Block < ' a > {
335
- let _icx = push_ctxt ( "trans_fail_expr" ) ;
336
- let mut bcx = bcx;
337
- match fail_expr {
338
- Some ( arg_expr) => {
339
- let ccx = bcx. ccx ( ) ;
340
- let tcx = ccx. tcx ;
341
- let arg_datum =
342
- unpack_datum ! ( bcx, expr:: trans_to_lvalue( bcx, arg_expr, "fail" ) ) ;
343
-
344
- if ty:: type_is_str ( arg_datum. ty ) {
345
- let ( lldata, _) = arg_datum. get_vec_base_and_len ( bcx) ;
346
- return trans_fail_value ( bcx, sp_opt, lldata) ;
347
- } else if bcx. unreachable . get ( ) || ty:: type_is_bot ( arg_datum. ty ) {
348
- return bcx;
349
- } else {
350
- bcx. sess ( ) . span_bug (
351
- arg_expr. span , ~"fail called with unsupported type " +
352
- ppaux::ty_to_str(tcx, arg_datum.ty));
353
- }
354
- }
355
- _ => trans_fail(bcx, sp_opt, InternedString::new(" explicit failure") )
356
- }
357
- }
358
-
359
328
pub fn trans_fail < ' a > (
360
329
bcx : & ' a Block < ' a > ,
361
- sp_opt : Option < Span > ,
330
+ sp : Span ,
362
331
fail_str : InternedString )
363
332
-> & ' a Block < ' a > {
364
- let _icx = push_ctxt( "trans_fail" ) ;
365
333
let V_fail_str = C_cstr ( bcx. ccx ( ) , fail_str) ;
366
- return trans_fail_value( bcx, sp_opt, V_fail_str ) ;
367
- }
368
-
369
- fn trans_fail_value < ' a > (
370
- bcx: & ' a Block < ' a > ,
371
- sp_opt: Option < Span > ,
372
- V_fail_str : ValueRef )
373
- -> & ' a Block < ' a > {
374
334
let _icx = push_ctxt ( "trans_fail_value" ) ;
375
335
let ccx = bcx. ccx ( ) ;
376
- let ( V_filename , V_line ) = match sp_opt {
377
- Some ( sp) => {
378
- let sess = bcx. sess ( ) ;
379
- let loc = sess. parse_sess . cm . lookup_char_pos ( sp. lo ) ;
380
- ( C_cstr ( bcx. ccx ( ) , token:: intern_and_get_ident ( loc. file . name ) ) ,
381
- loc. line as int )
382
- }
383
- None => {
384
- ( C_cstr ( bcx. ccx ( ) , InternedString :: new ( "<runtime>" ) ) , 0 )
385
- }
386
- } ;
336
+ let sess = bcx. sess ( ) ;
337
+ let loc = sess. parse_sess . cm . lookup_char_pos ( sp. lo ) ;
338
+ let V_filename = C_cstr ( bcx. ccx ( ) ,
339
+ token:: intern_and_get_ident ( loc. file . name ) ) ;
340
+ let V_line = loc. line as int ;
387
341
let V_str = PointerCast ( bcx, V_fail_str , Type :: i8p ( ) ) ;
388
342
let V_filename = PointerCast ( bcx, V_filename , Type :: i8p ( ) ) ;
389
343
let args = ~[ V_str , V_filename , C_int ( ccx, V_line ) ] ;
390
- let did = langcall ( bcx, sp_opt , "" , FailFnLangItem ) ;
344
+ let did = langcall ( bcx, Some ( sp ) , "" , FailFnLangItem ) ;
391
345
let bcx = callee:: trans_lang_call ( bcx, did, args, Some ( expr:: Ignore ) ) . bcx ;
392
346
Unreachable ( bcx) ;
393
347
return bcx;
0 commit comments