fix Rvalue::ty for ThreadLocalRef
This commit is contained in:
parent
c1766c6372
commit
153e843c49
5 changed files with 19 additions and 14 deletions
|
@ -1007,13 +1007,13 @@ impl<'tcx> LocalDecl<'tcx> {
|
|||
}
|
||||
|
||||
/// Returns `Some` if this is a reference to a static item that is used to
|
||||
/// access that static
|
||||
/// access that static.
|
||||
pub fn is_ref_to_static(&self) -> bool {
|
||||
matches!(self.local_info, Some(box LocalInfo::StaticRef { .. }))
|
||||
}
|
||||
|
||||
/// Returns `Some` if this is a reference to a static item that is used to
|
||||
/// access that static
|
||||
/// Returns `Some` if this is a reference to a thread-local static item that is used to
|
||||
/// access that static.
|
||||
pub fn is_ref_to_thread_local(&self) -> bool {
|
||||
match self.local_info {
|
||||
Some(box LocalInfo::StaticRef { is_thread_local, .. }) => is_thread_local,
|
||||
|
|
|
@ -152,10 +152,14 @@ impl<'tcx> Rvalue<'tcx> {
|
|||
tcx.mk_ty(ty::Array(operand.ty(local_decls, tcx), count))
|
||||
}
|
||||
Rvalue::ThreadLocalRef(did) => {
|
||||
let static_ty = tcx.type_of(did);
|
||||
if tcx.is_mutable_static(did) {
|
||||
tcx.mk_mut_ptr(tcx.type_of(did))
|
||||
tcx.mk_mut_ptr(static_ty)
|
||||
} else if tcx.is_foreign_item(did) {
|
||||
tcx.mk_imm_ptr(static_ty)
|
||||
} else {
|
||||
tcx.mk_imm_ref(tcx.lifetimes.re_static, tcx.type_of(did))
|
||||
// FIXME: These things don't *really* have 'static lifetime.
|
||||
tcx.mk_imm_ref(tcx.lifetimes.re_static, static_ty)
|
||||
}
|
||||
}
|
||||
Rvalue::Ref(reg, bk, ref place) => {
|
||||
|
|
|
@ -530,6 +530,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
let static_ty = self.normalize_erasing_regions(ty::ParamEnv::empty(), self.type_of(def_id));
|
||||
|
||||
// Make sure that accesses to unsafe statics end up using raw pointers.
|
||||
// For thread-locals, this needs to be kept in sync with `Rvalue::ty`.
|
||||
if self.is_mutable_static(def_id) {
|
||||
self.mk_mut_ptr(static_ty)
|
||||
} else if self.is_foreign_item(def_id) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue