summary refs log tree commit diff
path: root/compiler/rustc_mir_build/src
AgeCommit message (Collapse)AuthorLines
2021-02-05Auto merge of #81257 - ↵bors-295/+158
pnkfelix:issue-80949-short-term-resolution-via-revert-of-pr-78373, r=matthewjasper Revert 78373 ("dont leak return value after panic in drop") Short term resolution for issue #80949. Reopen #47949 after this lands. (We plan to fine-tune PR #78373 to not run into this problem.)
2020-12-22Fix a commentNadrieril-4/+4
2020-12-22Apply suggestions from code reviewNadrieril-14/+15
Co-authored-by: varkor <github@varkor.com>
2020-12-22Simplify field filteringNadrieril-64/+56
2020-12-22Make the special "missing patterns" constructor realNadrieril-64/+57
2020-12-22Completely rework the explanation of the algorithmNadrieril-285/+324
2020-12-22Pass `Matrix` explicitly instead of via `PatCtxt`Nadrieril-27/+48
2020-12-22Inline the constructor-specific `split` functionsNadrieril-34/+19
2020-12-22Inline `all_constructors`Nadrieril-121/+115
2020-12-22Rebrand `MissingConstructors` as `SplitWildcard`Nadrieril-49/+67
2020-12-22Factor out `SplitVarLenSlice` used for slice splittingNadrieril-105/+117
2020-12-22Run the annoying lint separatelyNadrieril-54/+43
2020-12-22Factor out `SplitIntRange` used for integer range splittingNadrieril-89/+110
2020-12-22Auto merge of #78242 - Nadrieril:rename-overlapping_endpoints-lint, r=varkorbors-9/+9
Rename `overlapping_patterns` lint As discussed in https://github.com/rust-lang/rust/issues/65477. I also tweaked a few things along the way. r? `@varkor` `@rustbot` modify labels: +A-exhaustiveness-checking
2020-12-19Auto merge of #80104 - Nadrieril:usefulness-merging, r=varkorbors-114/+185
Improve and fix diagnostics of exhaustiveness checking Primarily, this fixes https://github.com/rust-lang/rust/issues/56379. This also fixes incorrect interactions between or-patterns and slice patterns that I discovered while working on #56379. Those two examples show the incorrect diagnostics: ```rust match &[][..] { [true] => {} [true // detected as unreachable but that's not true | false, ..] => {} _ => {} } match (true, None) { (true, Some(_)) => {} (false, Some(true)) => {} (true | false, None | Some(true // should be detected as unreachable | false)) => {} } ``` I did not measure any perf impact. However, I suspect that [`616ba9f`](https://github.com/rust-lang/rust/pull/80104/commits/616ba9f9f7f5845777a36e1a41a515e6c33a8776) should have a negative impact on large or-patterns. I'll see what the perf run says; I have optimization ideas up my sleeve if needed. EDIT: I initially had a noticeable perf impact that I thought unavoidable. I then proceeded to avoid it x) r? `@varkor` `@rustbot` label +A-exhaustiveness-checking
2020-12-19Tweak diagnosticsNadrieril-3/+2
2020-12-18Unify the two kinds of usefulness mergingNadrieril-63/+35
This is elegant but a bit of a perf gamble. That said, or-patterns rarely have many branches and it's easy to optimize or revert if we ever need to. In the meantime simpler code is worth it.
2020-12-18Merge unreachable subpatterns correctlyNadrieril-3/+28
2020-12-18Keep all witnesses of non-exhaustivenessNadrieril-27/+37
2020-12-18Rewrite usefulness merging using `SpanSet`Nadrieril-65/+114
`SpanSet` is heavily inspired from `DefIdForest`.
2020-12-18Log the output of `is_useful` in the or-pattern case tooNadrieril-25/+31
2020-12-18Factor out or-pattern usefulness mergingNadrieril-72/+81
2020-12-17Rollup merge of #79051 - LeSeulArtichaut:if-let-guard, r=matthewjasperYuki Okushi-13/+82
Implement if-let match guards Implements rust-lang/rfcs#2294 (tracking issue: #51114). I probably should do a few more things before this can be merged: - [x] Add tests (added basic tests, more advanced tests could be done in the future?) - [x] Add lint for exhaustive if-let guard (comparable to normal if-let statements) - [x] Fix clippy However since this is a nightly feature maybe it's fine to land this and do those steps in follow-up PRs. Thanks a lot `@matthewjasper` :heart: for helping me with lowering to MIR! Would you be interested in reviewing this? r? `@ghost` for now
2020-12-15Auto merge of #73210 - wesleywiser:consts_in_debuginfo, r=oli-obkbors-5/+5
[mir-opt] Allow debuginfo to be generated for a constant or a Place Prior to this commit, debuginfo was always generated by mapping a name to a Place. This has the side-effect that `SimplifyLocals` cannot remove locals that are only used for debuginfo because their other uses have been const-propagated. To allow these locals to be removed, we now allow debuginfo to point to a constant value. The `ConstProp` pass detects when debuginfo points to a local with a known constant value and replaces it with the value. This allows the later `SimplifyLocals` pass to remove the local.
2020-12-13Rollup merge of #79940 - matthiaskrgr:cl15ppy, r=Dylan-DPCYuki Okushi-2/+3
fix more clippy::complexity findings fix clippy::unnecessary_filter_map use if let Some(x) = .. instead of ...map(|x|) to conditionally run fns that return () (clippy::option_map_unit_fn) fix clippy::{needless_bool, manual_unwrap_or} don't clone types that are copy (clippy::clone_on_copy) don't convert types into identical types with .into() (clippy::useless_conversion) use strip_prefix over slicing (clippy::manual_strip) r? ``@Dylan-DPC``
2020-12-12Auto merge of #79553 - sexxi-goose:mir_min_cap_writeback, r=nikomatsakisbors-139/+420
Capture precise paths in THIR and MIR This PR allows THIR and MIR to use the result of the new capture analysis to actually capture precise paths To achieve we: - Writeback min capture results to TypeckResults - Move handling upvars to PlaceBuilder in mir_build - Lower precise paths in THIR build by reading min_captures - Search for ancestors in min_capture when trying to build a MIR place which starts off of an upvar Closes: https://github.com/rust-lang/project-rfc-2229/issues/10 Partly implements: rust-lang/project-rfc-2229#18 Work that remains (not in this PR): - [ ] [Known bugs when feature gate is enabled](https://github.com/rust-lang/project-rfc-2229/projects/1?card_filter_query=label%3Abug) - [ ] Use min_capure_map for - [ ] Liveness analysis - [ ] rustc_mir/interpret/validity.rs - [ ] regionck - [ ] rust-lang/project-rfc-2229#8 - [ ] remove closure_captures and upvar_capture_map r? `@ghost`
2020-12-11use if let Some(x) = .. instead of ...map(|x|) to conditionally run fns ↵Matthias Krüger-2/+3
that return () (clippy::option_map_unit_fn)
2020-12-09Use precise places when lowering Closures in THIRAman Arora-63/+109
- Closures now use closure_min_captures to figure out captured paths - Build upvar_mutbls using closure_min_captures - Change logic in limit_capture_mutability to differentiate b/w capturing parent's local variable or capturing a variable that is captured by the parent (in case of nested closure) using PlaceBase. Co-authored-by: Roxane Fruytier <roxane.fruytier@hotmail.com>
2020-12-09Use Places for captures in MIRAman Arora-22/+128
- Use closure_min_capture maps to capture precise paths - PlaceBuilder now searches for ancestors in min_capture list - Add API to `Ty` to allow access to the n-th element in a tuple in O(1) time. Co-authored-by: Roxane Fruytier <roxane.fruytier@hotmail.com>
2020-12-09Also generate `StorageDead` in constantsoli-41/+16
2020-12-06[mir-opt] Allow debuginfo to be generated for a constant or a PlaceWesley Wiser-5/+5
Prior to this commit, debuginfo was always generated by mapping a name to a Place. This has the side-effect that `SimplifyLocals` cannot remove locals that are only used for debuginfo because their other uses have been const-propagated. To allow these locals to be removed, we now allow debuginfo to point to a constant value. The `ConstProp` pass detects when debuginfo points to a local with a known constant value and replaces it with the value. This allows the later `SimplifyLocals` pass to remove the local.
2020-12-06Move handling UpvarRef to PlaceBuilderAman Arora-78/+207
- This allows us to delay figuring out the index of a capture in the closure structure when all projections to atleast form a capture have been applied to the builder Co-authored-by: Roxane Fruytier <roxane.fruytier@hotmail.com>
2020-12-06Retain assembly operands span when lowering AST to HIRTomasz Miąsko-1/+1
2020-12-06Implement lowering of if-let guards to MIRLeSeulArtichaut-10/+78
2020-12-06Introduce if-let guards in the THIRLeSeulArtichaut-4/+5
2020-12-04Avoid leaking block expression valuesMatthew Jasper-149/+288
2020-12-04Use `record_operands_moved` more aggresivelyMatthew Jasper-5/+17
2020-12-04Simplify unscheduling of drops after movesMatthew Jasper-30/+22
2020-12-04Inline `is_covered_by`Nadrieril-0/+2
2020-11-29Improve error messageNadrieril-3/+3
2020-11-29Be consistent about linting singletonsNadrieril-1/+1
2020-11-29Rename the `overlapping_patterns` lint to `overlapping_range_endpoints`Nadrieril-6/+7
2020-11-28Don't store `ty` and `span` in `IntRange`Nadrieril-66/+56
We prefer to grab `ty` and `span` from `pcx`. This makes it consistent with other constructors.
2020-11-28Correctly detect `usize`/`isize` range overlapsNadrieril-29/+12
2020-11-27Rename `_match` to `usefulness`Nadrieril-4/+4
2020-11-27Rename `pat_constructor` to `Constructor::from_pat`Nadrieril-63/+63
2020-11-27Move the definitions of the two `Ctxt`s to the topNadrieril-47/+46
2020-11-27Extract everything related to pattern deconstruction to a new moduleNadrieril-1387/+1413
2020-11-27No need to expose `Matrix` internalsNadrieril-1/+6
2020-11-27Disentangle `Fields` and `PatStack`Nadrieril-17/+16