rust/compiler/rustc_span/src
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
..
analyze_source_file mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
source_map mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
symbol mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
analyze_source_file.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
caching_source_map_view.rs rustc_span: represent line bounds with Range 2020-10-27 15:47:29 -07:00
def_id.rs Add some docs to rustdoc::clean::inline and def_id functions 2020-10-06 09:46:00 +00:00
edition.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
fatal_error.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
hygiene.rs Show the inline stack of MIR lints that only occur after inlining 2020-10-27 14:08:07 +00:00
lib.rs Auto merge of #76256 - tgnottingham:issue-74890, r=nikomatsakis 2020-11-12 15:34:09 +00:00
source_map.rs Use RwLock instead of Lock for SourceMap::files 2020-10-29 18:09:53 +01:00
span_encoding.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
symbol.rs Indroduce feature flag for RFC-2229 2020-11-10 20:58:28 -05:00
tests.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00