rust/compiler/rustc_session/src
bors 51e514c0fb Auto merge of #88759 - Amanieu:panic_in_drop, r=nagisa,eddyb
Add -Z panic-in-drop={unwind,abort} command-line option

This PR changes `Drop` to abort if an unwinding panic attempts to escape it, making the process abort instead. This has several benefits:
- The current behavior when unwinding out of `Drop` is very unintuitive and easy to miss: unwinding continues, but the remaining drops in scope are simply leaked.
- A lot of unsafe code doesn't expect drops to unwind, which can lead to unsoundness:
  - https://github.com/servo/rust-smallvec/issues/14
  - https://github.com/bluss/arrayvec/issues/3
- There is a code size and compilation time cost to this: LLVM needs to generate extra landing pads out of all calls in a drop implementation. This can compound when functions are inlined since unwinding will then continue on to process drops in the callee, which can itself unwind, etc.
  - Initial measurements show a 3% size reduction and up to 10% compilation time reduction on some crates (`syn`).

One thing to note about `-Z panic-in-drop=abort` is that *all* crates must be built with this option for it to be sound since it makes the compiler assume that dropping `Box<dyn Any>` will never unwind.

cc https://github.com/rust-lang/lang-team/issues/97
2021-09-12 20:48:09 +00:00
..
cgu_reuse_tracker.rs Make Diagnostic::span_fatal unconditionally raise an error 2021-05-08 23:12:04 -04:00
code_stats.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
config.rs Stabilize force-warn 2021-08-24 11:19:55 -04:00
filesearch.rs Adjust target search algorithm for rustlib path 2021-05-10 19:15:19 +03:00
lib.rs Query-ify global limit attribute handling 2021-07-04 12:33:14 -05:00
options.rs Auto merge of #88759 - Amanieu:panic_in_drop, r=nagisa,eddyb 2021-09-12 20:48:09 +00:00
output.rs Use command line metadata path if provided 2021-05-28 22:24:24 -07:00
parse.rs Use multispan suggestions more often 2021-07-30 09:26:31 -07:00
search_paths.rs use strip_prefix over starts_with and manual slicing based on pattern length (clippy::manual_strip) 2020-09-17 10:13:16 +02:00
session.rs Revert "Remove optimization_fuel_crate from Session" 2021-09-08 17:36:41 +02:00
utils.rs Implement RFC 2951: Native link modifiers 2021-05-05 16:04:25 -07:00