11//! Type-checking for the rust-intrinsic and platform-intrinsic
22//! intrinsics that the compiler exposes.
33
4+ use rustc:: hir:: { self , Mutability } ;
5+ use rustc:: middle:: lang_items:: PanicLocationLangItem ;
46use rustc:: traits:: { ObligationCause , ObligationCauseCode } ;
57use rustc:: ty:: { self , TyCtxt , Ty } ;
68use rustc:: ty:: subst:: Subst ;
@@ -9,8 +11,6 @@ use crate::require_same_types;
911use rustc_target:: spec:: abi:: Abi ;
1012use syntax:: symbol:: Symbol ;
1113
12- use rustc:: hir;
13-
1414use std:: iter;
1515
1616fn equate_intrinsic_type < ' tcx > (
@@ -65,7 +65,7 @@ fn equate_intrinsic_type<'tcx>(
6565/// Returns `true` if the given intrinsic is unsafe to call or not.
6666pub fn intrinsic_operation_unsafety ( intrinsic : & str ) -> hir:: Unsafety {
6767 match intrinsic {
68- "size_of" | "min_align_of" | "needs_drop" |
68+ "size_of" | "min_align_of" | "needs_drop" | "caller_location" |
6969 "add_with_overflow" | "sub_with_overflow" | "mul_with_overflow" |
7070 "wrapping_add" | "wrapping_sub" | "wrapping_mul" |
7171 "saturating_add" | "saturating_sub" |
@@ -143,6 +143,18 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem) {
143143 ] , tcx. types . usize )
144144 }
145145 "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+ ) ,
146158 "panic_if_uninhabited" => ( 1 , Vec :: new ( ) , tcx. mk_unit ( ) ) ,
147159 "init" => ( 1 , Vec :: new ( ) , param ( 0 ) ) ,
148160 "uninit" => ( 1 , Vec :: new ( ) , param ( 0 ) ) ,
0 commit comments