Merge pull request #328 from dwrensha/rustup
update for upstream rename: CodeExtent -> Scope
This commit is contained in:
commit
0002b5af2e
8 changed files with 38 additions and 23 deletions
|
|
@ -4,7 +4,7 @@ use std::fmt::Write;
|
|||
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)]
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use std::cell::Cell;
|
|||
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 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> {
|
|||
&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 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> {
|
|||
&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 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> {
|
|||
&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 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> {
|
|||
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 {:?}",
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use rustc::ty::subst::{Substs, Subst};
|
|||
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 @@ pub type ValidationQuery<'tcx> = ValidationOperand<'tcx, Lvalue>;
|
|||
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 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
|
|||
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 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
|
|||
&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 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
|
|||
// 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.
|
||||
_ => {}
|
||||
|
|
|
|||
|
|
@ -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> {
|
||||
|
|
|
|||
|
|
@ -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) };
|
||||
|
|
|
|||
|
|
@ -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)));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue