Skip to content

Commit 9db11c9

Browse files
committed
Auto merge of rust-lang#2869 - oli-obk:only_interp_compiling_code, r=RalfJung
Avoid interpreting code that has lint errors fixes rust-lang#2608 we previously only checked for actual errors, as deny lints are handled differently.
2 parents 12fd42a + e0114e7 commit 9db11c9

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/tools/miri/src/bin/miri.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
6363
queries: &'tcx rustc_interface::Queries<'tcx>,
6464
) -> Compilation {
6565
queries.global_ctxt().unwrap().enter(|tcx| {
66-
tcx.sess.abort_if_errors();
66+
if tcx.sess.compile_status().is_err() {
67+
tcx.sess.fatal("miri cannot be run on programs that fail compilation");
68+
}
6769

6870
init_late_loggers(tcx);
6971
if !tcx.sess.crate_types().contains(&CrateType::Executable) {
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@error-pattern: miri cannot be run on programs that fail compilation
2+
3+
#![deny(warnings)]
4+
5+
struct Foo;
6+
//~^ ERROR: struct `Foo` is never constructed
7+
8+
fn main() {}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error: struct `Foo` is never constructed
2+
--> $DIR/deny_lint.rs:LL:CC
3+
|
4+
LL | struct Foo;
5+
| ^^^
6+
|
7+
= note: `-D dead-code` implied by `-D unused`
8+
9+
error: miri cannot be run on programs that fail compilation
10+
11+
error: aborting due to 2 previous errors
12+

0 commit comments

Comments
 (0)