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