@@ -18,8 +18,6 @@ use middle::trans::debuginfo;
1818use middle:: trans:: cleanup;
1919use middle:: trans:: cleanup:: CleanupMethods ;
2020use middle:: trans:: expr;
21- use middle:: ty;
22- use util:: ppaux;
2321use util:: ppaux:: Repr ;
2422
2523use middle:: trans:: type_:: Type ;
@@ -327,67 +325,23 @@ pub fn trans_ret<'a>(bcx: &'a Block<'a>,
327325 return bcx;
328326}
329327
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-
359328pub fn trans_fail < ' a > (
360329 bcx : & ' a Block < ' a > ,
361- sp_opt : Option < Span > ,
330+ sp : Span ,
362331 fail_str : InternedString )
363332 -> & ' a Block < ' a > {
364- let _icx = push_ctxt( "trans_fail" ) ;
365333 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 > {
374334 let _icx = push_ctxt ( "trans_fail_value" ) ;
375335 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 ;
387341 let V_str = PointerCast ( bcx, V_fail_str , Type :: i8p ( ) ) ;
388342 let V_filename = PointerCast ( bcx, V_filename , Type :: i8p ( ) ) ;
389343 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 ) ;
391345 let bcx = callee:: trans_lang_call ( bcx, did, args, Some ( expr:: Ignore ) ) . bcx ;
392346 Unreachable ( bcx) ;
393347 return bcx;
0 commit comments