Skip to content

Commit

Permalink
Avoid interpreting code that has lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed May 2, 2023
1 parent 12fd42a commit e0114e7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/tools/miri/src/bin/miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
queries: &'tcx rustc_interface::Queries<'tcx>,
) -> Compilation {
queries.global_ctxt().unwrap().enter(|tcx| {
tcx.sess.abort_if_errors();
if tcx.sess.compile_status().is_err() {
tcx.sess.fatal("miri cannot be run on programs that fail compilation");
}

init_late_loggers(tcx);
if !tcx.sess.crate_types().contains(&CrateType::Executable) {
Expand Down
8 changes: 8 additions & 0 deletions src/tools/miri/tests/fail/deny_lint.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//@error-pattern: miri cannot be run on programs that fail compilation

#![deny(warnings)]

struct Foo;
//~^ ERROR: struct `Foo` is never constructed

fn main() {}
12 changes: 12 additions & 0 deletions src/tools/miri/tests/fail/deny_lint.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error: struct `Foo` is never constructed
--> $DIR/deny_lint.rs:LL:CC
|
LL | struct Foo;
| ^^^
|
= note: `-D dead-code` implied by `-D unused`

error: miri cannot be run on programs that fail compilation

error: aborting due to 2 previous errors

0 comments on commit e0114e7

Please sign in to comment.