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