rust/compiler/rustc_interface/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
..
callbacks.rs Add sanity check. 2021-09-10 20:18:26 +02:00
interface.rs Move OnDiskCache to rustc_query_impl. 2021-07-18 11:14:07 +02:00
lib.rs Don't use a generator for BoxedResolver 2021-06-08 19:24:17 +02:00
passes.rs Rename rustc_mir to rustc_const_eval. 2021-09-07 20:46:26 +02:00
proc_macro_decls.rs Use () for proc_macro_decls_static. 2021-05-12 13:58:43 +02:00
queries.rs Remove Session.used_attrs and move logic to CheckAttrVisitor 2021-08-21 13:27:27 -05:00
tests.rs Add -Z panic-in-drop={unwind,abort} command-line option 2021-09-09 18:57:03 +01:00
util.rs Detect bare blocks with type ascription that were meant to be a struct literal 2021-09-03 14:43:04 +00:00