@@ -1197,37 +1197,6 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option<DefId>, abi: SpecAbi) ->
11971197 // ABIs have such an option. Otherwise the only other thing here is Rust
11981198 // itself, and those ABIs are determined by the panic strategy configured
11991199 // for this compilation.
1200- //
1201- // Unfortunately at this time there's also another caveat. Rust [RFC
1202- // 2945][rfc] has been accepted and is in the process of being implemented
1203- // and stabilized. In this interim state we need to deal with historical
1204- // rustc behavior as well as plan for future rustc behavior.
1205- //
1206- // Historically functions declared with `extern "C"` were marked at the
1207- // codegen layer as `nounwind`. This happened regardless of `panic=unwind`
1208- // or not. This is UB for functions in `panic=unwind` mode that then
1209- // actually panic and unwind. Note that this behavior is true for both
1210- // externally declared functions as well as Rust-defined function.
1211- //
1212- // To fix this UB rustc would like to change in the future to catch unwinds
1213- // from function calls that may unwind within a Rust-defined `extern "C"`
1214- // function and forcibly abort the process, thereby respecting the
1215- // `nounwind` attribute emitted for `extern "C"`. This behavior change isn't
1216- // ready to roll out, so determining whether or not the `C` family of ABIs
1217- // unwinds is conditional not only on their definition but also whether the
1218- // `#![feature(c_unwind)]` feature gate is active.
1219- //
1220- // Note that this means that unlike historical compilers rustc now, by
1221- // default, unconditionally thinks that the `C` ABI may unwind. This will
1222- // prevent some optimization opportunities, however, so we try to scope this
1223- // change and only assume that `C` unwinds with `panic=unwind` (as opposed
1224- // to `panic=abort`).
1225- //
1226- // Eventually the check against `c_unwind` here will ideally get removed and
1227- // this'll be a little cleaner as it'll be a straightforward check of the
1228- // ABI.
1229- //
1230- // [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md
12311200 use SpecAbi :: * ;
12321201 match abi {
12331202 C { unwind }
@@ -1239,10 +1208,7 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option<DefId>, abi: SpecAbi) ->
12391208 | Thiscall { unwind }
12401209 | Aapcs { unwind }
12411210 | Win64 { unwind }
1242- | SysV64 { unwind } => {
1243- unwind
1244- || ( !tcx. features ( ) . c_unwind && tcx. sess . panic_strategy ( ) == PanicStrategy :: Unwind )
1245- }
1211+ | SysV64 { unwind } => unwind,
12461212 PtxKernel
12471213 | Msp430Interrupt
12481214 | X86Interrupt
0 commit comments