Skip to content

Commit

Permalink
Merge pull request rust-lang#46 from oli-obk/rustup
Browse files Browse the repository at this point in the history
rustup to rustc 1.13.0-nightly (91f057d 2016-09-04)
  • Loading branch information
solson authored Sep 7, 2016
2 parents 45cf3cf + 7b24d55 commit f718e77
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 39 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 11 additions & 8 deletions src/bin/miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use miri::{eval_main, run_mir_passes};
use rustc::session::Session;
use rustc::mir::mir_map::MirMap;
use rustc_driver::{driver, CompilerCalls, Compilation};
use syntax::ast::MetaItemKind;
use syntax::ast::{MetaItemKind, NestedMetaItemKind};

struct MiriCompilerCalls;

Expand Down Expand Up @@ -52,14 +52,17 @@ impl<'a> CompilerCalls<'a> for MiriCompilerCalls {
MetaItemKind::List(ref name, _) if name != "miri" => {}
MetaItemKind::List(_, ref items) => for item in items {
match item.node {
MetaItemKind::NameValue(ref name, ref value) => {
match &**name {
"memory_size" => memory_size = extract_str(value).parse().expect("not a number"),
"step_limit" => step_limit = extract_str(value).parse().expect("not a number"),
"stack_limit" => stack_limit = extract_str(value).parse().expect("not a number"),
_ => state.session.span_err(item.span, "unknown miri attribute"),
NestedMetaItemKind::MetaItem(ref inner) => match inner.node {
MetaItemKind::NameValue(ref name, ref value) => {
match &**name {
"memory_size" => memory_size = extract_str(value).parse().expect("not a number"),
"step_limit" => step_limit = extract_str(value).parse().expect("not a number"),
"stack_limit" => stack_limit = extract_str(value).parse().expect("not a number"),
_ => state.session.span_err(item.span, "unknown miri attribute"),
}
}
}
_ => state.session.span_err(inner.span, "miri attributes need to be of key = value kind"),
},
_ => state.session.span_err(item.span, "miri attributes need to be of key = value kind"),
}
},
Expand Down
10 changes: 5 additions & 5 deletions src/interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
// TODO(solson): Is this inefficient? Needs investigation.
let ty = self.monomorphize(ty, substs);

self.tcx.normalizing_infer_ctxt(Reveal::All).enter(|infcx| {
self.tcx.infer_ctxt(None, None, Reveal::All).enter(|infcx| {
// TODO(solson): Report this error properly.
ty.layout(&infcx).unwrap()
})
Expand Down Expand Up @@ -454,7 +454,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
}

General { discr, ref variants, .. } => {
if let mir::AggregateKind::Adt(adt_def, variant, _) = *kind {
if let mir::AggregateKind::Adt(adt_def, variant, _, _) = *kind {
let discr_val = adt_def.variants[variant].disr_val.to_u64_unchecked();
let discr_size = discr.size().bytes() as usize;
self.memory.write_uint(dest, discr_val, discr_size)?;
Expand All @@ -468,7 +468,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
}

RawNullablePointer { nndiscr, .. } => {
if let mir::AggregateKind::Adt(_, variant, _) = *kind {
if let mir::AggregateKind::Adt(_, variant, _, _) = *kind {
if nndiscr == variant as u64 {
assert_eq!(operands.len(), 1);
let operand = &operands[0];
Expand All @@ -485,7 +485,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
}

StructWrappedNullablePointer { nndiscr, ref nonnull, ref discrfield } => {
if let mir::AggregateKind::Adt(_, variant, _) = *kind {
if let mir::AggregateKind::Adt(_, variant, _, _) = *kind {
if nndiscr == variant as u64 {
let offsets = iter::once(0)
.chain(nonnull.offset_after_field.iter().map(|s| s.bytes()));
Expand All @@ -503,7 +503,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {

CEnum { discr, signed, .. } => {
assert_eq!(operands.len(), 0);
if let mir::AggregateKind::Adt(adt_def, variant, _) = *kind {
if let mir::AggregateKind::Adt(adt_def, variant, _, _) = *kind {
let val = adt_def.variants[variant].disr_val.to_u64_unchecked();
let size = discr.size().bytes() as usize;

Expand Down
22 changes: 14 additions & 8 deletions src/interpreter/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
}

let block = self.frame().block;
let stmt = self.frame().stmt;
let stmt_id = self.frame().stmt;
let mir = self.mir();
let basic_block = &mir.basic_blocks()[block];

if let Some(ref stmt) = basic_block.statements.get(stmt) {
if let Some(ref stmt) = basic_block.statements.get(stmt_id) {
let mut new = Ok(0);
ConstantExtractor {
span: stmt.source_info.span,
Expand All @@ -37,7 +37,10 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
ecx: self,
mir: &mir,
new_constants: &mut new,
}.visit_statement(block, stmt);
}.visit_statement(block, stmt, mir::Location {
block: block,
statement_index: stmt_id,
});
if new? == 0 {
self.statement(stmt)?;
}
Expand All @@ -55,7 +58,10 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
ecx: self,
mir: &mir,
new_constants: &mut new,
}.visit_terminator(block, terminator);
}.visit_terminator(block, terminator, mir::Location {
block: block,
statement_index: stmt_id,
});
if new? == 0 {
self.terminator(terminator)?;
}
Expand Down Expand Up @@ -135,8 +141,8 @@ impl<'a, 'b, 'tcx> ConstantExtractor<'a, 'b, 'tcx> {
}

impl<'a, 'b, 'tcx> Visitor<'tcx> for ConstantExtractor<'a, 'b, 'tcx> {
fn visit_constant(&mut self, constant: &mir::Constant<'tcx>) {
self.super_constant(constant);
fn visit_constant(&mut self, constant: &mir::Constant<'tcx>, location: mir::Location) {
self.super_constant(constant, location);
match constant.literal {
// already computed by rustc
mir::Literal::Value { .. } => {}
Expand Down Expand Up @@ -170,8 +176,8 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for ConstantExtractor<'a, 'b, 'tcx> {
}
}

fn visit_lvalue(&mut self, lvalue: &mir::Lvalue<'tcx>, context: LvalueContext) {
self.super_lvalue(lvalue, context);
fn visit_lvalue(&mut self, lvalue: &mir::Lvalue<'tcx>, context: LvalueContext, location: mir::Location) {
self.super_lvalue(lvalue, context, location);
if let mir::Lvalue::Static(def_id) = *lvalue {
let substs = subst::Substs::empty(self.ecx.tcx);
let span = self.span;
Expand Down
24 changes: 12 additions & 12 deletions src/interpreter/terminator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {

// The discriminant_value intrinsic returns 0 for non-sum types.
Array { .. } | FatPointer { .. } | Scalar { .. } | Univariant { .. } |
Vector { .. } => 0,
Vector { .. } | UntaggedUnion { .. } => 0,
};

Ok(discr_val)
Expand Down Expand Up @@ -278,7 +278,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
"assume" => {}

"copy_nonoverlapping" => {
let elem_ty = substs.types[0];
let elem_ty = substs.type_at(0);
let elem_size = self.type_size(elem_ty);
let elem_align = self.type_align(elem_ty);
let src = self.memory.read_ptr(args_ptrs[0])?;
Expand All @@ -288,7 +288,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
}

"discriminant_value" => {
let ty = substs.types[0];
let ty = substs.type_at(0);
let adt_ptr = self.memory.read_ptr(args_ptrs[0])?;
let discr_val = self.read_discriminant_value(adt_ptr, ty)?;
self.memory.write_uint(dest, discr_val, 8)?;
Expand All @@ -299,19 +299,19 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
"init" => self.memory.write_repeat(dest, 0, dest_layout.size(&self.tcx.data_layout).bytes() as usize)?,

"min_align_of" => {
let elem_ty = substs.types[0];
let elem_ty = substs.type_at(0);
let elem_align = self.type_align(elem_ty);
self.memory.write_uint(dest, elem_align as u64, pointer_size)?;
}

"move_val_init" => {
let ty = substs.types[0];
let ty = substs.type_at(0);
let ptr = self.memory.read_ptr(args_ptrs[0])?;
self.move_(args_ptrs[1], ptr, ty)?;
}

"offset" => {
let pointee_ty = substs.types[0];
let pointee_ty = substs.type_at(0);
let pointee_size = self.type_size(pointee_ty) as isize;
let ptr_arg = args_ptrs[0];
let offset = self.memory.read_isize(args_ptrs[1])?;
Expand Down Expand Up @@ -343,13 +343,13 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
}

"size_of" => {
let ty = substs.types[0];
let ty = substs.type_at(0);
let size = self.type_size(ty) as u64;
self.memory.write_uint(dest, size, pointer_size)?;
}

"size_of_val" => {
let ty = substs.types[0];
let ty = substs.type_at(0);
if self.type_is_sized(ty) {
let size = self.type_size(ty) as u64;
self.memory.write_uint(dest, size, pointer_size)?;
Expand All @@ -369,7 +369,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
}

"transmute" => {
let ty = substs.types[0];
let ty = substs.type_at(0);
self.move_(args_ptrs[0], dest, ty)?;
}
"uninit" => self.memory.mark_definedness(dest, dest_layout.size(&self.tcx.data_layout).bytes() as usize, false)?,
Expand Down Expand Up @@ -457,7 +457,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
fn fulfill_obligation(&self, trait_ref: ty::PolyTraitRef<'tcx>) -> traits::Vtable<'tcx, ()> {
// Do the initial selection for the obligation. This yields the shallow result we are
// looking for -- that is, what specific impl.
self.tcx.normalizing_infer_ctxt(Reveal::All).enter(|infcx| {
self.tcx.infer_ctxt(None, None, Reveal::All).enter(|infcx| {
let mut selcx = traits::SelectionContext::new(&infcx);

let obligation = traits::Obligation::new(
Expand Down Expand Up @@ -570,14 +570,14 @@ fn get_impl_method<'a, 'tcx>(
impl_substs: &'tcx Substs<'tcx>,
name: ast::Name,
) -> ImplMethod<'tcx> {
assert!(!substs.types.needs_infer());
assert!(!substs.needs_infer());

let trait_def_id = tcx.trait_id_of_impl(impl_def_id).unwrap();
let trait_def = tcx.lookup_trait_def(trait_def_id);

match trait_def.ancestors(impl_def_id).fn_defs(tcx, name).next() {
Some(node_item) => {
let substs = tcx.normalizing_infer_ctxt(Reveal::All).enter(|infcx| {
let substs = tcx.infer_ctxt(None, None, Reveal::All).enter(|infcx| {
let substs = substs.rebase_onto(tcx, trait_def_id, impl_substs);
let substs = traits::translate_substs(&infcx, impl_def_id,
substs, node_item.node);
Expand Down

0 comments on commit f718e77

Please sign in to comment.