From 80929e17ae4806a1d2fb5cf282f430c5e34f7796 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 10 Aug 2020 09:04:37 +0200 Subject: [PATCH 1/2] add test for unused ill-formed constant also use better span in TopFrameInfo --- src/diagnostics.rs | 2 +- tests/compile-fail/erroneous_const.rs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/compile-fail/erroneous_const.rs diff --git a/src/diagnostics.rs b/src/diagnostics.rs index ca3dd4dd66..eed60c2696 100644 --- a/src/diagnostics.rs +++ b/src/diagnostics.rs @@ -227,7 +227,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx TopFrameInfo { stack_size: this.active_thread_stack().len(), instance: Some(frame.instance), - span: frame.current_source_info().map_or(DUMMY_SP, |si| si.span), + span: frame.current_span(), } } diff --git a/tests/compile-fail/erroneous_const.rs b/tests/compile-fail/erroneous_const.rs new file mode 100644 index 0000000000..287e073581 --- /dev/null +++ b/tests/compile-fail/erroneous_const.rs @@ -0,0 +1,19 @@ +//! Make sure we detect erroneous constants post-monomorphization even when they are unused. +//! (https://github.com/rust-lang/miri/issues/1382) +#![feature(const_panic)] +#![feature(never_type)] +#![warn(warnings, const_err)] + +struct PrintName(T); +impl PrintName { + const VOID: ! = panic!(); //~WARN any use of this value will cause an error +} + +fn no_codegen() { + if false { + let _ = PrintName::::VOID; //~ERROR referenced constant has errors + } +} +fn main() { + no_codegen::(); +} From 925d60760eb953af3ffd288fa5a8e9546f60311e Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 13 Aug 2020 08:43:28 +0200 Subject: [PATCH 2/2] rustup --- rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-version b/rust-version index c8fd55f4c3..198b3970e0 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -c94ed5ca91f1363b66970ce2cbd6e2773e3cb1d3 +814bc4fe9364865bfaa94d7825b8eabc11245c7c