Skip to content

update for upstream rename: CodeExtent -> Scope #328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustc_mir/interpret/eval_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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)]
Expand Down
16 changes: 8 additions & 8 deletions src/librustc_mir/interpret/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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,
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {:?}",
Expand Down
26 changes: 13 additions & 13 deletions src/librustc_mir/interpret/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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 {
Expand Down Expand Up @@ -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(())
Expand Down Expand Up @@ -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> {
Expand Down Expand Up @@ -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.
_ => {}
Expand Down
3 changes: 3 additions & 0 deletions tests/run-pass/dst-field-align.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
3 changes: 3 additions & 0 deletions tests/run-pass/mir_coercions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions tests/run-pass/non_capture_closure_to_fn_ptr.rs
Original file line number Diff line number Diff line change
@@ -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) };
Expand Down
3 changes: 3 additions & 0 deletions tests/run-pass/subslice_array.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// FIXME: investigate again once #296 is fixed
// compile-flags: -Zmir-emit-validate=0

#![feature(advanced_slice_patterns)]
#![feature(slice_patterns)]

Expand Down
Original file line number Diff line number Diff line change
@@ -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)));
Expand Down