Skip to content

Commit e0114e7

Browse files
committed
Avoid interpreting code that has lint errors
1 parent 12fd42a commit e0114e7

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
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) {
Lines changed: 8 additions & 0 deletions
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() {}
Lines changed: 12 additions & 0 deletions
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)