@@ -44,6 +44,9 @@ use syntax::ast;
4444use syntax:: ptr:: P ;
4545use syntax:: parse:: token;
4646
47+ use rustc:: session:: Session ;
48+ use syntax:: codemap:: Span ;
49+
4750use std:: cmp:: Ordering ;
4851
4952pub fn get_simple_intrinsic ( ccx : & CrateContext , item : & hir:: ForeignItem ) -> Option < ValueRef > {
@@ -99,6 +102,10 @@ pub fn get_simple_intrinsic(ccx: &CrateContext, item: &hir::ForeignItem) -> Opti
99102 Some ( ccx. get_intrinsic ( & name) )
100103}
101104
105+ pub fn span_transmute_size_error ( a : & Session , b : Span , msg : & str ) {
106+ span_err ! ( a, b, E0512 , "{}" , msg) ;
107+ }
108+
102109/// Performs late verification that intrinsics are used correctly. At present,
103110/// the only intrinsic that needs such verification is `transmute`.
104111pub fn check_intrinsics ( ccx : & CrateContext ) {
@@ -127,8 +134,7 @@ pub fn check_intrinsics(ccx: &CrateContext) {
127134 last_failing_id = Some ( transmute_restriction. id ) ;
128135
129136 if transmute_restriction. original_from != transmute_restriction. substituted_from {
130- ccx. sess ( ) . span_err (
131- transmute_restriction. span ,
137+ span_transmute_size_error ( ccx. sess ( ) , transmute_restriction. span ,
132138 & format ! ( "transmute called on types with potentially different sizes: \
133139 {} (could be {} bit{}) to {} (could be {} bit{})",
134140 transmute_restriction. original_from,
@@ -138,8 +144,7 @@ pub fn check_intrinsics(ccx: &CrateContext) {
138144 to_type_size as usize ,
139145 if to_type_size == 1 { "" } else { "s" } ) ) ;
140146 } else {
141- ccx. sess ( ) . span_err (
142- transmute_restriction. span ,
147+ span_transmute_size_error ( ccx. sess ( ) , transmute_restriction. span ,
143148 & format ! ( "transmute called on types with different sizes: \
144149 {} ({} bit{}) to {} ({} bit{})",
145150 transmute_restriction. original_from,
@@ -798,9 +803,9 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
798803
799804 ( _, "return_address" ) => {
800805 if !fcx. caller_expects_out_pointer {
801- tcx. sess . span_err ( call_info. span ,
802- "invalid use of `return_address` intrinsic: function \
803- does not use out pointer") ;
806+ span_err ! ( tcx. sess, call_info. span, E0510 ,
807+ "invalid use of `return_address` intrinsic: function \
808+ does not use out pointer") ;
804809 C_null ( Type :: i8p ( ccx) )
805810 } else {
806811 PointerCast ( bcx, llvm:: get_param ( fcx. llfn , 0 ) , Type :: i8p ( ccx) )
@@ -1439,6 +1444,10 @@ fn get_rust_try_fn<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>,
14391444 return rust_try
14401445}
14411446
1447+ fn span_invalid_monomorphization_error ( a : & Session , b : Span , c : & str ) {
1448+ span_err ! ( a, b, E0511 , "{}" , c) ;
1449+ }
1450+
14421451fn generic_simd_intrinsic < ' blk , ' tcx , ' a >
14431452 ( bcx : Block < ' blk , ' tcx > ,
14441453 name : & str ,
@@ -1457,10 +1466,11 @@ fn generic_simd_intrinsic<'blk, 'tcx, 'a>
14571466 emit_error!( $msg, )
14581467 } ;
14591468 ( $msg: tt, $( $fmt: tt) * ) => {
1460- bcx. sess( ) . span_err( call_info. span,
1461- & format!( concat!( "invalid monomorphization of `{}` intrinsic: " ,
1462- $msg) ,
1463- name, $( $fmt) * ) ) ;
1469+ span_invalid_monomorphization_error(
1470+ bcx. sess( ) , call_info. span,
1471+ & format!( concat!( "invalid monomorphization of `{}` intrinsic: " ,
1472+ $msg) ,
1473+ name, $( $fmt) * ) ) ;
14641474 }
14651475 }
14661476 macro_rules! require {
0 commit comments