diff options
| author | bors <bors@rust-lang.org> | 2021-04-14 15:35:33 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-04-14 15:35:33 +0000 |
| commit | 07ef25984549bc33adbdc402e977655d8c9093a7 (patch) | |
| tree | e5061c842a1e748904051d08789e89302ed1a2e0 | |
| parent | b203b0d240b67916cfa77f640aedaf1c87d50f6d (diff) | |
| parent | 3e16d233d85e0774c58c736e3ce5a939d3ef2817 (diff) | |
| download | rust-07ef25984549bc33adbdc402e977655d8c9093a7.tar.gz rust-07ef25984549bc33adbdc402e977655d8c9093a7.zip | |
Auto merge of #84158 - cratelyn:patch-extern-c-unwind-behavior, r=nikomatsakis
move new c abi abort behavior behind feature gate *Background* In #76570, new ABI strings including `C-unwind` were introduced. Their behavior is specified in RFC 2945 <sup>[1]</sup>. However, it was reported in the #ffi-unwind stream of the Rust community Zulip that this had altered the way that `extern "C"` functions behaved even when the `c_unwind` feature gate was not active. <sup>[2]</sup> *Overview* This makes a small patch to `rustc_mir_build::build::should_abort_on_panic`, so that the same behavior from before is in place when the `c_unwind` gate is not active. `rustc_middle::ty::layout::fn_can_unwind` is not touched, as the visible behavior should not differ before/after #76570. <sup>[3]</sup> --- 1: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md 2: https://rust-lang.zulipchat.com/#narrow/stream/210922-project-ffi-unwind/topic/Is.20unwinding.20through.20extern.20C.20UB.3F/near/230112325 3: https://github.com/rust-lang/rust/pull/76570/files#diff-b0320c2b8868f325d83c027fc5d71732636e9763551e35895488f30fe057c6e9L2599-R2617 [1]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md [2]: https://rust-lang.zulipchat.com/#narrow/stream/210922-project-ffi-unwind/topic/Is.20unwinding.20through.20extern.20C.20UB.3F/near/230112325 [3]: https://github.com/rust-lang/rust/pull/76570/files#diff-b0320c2b8868f325d83c027fc5d71732636e9763551e35895488f30fe057c6e9L2599-R2617
| -rw-r--r-- | compiler/rustc_mir_build/src/build/mod.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index 3a189e6b33d..f944e5f8f04 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -584,7 +584,7 @@ fn should_abort_on_panic(tcx: TyCtxt<'_>, fn_def_id: LocalDefId, abi: Abi) -> bo Some(UnwindAttr::Aborts) => true, // If no attribute was found and the panic strategy is `unwind`, then we should examine // the function's ABI string to determine whether it should abort upon panic. - None => { + None if tcx.features().c_unwind => { use Abi::*; match abi { // In the case of ABI's that have an `-unwind` equivalent, check whether the ABI @@ -615,6 +615,10 @@ fn should_abort_on_panic(tcx: TyCtxt<'_>, fn_def_id: LocalDefId, abi: Abi) -> bo | Unadjusted => true, } } + // If the `c_unwind` feature gate is not active, follow the behavior that was in place + // prior to #76570. This is a special case: some functions have a C ABI but are meant to + // unwind anyway. Don't stop them. + None => false, // FIXME(#58794); should be `!(abi == Abi::Rust || abi == Abi::RustCall)` } } |
