Merge pull request #328 from dwrensha/rustup

update for upstream rename: CodeExtent -> Scope
This commit is contained in:
Ralf Jung
2017-09-04 12:37:22 +02:00
committed by GitHub
8 changed files with 38 additions and 23 deletions
+2 -2
View File
@@ -4,7 +4,7 @@
use rustc::hir::def_id::DefId;
use rustc::hir::map::definitions::DefPathData;
use rustc::middle::const_val::ConstVal;
use rustc::middle::region::CodeExtent;
use rustc::middle::region;
use rustc::mir;
use rustc::traits::Reveal;
use rustc::ty::layout::{self, Layout, Size, Align, HasDataLayout};
@@ -106,7 +106,7 @@ pub enum StackPopCleanup {
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct DynamicLifetime {
pub frame: usize,
pub region: Option<CodeExtent>, // "None" indicates "until the function ends"
pub region: Option<region::Scope>, // "None" indicates "until the function ends"
}
#[derive(Copy, Clone, Debug)]
+8 -8
View File
@@ -6,7 +6,7 @@
use rustc::ty::Instance;
use rustc::ty::layout::{self, TargetDataLayout, HasDataLayout};
use syntax::ast::Mutability;
use rustc::middle::region::CodeExtent;
use rustc::middle::region;
use super::{EvalResult, EvalErrorKind, PrimVal, Pointer, EvalContext, DynamicLifetime, Machine,
RangeMap};
@@ -26,7 +26,7 @@ pub enum AccessKind {
struct LockInfo {
/// Stores for which lifetimes (of the original write lock) we got
/// which suspensions.
suspended: HashMap<DynamicLifetime, Vec<CodeExtent>>,
suspended: HashMap<DynamicLifetime, Vec<region::Scope>>,
/// The current state of the lock that's actually effective.
active: Lock,
}
@@ -567,7 +567,7 @@ pub(crate) fn acquire_lock(
&mut self,
ptr: MemoryPointer,
len: u64,
region: Option<CodeExtent>,
region: Option<region::Scope>,
kind: AccessKind,
) -> EvalResult<'tcx> {
let frame = self.cur_frame;
@@ -620,8 +620,8 @@ pub(crate) fn suspend_write_lock(
&mut self,
ptr: MemoryPointer,
len: u64,
lock_region: Option<CodeExtent>,
suspend: Option<CodeExtent>,
lock_region: Option<region::Scope>,
suspend: Option<region::Scope>,
) -> EvalResult<'tcx> {
assert!(len > 0);
let cur_frame = self.cur_frame;
@@ -680,8 +680,8 @@ pub(crate) fn recover_write_lock(
&mut self,
ptr: MemoryPointer,
len: u64,
lock_region: Option<CodeExtent>,
suspended_region: CodeExtent,
lock_region: Option<region::Scope>,
suspended_region: region::Scope,
) -> EvalResult<'tcx> {
assert!(len > 0);
let cur_frame = self.cur_frame;
@@ -741,7 +741,7 @@ pub(crate) fn recover_write_lock(
Ok(())
}
pub(crate) fn locks_lifetime_ended(&mut self, ending_region: Option<CodeExtent>) {
pub(crate) fn locks_lifetime_ended(&mut self, ending_region: Option<region::Scope>) {
let cur_frame = self.cur_frame;
trace!(
"Releasing frame {} locks that expire at {:?}",
+13 -13
View File
@@ -6,7 +6,7 @@
use rustc::traits;
use rustc::infer::InferCtxt;
use rustc::traits::Reveal;
use rustc::middle::region::CodeExtent;
use rustc::middle::region;
use super::{EvalError, EvalResult, EvalErrorKind, EvalContext, DynamicLifetime, AccessKind, Value,
Lvalue, LvalueExtra, Machine};
@@ -17,8 +17,8 @@
enum ValidationMode {
Acquire,
/// Recover because the given region ended
Recover(CodeExtent),
ReleaseUntil(Option<CodeExtent>),
Recover(region::Scope),
ReleaseUntil(Option<region::Scope>),
}
impl ValidationMode {
@@ -89,34 +89,34 @@ pub(crate) fn validation_op(
let mode = match op {
ValidationOp::Acquire => ValidationMode::Acquire,
ValidationOp::Release => ValidationMode::ReleaseUntil(None),
ValidationOp::Suspend(ce) => {
ValidationOp::Suspend(scope) => {
if query.mutbl == MutMutable {
let lft = DynamicLifetime {
frame: self.cur_frame(),
region: Some(ce),
region: Some(scope),
};
trace!("Suspending {:?} until {:?}", query, ce);
trace!("Suspending {:?} until {:?}", query, scope);
self.suspended.entry(lft).or_insert_with(Vec::new).push(
query.clone(),
);
}
ValidationMode::ReleaseUntil(Some(ce))
ValidationMode::ReleaseUntil(Some(scope))
}
};
self.validate(query, mode)
}
pub(crate) fn end_region(&mut self, ce: CodeExtent) -> EvalResult<'tcx> {
self.memory.locks_lifetime_ended(Some(ce));
pub(crate) fn end_region(&mut self, scope: region::Scope) -> EvalResult<'tcx> {
self.memory.locks_lifetime_ended(Some(scope));
// Recover suspended lvals
let lft = DynamicLifetime {
frame: self.cur_frame(),
region: Some(ce),
region: Some(scope),
};
if let Some(queries) = self.suspended.remove(&lft) {
for query in queries {
trace!("Recovering {:?} from suspension", query);
self.validate(query, ValidationMode::Recover(ce))?;
self.validate(query, ValidationMode::Recover(scope))?;
}
}
Ok(())
@@ -268,7 +268,7 @@ fn validate_ptr(
&mut self,
val: Value,
pointee_ty: Ty<'tcx>,
re: Option<CodeExtent>,
re: Option<region::Scope>,
mutbl: Mutability,
mode: ValidationMode,
) -> EvalResult<'tcx> {
@@ -459,7 +459,7 @@ fn try_validate(
// we record the region of this borrow to the context.
if query.re == None {
match *region {
ReScope(ce) => query.re = Some(ce),
ReScope(scope) => query.re = Some(scope),
// It is possible for us to encounter erased lifetimes here because the lifetimes in
// this functions' Subst will be erased.
_ => {}
+3
View File
@@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// FIXME: Broken by #296
// compile-flags: -Zmir-emit-validate=0
#![allow(dead_code)]
struct Foo<T: ?Sized> {
+3
View File
@@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// FIXME: investigate again once #296 is fixed
// compile-flags: -Zmir-emit-validate=0
#![feature(coerce_unsized, unsize)]
use std::ops::CoerceUnsized;
@@ -1,3 +1,6 @@
// FIXME: investigate again once #296 is fixed
// compile-flags: -Zmir-emit-validate=0
// allow(const_err) to work around a bug in warnings
#[allow(const_err)]
static FOO: fn() = || { assert_ne!(42, 43) };
+3
View File
@@ -1,3 +1,6 @@
// FIXME: investigate again once #296 is fixed
// compile-flags: -Zmir-emit-validate=0
#![feature(advanced_slice_patterns)]
#![feature(slice_patterns)]
@@ -1,3 +1,6 @@
// FIXME: investigate again once #296 is fixed
// compile-flags: -Zmir-emit-validate=0
fn main() {
let x = 5;
assert_eq!(Some(&x).map(Some), Some(Some(&x)));