Skip to content

Commit

Permalink
Auto merge of #1137 - anp:track-caller-update, r=RalfJung
Browse files Browse the repository at this point in the history
Update panic machinery to match #[track_caller] changes.

This gets miri's tests passing again with rust-lang/rust#67137, I don't think it will pass CI until that has merged.
  • Loading branch information
bors committed Jan 6, 2020
2 parents f3c267d + 3607daf commit 50a5e20
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0ec370670220b712b042ee09aab067ec7e5878d5
093241deae70ba38413aff823b31c23731debf14
4 changes: 2 additions & 2 deletions src/bin/miri-rustc-tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extern crate rustc_driver;
extern crate rustc_errors;
extern crate rustc_interface;
extern crate rustc_metadata;
extern crate syntax;
extern crate rustc_span;

use std::io;
use std::io::Write;
Expand Down Expand Up @@ -40,7 +40,7 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
impl<'tcx, 'hir> itemlikevisit::ItemLikeVisitor<'hir> for Visitor<'tcx> {
fn visit_item(&mut self, i: &'hir hir::Item) {
if let hir::ItemKind::Fn(.., body_id) = i.kind {
if i.attrs.iter().any(|attr| attr.check_name(syntax::symbol::sym::test))
if i.attrs.iter().any(|attr| attr.check_name(rustc_span::symbol::sym::test))
{
let config = MiriConfig {
validate: true,
Expand Down
2 changes: 1 addition & 1 deletion src/bin/miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extern crate rustc_driver;
extern crate rustc_errors;
extern crate rustc_interface;
extern crate rustc_metadata;
extern crate syntax;
extern crate rustc_span;

use std::convert::TryFrom;
use std::env;
Expand Down
2 changes: 1 addition & 1 deletion src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
config: MiriConfig,
) -> InterpResult<'tcx, (InterpCx<'mir, 'tcx, Evaluator<'tcx>>, MPlaceTy<'tcx, Tag>)> {
let mut ecx = InterpCx::new(
tcx.at(syntax::source_map::DUMMY_SP),
tcx.at(rustc_span::source_map::DUMMY_SP),
ty::ParamEnv::reveal_all(),
Evaluator::new(config.communicate),
MemoryExtra::new(
Expand Down
2 changes: 1 addition & 1 deletion src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc::ty::{
layout::{self, LayoutOf, Size, TyLayout},
List, TyCtxt,
};
use syntax::source_map::DUMMY_SP;
use rustc_span::source_map::DUMMY_SP;

use rand::RngCore;

Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ extern crate rustc_apfloat;
extern crate syntax;
#[macro_use]
extern crate rustc;
extern crate rustc_span;
extern crate rustc_data_structures;
extern crate rustc_mir;
extern crate rustc_target;
Expand Down
4 changes: 3 additions & 1 deletion src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ use rustc::ty::{
layout::{LayoutOf, Size},
Ty, TyCtxt,
};
use syntax::{attr, source_map::Span, symbol::sym};
use rustc_span::{source_map::Span, symbol::sym};
use syntax::attr;

use crate::*;

Expand Down Expand Up @@ -182,6 +183,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
#[inline(always)]
fn find_mir_or_eval_fn(
ecx: &mut InterpCx<'mir, 'tcx, Self>,
_span: Span,
instance: ty::Instance<'tcx>,
args: &[OpTy<'tcx, Tag>],
ret: Option<(PlaceTy<'tcx, Tag>, mir::BasicBlock)>,
Expand Down
4 changes: 2 additions & 2 deletions src/shims/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use rustc::mir;
use rustc::ty;
use rustc::ty::layout::{Align, LayoutOf, Size};
use rustc_apfloat::Float;
use rustc_span::symbol::sym;
use syntax::attr;
use syntax::symbol::sym;

use crate::*;

Expand Down Expand Up @@ -961,7 +961,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
// lpBuffer : ptr to buffer that receives contents of the env_var as a null-terminated string.
// Return `# of chars` stored in the buffer pointed to by lpBuffer, excluding null-terminator.
// Return 0 upon failure.

// This is not the env var you are looking for.
this.set_last_error(Scalar::from_u32(203))?; // ERROR_ENVVAR_NOT_FOUND
this.write_null(dest)?;
Expand Down
2 changes: 1 addition & 1 deletion src/shims/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rustc::mir::interpret::{InterpResult, PointerArithmetic};
use rustc::ty;
use rustc::ty::layout::{self, Align, LayoutOf, Size};
use rustc_apfloat::Float;
use syntax::source_map::Span;
use rustc_span::source_map::Span;

use crate::*;

Expand Down
7 changes: 2 additions & 5 deletions src/shims/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use rustc::mir;
use rustc::ty::{self, layout::LayoutOf};
use rustc_target::spec::PanicStrategy;
use syntax::source_map::Span;
use rustc_span::source_map::Span;

use crate::*;

Expand Down Expand Up @@ -187,15 +187,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
let msg = msg.description();
let msg = this.allocate_str(msg, MiriMemoryKind::Env.into());

// Second arg: Caller location.
let location = this.alloc_caller_location_for_span(span);

// Call the lang item.
let panic = this.tcx.lang_items().panic_fn().unwrap();
let panic = ty::Instance::mono(this.tcx.tcx, panic);
this.call_function(
panic,
&[msg.to_ref(), location.ptr.into()],
&[msg.to_ref()],
None,
StackPopCleanup::Goto { ret: None, unwind },
)?;
Expand Down

0 comments on commit 50a5e20

Please sign in to comment.