rust/compiler
bors b5c37e86ff Auto merge of #78801 - sexxi-goose:min_capture, r=nikomatsakis
RFC-2229: Implement Precise Capture Analysis

### This PR introduces
- Feature gate for RFC-2229 (incomplete) `capture_disjoint_field`
- Rustc Attribute to print out the capture analysis `rustc_capture_analysis`
- Precise capture analysis

### Description of the analysis
1. If the feature gate is not set then all variables that are not local to the closure will be added to the list of captures. (This is for backcompat)
2. The rest of the analysis is based entirely on how the captured `Place`s are used within the closure. Precise information (i.e. projections) about the `Place` is maintained throughout.
3. To reduce the amount of information we need to keep track of, we do a minimization step. In this step, we determine a list such that no Place within this list represents an ancestor path to another entry in the list.  Check rust-lang/project-rfc-2229#9 for more detailed examples.
4. To keep the compiler functional as before we implement a Bridge between the results of this new analysis to existing data structures used for closure captures. Note the new capture analysis results are only part of MaybeTypeckTables that is the information is only available during typeck-ing.

### Known issues
- Statements like `let _ = x` will make the compiler ICE when used within a closure with the feature enabled. More generally speaking the issue is caused by `let` statements that create no bindings and are init'ed using a Place expression.

### Testing
We removed the code that would handle the case where the feature gate is not set, to enable the feature as default and did a bors try and perf run. More information here: #78762

### Thanks
This has been slowly in the works for a while now.
I want to call out `@Azhng` `@ChrisPardy` `@null-sleep` `@jenniferwills` `@logmosier` `@roxelo` for working on this and the previous PRs that led up to this, `@nikomatsakis` for guiding us.

Closes rust-lang/project-rfc-2229#7
Closes rust-lang/project-rfc-2229#9
Closes rust-lang/project-rfc-2229#6
Closes rust-lang/project-rfc-2229#19

r? `@nikomatsakis`
2020-11-17 03:56:03 +00:00
..
rustc just max_level_info 2020-09-11 09:37:51 -07:00
rustc_apfloat Backport another LLVM commit to rustc_apfloat 2020-10-04 02:02:25 +02:00
rustc_arena Fix even more clippy warnings 2020-10-30 10:13:39 -04:00
rustc_ast Rollup merge of #79016 - fanzier:underscore-expressions, r=petrochenkov 2020-11-15 13:39:48 +01:00
rustc_ast_lowering Rollup merge of #79016 - fanzier:underscore-expressions, r=petrochenkov 2020-11-15 13:39:48 +01:00
rustc_ast_passes Add underscore expressions for destructuring assignments 2020-11-14 13:53:12 +00:00
rustc_ast_pretty Rollup merge of #79016 - fanzier:underscore-expressions, r=petrochenkov 2020-11-15 13:39:48 +01:00
rustc_attr Improve deprecation attribute diagnostic messages. 2020-11-02 13:21:18 +01:00
rustc_builtin_macros Rollup merge of #79005 - petrochenkov:noinjected, r=davidtwco 2020-11-15 13:39:46 +01:00
rustc_codegen_cranelift update cg_clif 2020-11-16 22:42:09 +01:00
rustc_codegen_llvm compiler: fold by value 2020-11-16 22:34:57 +01:00
rustc_codegen_ssa compiler: fold by value 2020-11-16 22:34:57 +01:00
rustc_data_structures words 2020-11-16 22:42:09 +01:00
rustc_driver Rollup merge of #79005 - petrochenkov:noinjected, r=davidtwco 2020-11-15 13:39:46 +01:00
rustc_error_codes Update E0744 about control flow in const contexts to reflect the current status of const fn. 2020-11-16 09:30:29 -06:00
rustc_errors Auto merge of #76931 - oli-obk:const_prop_inline_lint_madness, r=wesleywiser 2020-11-03 16:32:34 +00:00
rustc_expand Rollup merge of #78836 - fanzier:struct-and-slice-destructuring, r=petrochenkov 2020-11-12 19:46:09 +01:00
rustc_feature Auto merge of #78801 - sexxi-goose:min_capture, r=nikomatsakis 2020-11-17 03:56:03 +00:00
rustc_fs_util Remove unused code from remaining compiler crates 2020-10-14 04:14:32 +02:00
rustc_graphviz Rust coverage before splitting instrument_coverage.rs 2020-11-05 18:24:12 -08:00
rustc_hir improve error message for const ty param mismatch 2020-11-16 16:07:59 +01:00
rustc_hir_pretty Fix even more clippy warnings 2020-10-30 10:13:39 -04:00
rustc_incremental Allow making RUSTC_BOOTSTRAP conditional on the crate name 2020-11-07 13:45:11 -05:00
rustc_index cache types during normalization 2020-09-19 17:27:13 +02:00
rustc_infer words 2020-11-16 22:42:09 +01:00
rustc_interface Rollup merge of #78714 - m-ou-se:simplify-local-streams, r=KodrAus 2020-11-16 17:26:27 +01:00
rustc_lexer Add back missing comments 2020-10-30 10:13:41 -04:00
rustc_lint compiler: fold by value 2020-11-16 22:34:57 +01:00
rustc_lint_defs Rollup merge of #78114 - jyn514:private, r=oli-obk 2020-11-09 01:13:31 +01:00
rustc_llvm fully exploited the dropped support of LLVM 8 2020-11-12 14:39:47 +01:00
rustc_macros compiler: fold by value 2020-11-16 22:34:57 +01:00
rustc_metadata Push to result vector instead of allocating 2020-11-13 11:19:25 +01:00
rustc_middle Auto merge of #78801 - sexxi-goose:min_capture, r=nikomatsakis 2020-11-17 03:56:03 +00:00
rustc_mir Auto merge of #78801 - sexxi-goose:min_capture, r=nikomatsakis 2020-11-17 03:56:03 +00:00
rustc_mir_build Auto merge of #78801 - sexxi-goose:min_capture, r=nikomatsakis 2020-11-17 03:56:03 +00:00
rustc_parse Rollup merge of #79016 - fanzier:underscore-expressions, r=petrochenkov 2020-11-15 13:39:48 +01:00
rustc_parse_format /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
rustc_passes Auto merge of #78801 - sexxi-goose:min_capture, r=nikomatsakis 2020-11-17 03:56:03 +00:00
rustc_plugin_impl /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
rustc_privacy Fix even more URLs 2020-11-05 20:11:29 +01:00
rustc_query_system Fix even more clippy warnings 2020-10-30 10:13:39 -04:00
rustc_resolve Rollup merge of #79034 - petrochenkov:mrscopes3, r=eddyb 2020-11-15 13:39:57 +01:00
rustc_save_analysis Rollup merge of #78352 - JohnTitor:issue-75229, r=Dylan-DPC 2020-11-15 03:02:34 +01:00
rustc_serialize Replace absolute paths with relative ones 2020-10-13 14:16:45 +02:00
rustc_session Rollup merge of #79005 - petrochenkov:noinjected, r=davidtwco 2020-11-15 13:39:46 +01:00
rustc_span Auto merge of #78801 - sexxi-goose:min_capture, r=nikomatsakis 2020-11-17 03:56:03 +00:00
rustc_symbol_mangling compiler: fold by value 2020-11-16 22:34:57 +01:00
rustc_target Rollup merge of #78993 - petrochenkov:specdash, r=oli-obk 2020-11-15 03:02:59 +01:00
rustc_trait_selection words 2020-11-16 22:42:09 +01:00
rustc_traits compiler: fold by value 2020-11-16 22:34:57 +01:00
rustc_ty compiler: fold by value 2020-11-16 22:34:57 +01:00
rustc_typeck Auto merge of #78801 - sexxi-goose:min_capture, r=nikomatsakis 2020-11-17 03:56:03 +00:00