Skip to content

Commit c6d97df

Browse files
committed
Fix rebase
1 parent 47a3294 commit c6d97df

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

src/librustc/mir/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use crate::hir::def::{CtorKind, Namespace};
88
use crate::hir::def_id::DefId;
99
use crate::hir;
10-
use crate::mir::interpret::{ConstValue, GlobalAlloc, PanicInfo, Scalar};
10+
use crate::mir::interpret::{GlobalAlloc, PanicInfo, Scalar};
1111
use crate::mir::visit::MirVisitable;
1212
use crate::ty::adjustment::PointerCast;
1313
use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
@@ -2343,8 +2343,8 @@ pub struct Constant<'tcx> {
23432343

23442344
impl Constant<'tcx> {
23452345
pub fn check_static_ptr(&self, tcx: TyCtxt<'_>) -> Option<DefId> {
2346-
match self.literal.val {
2347-
ConstValue::Scalar(Scalar::Ptr(ptr)) => match tcx.alloc_map.lock().get(ptr.alloc_id) {
2346+
match self.literal.val.try_to_scalar() {
2347+
Some(Scalar::Ptr(ptr)) => match tcx.alloc_map.lock().get(ptr.alloc_id) {
23482348
Some(GlobalAlloc::Static(def_id)) => Some(def_id),
23492349
Some(_) => None,
23502350
None => {

src/librustc_codegen_ssa/mir/constant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1616
constant: &mir::Constant<'tcx>,
1717
) -> Result<OperandRef<'tcx, Bx::Value>, ErrorHandled> {
1818
match constant.literal.val {
19-
mir::interpret::ConstValue::Unevaluated(def_id, substs)
19+
ty::ConstKind::Unevaluated(def_id, substs)
2020
if self.cx.tcx().is_static(def_id) => {
2121
assert!(substs.is_empty(), "we don't support generic statics yet");
2222
let static_ = bx.get_static(def_id);

src/librustc_mir/hair/cx/expr.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::hair::cx::to_ref::ToRef;
55
use crate::hair::util::UserAnnotatedTyHelpers;
66
use rustc_index::vec::Idx;
77
use rustc::hir::def::{CtorOf, Res, DefKind, CtorKind};
8-
use rustc::mir::interpret::{GlobalId, ErrorHandled, ConstValue, Scalar};
8+
use rustc::mir::interpret::{GlobalId, ErrorHandled, Scalar};
99
use rustc::ty::{self, AdtKind, Ty};
1010
use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, AutoBorrowMutability, PointerCast};
1111
use rustc::ty::subst::{InternalSubsts, SubstsRef};
@@ -978,11 +978,9 @@ fn convert_path_expr<'a, 'tcx>(
978978
ty,
979979
temp_lifetime,
980980
span: expr.span,
981-
kind: ExprKind::Literal {
982-
literal: cx.tcx.mk_const(ty::Const {
983-
ty, val: ConstValue::Scalar(Scalar::Ptr(ptr.into())),
984-
}),
985-
user_ty: None,
981+
kind: ExprKind::StaticRef {
982+
literal: ty::Const::from_scalar(cx.tcx, Scalar::Ptr(ptr.into()), ty),
983+
def_id: id,
986984
}
987985
}.to_ref() }
988986
},

src/librustc_mir/transform/check_consts/validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
425425
let is_thread_local = self.tcx.has_attr(def_id, sym::thread_local);
426426
if is_thread_local {
427427
self.check_op(ops::ThreadLocalAccess);
428-
} else if self.const_kind() != ConstKind::Static || !context.is_mutating_use() {
428+
} else {
429429
self.check_op(ops::StaticAccess);
430430
}
431431
}

0 commit comments

Comments
 (0)