]> git.lizzy.rs Git - rust.git/commitdiff
with this, we support panics on Windows
authorRalf Jung <post@ralfj.de>
Sat, 27 Jun 2020 12:43:37 +0000 (14:43 +0200)
committerRalf Jung <post@ralfj.de>
Sat, 27 Jun 2020 12:43:37 +0000 (14:43 +0200)
28 files changed:
src/shims/foreign_items.rs
src/shims/mod.rs
src/shims/panic.rs
tests/compile-fail/abort-terminator.rs
tests/compile-fail/panic/double_panic.rs
tests/compile-fail/panic/windows1.rs [deleted file]
tests/compile-fail/panic/windows2.rs [deleted file]
tests/compile-fail/panic/windows3.rs [deleted file]
tests/run-pass/panic/catch_panic.rs
tests/run-pass/panic/div-by-zero-2.rs
tests/run-pass/panic/div-by-zero-2.stderr
tests/run-pass/panic/overflowing-lsh-neg.rs
tests/run-pass/panic/overflowing-lsh-neg.stderr
tests/run-pass/panic/overflowing-rsh-1.rs
tests/run-pass/panic/overflowing-rsh-1.stderr
tests/run-pass/panic/overflowing-rsh-2.rs
tests/run-pass/panic/overflowing-rsh-2.stderr
tests/run-pass/panic/panic1.rs
tests/run-pass/panic/panic1.stderr
tests/run-pass/panic/panic2.rs
tests/run-pass/panic/panic2.stderr
tests/run-pass/panic/panic3.rs
tests/run-pass/panic/panic3.stderr
tests/run-pass/panic/panic4.rs
tests/run-pass/panic/panic4.stderr
tests/run-pass/panic/std-panic-locations.rs
tests/run-pass/transmute_fat2.rs
tests/run-pass/transmute_fat2.stderr

index 14c5aac4899a750c8e2b330f1dd1e2b5f83bc620..a7495beef72ee21b03c090833d419fb65c8dad4a 100644 (file)
@@ -129,7 +129,6 @@ fn emulate_foreign_item(
                 // This matches calls to the foreign item `panic_impl`.
                 // The implementation is provided by the function with the `#[panic_handler]` attribute.
                 "panic_impl" => {
-                    this.check_panic_supported()?;
                     let panic_impl_id = tcx.lang_items().panic_impl().unwrap();
                     let panic_impl_instance = ty::Instance::mono(tcx, panic_impl_id);
                     return Ok(Some(&*this.load_mir(panic_impl_instance.def, None)?));
index 37e7b8c40462e51a1b92d6d82ac292e698664ef3..56754a9ebde554664c66f45bccdb657c33a723c5 100644 (file)
@@ -52,14 +52,6 @@ fn find_mir_or_eval_fn(
             return this.emulate_foreign_item(instance.def_id(), args, ret, unwind);
         }
 
-        // Better error message for panics on Windows.
-        let def_id = instance.def_id();
-        if Some(def_id) == this.tcx.lang_items().begin_panic_fn() ||
-            Some(def_id) == this.tcx.lang_items().panic_impl()
-        {
-            this.check_panic_supported()?;
-        }
-
         // Otherwise, load the MIR.
         Ok(Some(&*this.load_mir(instance.def, None)?))
     }
index 43f90f1b04f73d33cd1b46d13c8427713d0daa29..8e291c2012152bc7eeba603c35de3e59bf77d31b 100644 (file)
@@ -34,14 +34,6 @@ pub struct CatchUnwindData<'tcx> {
 
 impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mir, 'tcx> {}
 pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx> {
-    /// Check if panicking is supported on this target, and give a good error otherwise.
-    fn check_panic_supported(&self) -> InterpResult<'tcx> {
-        match self.eval_context_ref().tcx.sess.target.target.target_os.as_str() {
-            "linux" | "macos" => Ok(()),
-            _ => throw_unsup_format!("panicking is not supported on this target"),
-        }
-    }
-
     /// Handles the special `miri_start_panic` intrinsic, which is called
     /// by libpanic_unwind to delegate the actual unwinding process to Miri.
     fn handle_miri_start_panic(
index af1a155435fb6de07f973a8b255526c69b85c460..1bfa289a52b4e1bc13944c5161baaf8b13b6d5e8 100644 (file)
@@ -1,5 +1,4 @@
 // error-pattern: the evaluated program aborted
-// ignore-windows (panics dont work on Windows)
 #![feature(unwind_attributes)]
 
 #[unwind(aborts)]
index 3085d0b006570ecbabe23b8225fb97d8cb225236..80d74f026232e44c09ea3a65640ce04e9422443e 100644 (file)
@@ -1,5 +1,4 @@
 // error-pattern: the evaluated program aborted
-// ignore-windows (panics dont work on Windows)
 
 struct Foo;
 impl Drop for Foo {
diff --git a/tests/compile-fail/panic/windows1.rs b/tests/compile-fail/panic/windows1.rs
deleted file mode 100644 (file)
index 142ba85..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-// ignore-linux
-// ignore-macos
-
-// Test that panics on Windows give a reasonable error message.
-
-// error-pattern: panicking is not supported on this target
-fn main() {
-    core::panic!("this is {}", "Windows");
-}
diff --git a/tests/compile-fail/panic/windows2.rs b/tests/compile-fail/panic/windows2.rs
deleted file mode 100644 (file)
index da2cfb5..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-// ignore-linux
-// ignore-macos
-
-// Test that panics on Windows give a reasonable error message.
-
-// error-pattern: panicking is not supported on this target
-fn main() {
-    std::panic!("this is Windows");
-}
diff --git a/tests/compile-fail/panic/windows3.rs b/tests/compile-fail/panic/windows3.rs
deleted file mode 100644 (file)
index a2e7bf5..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// ignore-linux
-// ignore-macos
-
-// Test that panics on Windows give a reasonable error message.
-
-// error-pattern: panicking is not supported on this target
-#[allow(unconditional_panic)]
-fn main() {
-    let _val = 1/0;
-}
index 288ae1965a69d2f1e4b560d73fbacd5d66fcc7fa..ac41de586e8a7adb08ccce1a57ffa9908204e3eb 100644 (file)
@@ -1,7 +1,7 @@
-// ignore-windows: Unwind panicking does not currently work on Windows
 // normalize-stderr-test "[^ ]*libcore/[a-z/]+.rs[0-9:]*" -> "$$LOC"
 #![feature(never_type)]
 #![allow(unconditional_panic)]
+
 use std::panic::{catch_unwind, AssertUnwindSafe};
 use std::cell::Cell;
 
index cfacc9db0d666b70c4a583666e7adc4b81b2b64a..fac5415696fc675e9f9ddfb5241daf954957b6de 100644 (file)
@@ -1,4 +1,3 @@
-// ignore-windows: Unwind panicking does not currently work on Windows
 #![allow(unconditional_panic)]
 
 fn main() {
index 77dca2aac1e289715f0f8db4b30744320182782b..d255811be2a94dd04ba9d1d6b4445088d80844bb 100644 (file)
@@ -1 +1 @@
-thread 'main' panicked at 'attempt to divide by zero', $DIR/div-by-zero-2.rs:5:14
+thread 'main' panicked at 'attempt to divide by zero', $DIR/div-by-zero-2.rs:4:14
index ee15ca0284ef3dc9432be9b1c8d9a99a49a35921..bf5eed1c550f1b1b4f81491454e2825a5e8e6f28 100644 (file)
@@ -1,4 +1,3 @@
-// ignore-windows: Unwind panicking does not currently work on Windows
 #![allow(arithmetic_overflow)]
 
 fn main() {
index e1e7daa119abd7767330728d099897b3879ca974..04d98a0a2f155b767dc541b6081b6cc9564ccddc 100644 (file)
@@ -1 +1 @@
-thread 'main' panicked at 'attempt to shift left with overflow', $DIR/overflowing-lsh-neg.rs:5:14
+thread 'main' panicked at 'attempt to shift left with overflow', $DIR/overflowing-lsh-neg.rs:4:14
index 36ab948a5efa082289b977918b82b550cc87c6a0..4c0106f0fb1fd3bd7b9aa8d375f6f88c35ddbdbd 100644 (file)
@@ -1,4 +1,3 @@
-// ignore-windows: Unwind panicking does not currently work on Windows
 #![allow(arithmetic_overflow)]
 
 fn main() {
index 20a45739ae2e6a19434c04bf9f156d4ca2b5ca39..a9a72f46222df4d2fdebd036f2ac59d6a5c62296 100644 (file)
@@ -1 +1 @@
-thread 'main' panicked at 'attempt to shift right with overflow', $DIR/overflowing-rsh-1.rs:5:14
+thread 'main' panicked at 'attempt to shift right with overflow', $DIR/overflowing-rsh-1.rs:4:14
index 27cc65fa7685b4355c673ae90b3c5a74c92129a5..19d16e7bc84a2e3117977e7ec0b4bd03f894fa6a 100644 (file)
@@ -1,4 +1,3 @@
-// ignore-windows: Unwind panicking does not currently work on Windows
 #![allow(arithmetic_overflow)]
 
 fn main() {
index 3381116ae6c858133aea4277c84c030c2af8b603..24b61194565dd1230806f29167cf44856581a95a 100644 (file)
@@ -1 +1 @@
-thread 'main' panicked at 'attempt to shift right with overflow', $DIR/overflowing-rsh-2.rs:6:14
+thread 'main' panicked at 'attempt to shift right with overflow', $DIR/overflowing-rsh-2.rs:5:14
index 61321c658166f45baacd35da377bbf1c52e0c995..9d9ad28df5a710bfc205cb68a8b8024fa33dd277 100644 (file)
@@ -1,4 +1,3 @@
-// ignore-windows: Unwind panicking does not currently work on Windows
 fn main() {
     std::panic!("panicking from libstd");
 }
index 305fc1a1a6e669eb7f0d4cd8956cce68d84ad7c3..954b8799a082351c51f7f18e76dd35be0c2ef790 100644 (file)
@@ -1 +1 @@
-thread 'main' panicked at 'panicking from libstd', $DIR/panic1.rs:3:5
+thread 'main' panicked at 'panicking from libstd', $DIR/panic1.rs:2:5
index d6ab864795eafa169381f15d5419acae321a00dc..d90e3f2e0ac132433efac639f03569322869c305 100644 (file)
@@ -1,4 +1,3 @@
-// ignore-windows: Unwind panicking does not currently work on Windows
 fn main() {
     std::panic!("{}-panicking from libstd", 42);
 }
index cd40559c81ef1c94ece47c848f80b6db25e487d3..e90e3502cbfbf99515811e3fef3eae2843d2b338 100644 (file)
@@ -1 +1 @@
-thread 'main' panicked at '42-panicking from libstd', $DIR/panic2.rs:3:5
+thread 'main' panicked at '42-panicking from libstd', $DIR/panic2.rs:2:5
index 10a42c7e6c00f19fb385e2000a3dc13e42af8c27..418ee4f8411eb9472274a162b0ce0d8c43e6e273 100644 (file)
@@ -1,4 +1,3 @@
-// ignore-windows: Unwind panicking does not currently work on Windows
 fn main() {
     core::panic!("panicking from libcore");
 }
index e3aa902f0cbc9d57819d01ddf9e99bf1266256c2..0a3c191b282ec22c60fd72517033c15d78395d0d 100644 (file)
@@ -1 +1 @@
-thread 'main' panicked at 'panicking from libcore', $DIR/panic3.rs:3:5
+thread 'main' panicked at 'panicking from libcore', $DIR/panic3.rs:2:5
index 06e2dd008fff82e2e08fb0eb94d6eb1c7babfddc..0fcc53813b5d79dcb47edfc8a6ba51f1000b8732 100644 (file)
@@ -1,4 +1,3 @@
-// ignore-windows: Unwind panicking does not currently work on Windows
 fn main() {
     core::panic!("{}-panicking from libcore", 42);
 }
index 1a242a868cae19987253976f9b533fcb1372f605..946059b1e49fc5adb3b3ba8fbab626e8587ee49a 100644 (file)
@@ -1 +1 @@
-thread 'main' panicked at '42-panicking from libcore', $DIR/panic4.rs:3:5
+thread 'main' panicked at '42-panicking from libcore', $DIR/panic4.rs:2:5
index d5f38fc2672e7ed0b8e74d5627ba5a89b1a76c1c..ac2e8d5305dfef2c0935275988373dd18d1de8ac 100644 (file)
@@ -1,4 +1,3 @@
-// ignore-windows: Unwind panicking does not currently work on Windows
 #![feature(option_expect_none, option_unwrap_none)]
 //! Test that panic locations for `#[track_caller]` functions in std have the correct
 //! location reported.
index c667aab6bb5fdbd1f478b6f9a3dc8ebd401e1cc8..3dff2cc1e0c9300d3b013af52375f0425758ffd6 100644 (file)
@@ -1,4 +1,3 @@
-// ignore-windows: Unwind panicking does not currently work on Windows
 fn main() {
     #[cfg(target_pointer_width="64")]
     let bad = unsafe {
index 2539e58814d6b833010b59851b04516f1757cd33..08849a5b517a4e9e3a9fa6dd90e9879f4dedfdbe 100644 (file)
@@ -1 +1 @@
-thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', $DIR/transmute_fat2.rs:12:5
+thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', $DIR/transmute_fat2.rs:11:5