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