1
1
//! Type-checking for the rust-intrinsic and platform-intrinsic
2
2
//! intrinsics that the compiler exposes.
3
3
4
+ use rustc:: hir:: { self , Mutability } ;
5
+ use rustc:: middle:: lang_items:: PanicLocationLangItem ;
4
6
use rustc:: traits:: { ObligationCause , ObligationCauseCode } ;
5
7
use rustc:: ty:: { self , TyCtxt , Ty } ;
6
8
use rustc:: ty:: subst:: Subst ;
@@ -9,8 +11,6 @@ use crate::require_same_types;
9
11
use rustc_target:: spec:: abi:: Abi ;
10
12
use syntax:: symbol:: Symbol ;
11
13
12
- use rustc:: hir;
13
-
14
14
use std:: iter;
15
15
16
16
fn equate_intrinsic_type < ' tcx > (
@@ -65,7 +65,7 @@ fn equate_intrinsic_type<'tcx>(
65
65
/// Returns `true` if the given intrinsic is unsafe to call or not.
66
66
pub fn intrinsic_operation_unsafety ( intrinsic : & str ) -> hir:: Unsafety {
67
67
match intrinsic {
68
- "size_of" | "min_align_of" | "needs_drop" |
68
+ "size_of" | "min_align_of" | "needs_drop" | "caller_location" |
69
69
"add_with_overflow" | "sub_with_overflow" | "mul_with_overflow" |
70
70
"wrapping_add" | "wrapping_sub" | "wrapping_mul" |
71
71
"saturating_add" | "saturating_sub" |
@@ -143,6 +143,18 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem) {
143
143
] , tcx. types . usize )
144
144
}
145
145
"rustc_peek" => ( 1 , vec ! [ param( 0 ) ] , param ( 0 ) ) ,
146
+ "caller_location" => (
147
+ 0 ,
148
+ vec ! [ ] ,
149
+ tcx. mk_ref (
150
+ tcx. lifetimes . re_static ,
151
+ ty:: TypeAndMut {
152
+ mutbl : Mutability :: MutImmutable ,
153
+ ty : tcx. type_of ( tcx. require_lang_item ( PanicLocationLangItem , None ) )
154
+ . subst ( tcx, tcx. mk_substs ( [ tcx. lifetimes . re_static . into ( ) ] . iter ( ) ) ) ,
155
+ } ,
156
+ ) ,
157
+ ) ,
146
158
"panic_if_uninhabited" => ( 1 , Vec :: new ( ) , tcx. mk_unit ( ) ) ,
147
159
"init" => ( 1 , Vec :: new ( ) , param ( 0 ) ) ,
148
160
"uninit" => ( 1 , Vec :: new ( ) , param ( 0 ) ) ,
0 commit comments