diff options
| author | bors <bors@rust-lang.org> | 2023-05-02 20:05:15 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-05-02 20:05:15 +0000 |
| commit | 9db11c97896e9a0de9fbd2d28c72bcf3b2e60583 (patch) | |
| tree | 7321a45c8a5093408fb5d833b618f148b935e8e1 | |
| parent | 12fd42a2452a5dbea62d20898533b36947abb5be (diff) | |
| parent | e0114e78b9d4a7e0f05b1b4c1c0d9942436c34b0 (diff) | |
| download | rust-9db11c97896e9a0de9fbd2d28c72bcf3b2e60583.tar.gz rust-9db11c97896e9a0de9fbd2d28c72bcf3b2e60583.zip | |
Auto merge of #2869 - oli-obk:only_interp_compiling_code, r=RalfJung
Avoid interpreting code that has lint errors fixes #2608 we previously only checked for actual errors, as deny lints are handled differently.
| -rw-r--r-- | src/tools/miri/src/bin/miri.rs | 4 | ||||
| -rw-r--r-- | src/tools/miri/tests/fail/deny_lint.rs | 8 | ||||
| -rw-r--r-- | src/tools/miri/tests/fail/deny_lint.stderr | 12 |
3 files changed, 23 insertions, 1 deletions
diff --git a/src/tools/miri/src/bin/miri.rs b/src/tools/miri/src/bin/miri.rs index e4ca40570b7..a77b6e53353 100644 --- a/src/tools/miri/src/bin/miri.rs +++ b/src/tools/miri/src/bin/miri.rs @@ -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) { diff --git a/src/tools/miri/tests/fail/deny_lint.rs b/src/tools/miri/tests/fail/deny_lint.rs new file mode 100644 index 00000000000..a0cb24c51bd --- /dev/null +++ b/src/tools/miri/tests/fail/deny_lint.rs @@ -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() {} diff --git a/src/tools/miri/tests/fail/deny_lint.stderr b/src/tools/miri/tests/fail/deny_lint.stderr new file mode 100644 index 00000000000..bb48fcc2038 --- /dev/null +++ b/src/tools/miri/tests/fail/deny_lint.stderr @@ -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 + |
