@@ -47,7 +47,7 @@ use syntax::parse::token;
4747
4848use rustc:: lint;
4949use rustc:: session:: Session ;
50- use syntax:: codemap:: Span ;
50+ use syntax:: codemap:: { Span , DUMMY_SP } ;
5151
5252use std:: cmp:: Ordering ;
5353
@@ -173,10 +173,9 @@ pub fn check_intrinsics(ccx: &CrateContext) {
173173pub fn trans_intrinsic_call < ' a , ' blk , ' tcx > ( mut bcx : Block < ' blk , ' tcx > ,
174174 callee_ty : Ty < ' tcx > ,
175175 fn_ty : & FnType ,
176- cleanup_scope : cleanup:: CustomScopeIndex ,
177176 args : callee:: CallArgs < ' a , ' tcx > ,
178177 dest : expr:: Dest ,
179- call_info : NodeIdAndSpan )
178+ call_debug_location : DebugLoc )
180179 -> Result < ' blk , ' tcx > {
181180 let fcx = bcx. fcx ;
182181 let ccx = fcx. ccx ;
@@ -195,7 +194,12 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
195194 let ret_ty = sig. output ;
196195 let name = tcx. item_name ( def_id) . as_str ( ) ;
197196
198- let call_debug_location = DebugLoc :: At ( call_info. id , call_info. span ) ;
197+ let span = match call_debug_location {
198+ DebugLoc :: At ( _, span) => span,
199+ DebugLoc :: None => fcx. span . unwrap_or ( DUMMY_SP )
200+ } ;
201+
202+ let cleanup_scope = fcx. push_custom_cleanup_scope ( ) ;
199203
200204 // For `transmute` we can just trans the input expr directly into dest
201205 if name == "transmute" {
@@ -644,7 +648,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
644648 } ,
645649 None => {
646650 span_invalid_monomorphization_error (
647- tcx. sess , call_info . span ,
651+ tcx. sess , span,
648652 & format ! ( "invalid monomorphization of `{}` intrinsic: \
649653 expected basic integer type, found `{}`", name, sty) ) ;
650654 C_null ( llret_ty)
@@ -656,7 +660,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
656660
657661 ( _, "return_address" ) => {
658662 if !fcx. fn_ty . ret . is_indirect ( ) {
659- span_err ! ( tcx. sess, call_info . span, E0510 ,
663+ span_err ! ( tcx. sess, span, E0510 ,
660664 "invalid use of `return_address` intrinsic: function \
661665 does not use out pointer") ;
662666 C_null ( Type :: i8p ( ccx) )
@@ -684,7 +688,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
684688 & llargs,
685689 ret_ty, llret_ty,
686690 call_debug_location,
687- call_info )
691+ span )
688692 }
689693 // This requires that atomic intrinsics follow a specific naming pattern:
690694 // "atomic_<operation>[_<ordering>]", and no ordering means SeqCst
@@ -1404,7 +1408,7 @@ fn generic_simd_intrinsic<'blk, 'tcx, 'a>
14041408 ret_ty : Ty < ' tcx > ,
14051409 llret_ty : Type ,
14061410 call_debug_location : DebugLoc ,
1407- call_info : NodeIdAndSpan ) -> ValueRef
1411+ span : Span ) -> ValueRef
14081412{
14091413 // macros for error handling:
14101414 macro_rules! emit_error {
@@ -1413,7 +1417,7 @@ fn generic_simd_intrinsic<'blk, 'tcx, 'a>
14131417 } ;
14141418 ( $msg: tt, $( $fmt: tt) * ) => {
14151419 span_invalid_monomorphization_error(
1416- bcx. sess( ) , call_info . span,
1420+ bcx. sess( ) , span,
14171421 & format!( concat!( "invalid monomorphization of `{}` intrinsic: " ,
14181422 $msg) ,
14191423 name, $( $fmt) * ) ) ;
@@ -1482,7 +1486,7 @@ fn generic_simd_intrinsic<'blk, 'tcx, 'a>
14821486 if name. starts_with ( "simd_shuffle" ) {
14831487 let n: usize = match name[ "simd_shuffle" . len ( ) ..] . parse ( ) {
14841488 Ok ( n) => n,
1485- Err ( _) => tcx. sess . span_bug ( call_info . span ,
1489+ Err ( _) => tcx. sess . span_bug ( span,
14861490 "bad `simd_shuffle` instruction only caught in trans?" )
14871491 } ;
14881492
@@ -1502,14 +1506,14 @@ fn generic_simd_intrinsic<'blk, 'tcx, 'a>
15021506
15031507 let vector = match args {
15041508 Some ( args) => & args[ 2 ] ,
1505- None => bcx. sess ( ) . span_bug ( call_info . span ,
1509+ None => bcx. sess ( ) . span_bug ( span,
15061510 "intrinsic call with unexpected argument shape" ) ,
15071511 } ;
15081512 let vector = match consts:: const_expr ( bcx. ccx ( ) , vector, substs, None ,
15091513 consts:: TrueConst :: Yes , // this should probably help simd error reporting
15101514 ) {
15111515 Ok ( ( vector, _) ) => vector,
1512- Err ( err) => bcx. sess ( ) . span_fatal ( call_info . span , & err. description ( ) ) ,
1516+ Err ( err) => bcx. sess ( ) . span_fatal ( span, & err. description ( ) ) ,
15131517 } ;
15141518
15151519 let indices: Option < Vec < _ > > = ( 0 ..n)
@@ -1652,7 +1656,7 @@ fn generic_simd_intrinsic<'blk, 'tcx, 'a>
16521656 simd_or: TyUint , TyInt => Or ;
16531657 simd_xor: TyUint , TyInt => Xor ;
16541658 }
1655- bcx. sess ( ) . span_bug ( call_info . span , "unknown SIMD intrinsic" ) ;
1659+ bcx. sess ( ) . span_bug ( span, "unknown SIMD intrinsic" ) ;
16561660}
16571661
16581662// Returns the width of an int TypeVariant, and if it's signed or not
0 commit comments