rust/compiler/rustc_metadata/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
..
dynamic_lib mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
rmeta Auto merge of #88759 - Amanieu:panic_in_drop, r=nagisa,eddyb 2021-09-12 20:48:09 +00:00
creader.rs Remove unused argument from resolve_crate 2021-09-02 12:25:27 +02:00
dependency_format.rs Ensure that crates are linked with compatible panic-in-drop settings 2021-09-11 16:13:30 +01:00
dynamic_lib.rs Use #[non_exhaustive] where appropriate 2021-06-24 04:16:11 -04:00
foreign_modules.rs Only store a LocalDefId in hir::ForeignItem. 2021-02-15 19:32:29 +01:00
lib.rs Auto merge of #85910 - cjgillot:no-meta-version, r=Aaron1011 2021-06-10 00:39:25 +00:00
locator.rs Add help for E0463 2021-09-10 21:36:09 +02:00
native_libs.rs Remove Session.used_attrs and move logic to CheckAttrVisitor 2021-08-21 13:27:27 -05:00