@@ -90,12 +90,9 @@ use build::{BlockAnd, BlockAndExtension, Builder, CFG, ScopeAuxiliary};
90
90
use rustc:: middle:: region:: { CodeExtent , CodeExtentData } ;
91
91
use rustc:: middle:: lang_items;
92
92
use rustc:: ty:: subst:: { Substs , Subst , VecPerParamSpace } ;
93
- use rustc:: ty:: { self , Ty , TyCtxt } ;
93
+ use rustc:: ty:: { Ty , TyCtxt } ;
94
94
use rustc:: mir:: repr:: * ;
95
95
use syntax:: codemap:: { Span , DUMMY_SP } ;
96
- use syntax:: parse:: token:: intern_and_get_ident;
97
- use rustc:: middle:: const_val:: ConstVal ;
98
- use rustc_const_math:: ConstInt ;
99
96
100
97
pub struct Scope < ' tcx > {
101
98
/// the scope-id within the scope_datas
@@ -536,50 +533,6 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
536
533
next_target. unit ( )
537
534
}
538
535
539
- /// Create diverge cleanup and branch to it from `block`.
540
- // FIXME: Remove this (used only for unreachable cases in match).
541
- pub fn panic ( & mut self , block : BasicBlock , msg : & ' static str , span : Span ) {
542
- // fn(&(msg: &'static str filename: &'static str, line: u32)) -> !
543
- let region = ty:: ReStatic ; // FIXME(mir-borrowck): use a better region?
544
- let func = self . lang_function ( lang_items:: PanicFnLangItem ) ;
545
- let args = self . hir . tcx ( ) . replace_late_bound_regions ( & func. ty . fn_args ( ) , |_| region) . 0 ;
546
-
547
- let ref_ty = args[ 0 ] ;
548
- let tup_ty = if let ty:: TyRef ( _, tyandmut) = ref_ty. sty {
549
- tyandmut. ty
550
- } else {
551
- span_bug ! ( span, "unexpected panic type: {:?}" , func. ty) ;
552
- } ;
553
-
554
- let ( tuple, tuple_ref) = ( self . temp ( tup_ty) , self . temp ( ref_ty) ) ;
555
- let ( file, line) = self . span_to_fileline_args ( span) ;
556
- let message = Constant {
557
- span : span,
558
- ty : self . hir . tcx ( ) . mk_static_str ( ) ,
559
- literal : self . hir . str_literal ( intern_and_get_ident ( msg) )
560
- } ;
561
- let elems = vec ! [ Operand :: Constant ( message) ,
562
- Operand :: Constant ( file) ,
563
- Operand :: Constant ( line) ] ;
564
- let scope_id = self . innermost_scope_id ( ) ;
565
- // FIXME: We should have this as a constant, rather than a stack variable (to not pollute
566
- // icache with cold branch code), however to achieve that we either have to rely on rvalue
567
- // promotion or have some way, in MIR, to create constants.
568
- self . cfg . push_assign ( block, scope_id, span, & tuple, // [1]
569
- Rvalue :: Aggregate ( AggregateKind :: Tuple , elems) ) ;
570
- // [1] tuple = (message_arg, file_arg, line_arg);
571
- // FIXME: is this region really correct here?
572
- self . cfg . push_assign ( block, scope_id, span, & tuple_ref, // tuple_ref = &tuple;
573
- Rvalue :: Ref ( region, BorrowKind :: Shared , tuple) ) ;
574
- let cleanup = self . diverge_cleanup ( ) ;
575
- self . cfg . terminate ( block, scope_id, span, TerminatorKind :: Call {
576
- func : Operand :: Constant ( func) ,
577
- args : vec ! [ Operand :: Consume ( tuple_ref) ] ,
578
- cleanup : cleanup,
579
- destination : None ,
580
- } ) ;
581
- }
582
-
583
536
/// Create an Assert terminator and return the success block.
584
537
/// If the boolean condition operand is not the expected value,
585
538
/// a runtime panic will be caused with the given message.
@@ -605,39 +558,6 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
605
558
606
559
success_block
607
560
}
608
-
609
- fn lang_function ( & mut self , lang_item : lang_items:: LangItem ) -> Constant < ' tcx > {
610
- let funcdid = match self . hir . tcx ( ) . lang_items . require ( lang_item) {
611
- Ok ( d) => d,
612
- Err ( m) => {
613
- self . hir . tcx ( ) . sess . fatal ( & m)
614
- }
615
- } ;
616
- Constant {
617
- span : DUMMY_SP ,
618
- ty : self . hir . tcx ( ) . lookup_item_type ( funcdid) . ty ,
619
- literal : Literal :: Item {
620
- def_id : funcdid,
621
- substs : self . hir . tcx ( ) . mk_substs ( Substs :: empty ( ) )
622
- }
623
- }
624
- }
625
-
626
- fn span_to_fileline_args ( & mut self , span : Span ) -> ( Constant < ' tcx > , Constant < ' tcx > ) {
627
- let span_lines = self . hir . tcx ( ) . sess . codemap ( ) . lookup_char_pos ( span. lo ) ;
628
- ( Constant {
629
- span : span,
630
- ty : self . hir . tcx ( ) . mk_static_str ( ) ,
631
- literal : self . hir . str_literal ( intern_and_get_ident ( & span_lines. file . name ) )
632
- } , Constant {
633
- span : span,
634
- ty : self . hir . tcx ( ) . types . u32 ,
635
- literal : Literal :: Value {
636
- value : ConstVal :: Integral ( ConstInt :: U32 ( span_lines. line as u32 ) ) ,
637
- } ,
638
- } )
639
- }
640
-
641
561
}
642
562
643
563
/// Builds drops for pop_scope and exit_scope.
0 commit comments