summary refs log tree commit diff
path: root/compiler/rustc_mir_build/src
AgeCommit message (Collapse)AuthorLines
2020-12-10Fix exhaustiveness in case a byte string literal is used at slice typeoli-8/+36
2020-11-09Rollup merge of #78748 - fanzier:tuple-assignment, r=petrochenkovDylan DPC-0/+1
Implement destructuring assignment for tuples This is the first step towards implementing destructuring assignment (RFC: https://github.com/rust-lang/rfcs/pull/2909, tracking issue: #71126). This PR is the first part of #71156, which was split up to allow for easier review. Quick summary: This change allows destructuring the LHS of an assignment if it's a (possibly nested) tuple. It is implemented via a desugaring (AST -> HIR lowering) as follows: ```rust (a,b) = (1,2) ``` ... becomes ... ```rust { let (lhs0,lhs1) = (1,2); a = lhs0; b = lhs1; } ``` Thanks to `@varkor` who helped with the implementation, particularly around default binding modes. r? `@petrochenkov`
2020-11-07Implement destructuring assignment for tuplesFabian Zaiser-0/+1
Co-authored-by: varkor <github@varkor.com>
2020-11-07Rollup merge of #78167 - Nadrieril:fix-76836_, r=varkorYuki Okushi-34/+93
Fix unreachable sub-branch detection in or-patterns The previous implementation was too eager to avoid unnecessary "unreachable pattern" warnings. I feel more confident about this implementation than I felt about the previous one. Fixes https://github.com/rust-lang/rust/issues/76836. ``@rustbot`` modify labels: +A-exhaustiveness-checking
2020-11-06Auto merge of #77856 - GuillaumeGomez:automatic-links-lint, r=jyn514,ollie27bors-2/+2
Add non_autolinks lint Part of #77501. r? `@jyn514`
2020-11-05Emit lints in the order in which they occur in the file.Nadrieril-4/+5
2020-11-05Fix unreachable sub-branch detectionNadrieril-35/+93
This fixes https://github.com/rust-lang/rust/issues/76836
2020-11-05Fix even more URLsGuillaume Gomez-2/+2
2020-11-05Auto merge of #78638 - vn-ki:bindigs-after-at-issue-69971, r=oli-obkbors-0/+44
reverse binding order in matches to allow the subbinding of copyable fields in bindings after @ Fixes #69971 ### TODO - [x] Regression tests r? `@oli-obk`
2020-11-04`u128` truncation and sign extension are not just interpreter relatedoli-10/+9
2020-11-03review commentsVishnunarayan K I-10/+10
2020-11-03preserve bindings order for SomeVishnunarayan K I-5/+28
2020-11-02new fix method and update testsVishnunarayan K I-15/+23
2020-11-02reverse binding order in matches ...Vishnunarayan K I-1/+14
... to allow the subbinding of copyable fields in bindings after `@` Fixes #69971
2020-11-01Auto merge of #78553 - Nadrieril:fix-78549, r=varkorbors-32/+55
Fix #78549 Before #78430, this worked because `specialize_constructor` didn't actually care too much which constructor was passed to it unless needed. That PR however handles `&str` as a special case, and I did not anticipate patterns for the `&str` type other than string literals. I am not very confident there are not other similar oversights left, but hopefully only `&str` was different enough to break my assumptions. Fixes https://github.com/rust-lang/rust/issues/78549
2020-11-01The need for `Single` to cover `Unlistable` was a hackNadrieril-18/+13
It is now unneeded, since we handle `&str` patterns in a consistent way.
2020-11-01Fix #78549Nadrieril-16/+44
Before #78430, string literals worked because `specialize_constructor` didn't actually care too much which constructor was passed to it unless needed. Since then, string literals are special cased and a bit hacky. I did not anticipate patterns for the `&str` type other than string literals, hence this bug. This makes string literals less hacky.
2020-10-30Fix even more clippy warningsJoshua Nelson-55/+26
2020-10-29Auto merge of #78430 - Nadrieril:taking-constructors-seriously2, r=varkorbors-1143/+708
Clarify main code paths in exhaustiveness checking This PR massively clarifies the main code paths of exhaustiveness checking, by using the `Constructor` enum to a fuller extent. I've been itching to write it for more than a year, but the complexity of matching consts had prevented me. Behold a massive simplification :D. This in particular removes a fair amount of duplication between various parts, localizes code into methods of relevant types when applicable, makes some implicit assumptions explicit, and overall improves legibility a lot (or so I hope). Additionally, after my changes undoing #76918 turned out to be a noticeable perf gain. As usual I tried my best to make the commits self-contained and easy to follow. I've also tried to keep the code well-commented, but I tend to forget how complex this file is; I'm happy to clarify things as needed. My measurements show good perf improvements on the two match-heavy benchmarks (-18.0% on `unicode_normalization-check`! :D); I'd like a perf run to check the overall impact. r? `@varkor` `@rustbot` modify labels: +A-exhaustiveness-checking
2020-10-28Apply suggestions from code reviewNadrieril-23/+20
Co-authored-by: Who? Me?! <mark-i-m@users.noreply.github.com> Co-authored-by: varkor <github@varkor.com>
2020-10-27Add unsized_fn_params featureSantiago Pastorino-1/+1
2020-10-27Simplify slice splitting a bitNadrieril-41/+28
2020-10-27Deduplicate work between splitting and subtractionNadrieril-216/+87
After splitting, subtraction becomes much simpler
2020-10-27Be honest about being able to list constructorsNadrieril-33/+41
The test change is because we used to treat `&str` like other `&T`s, ie as having a single constructor. That's not quite true though since we consider `&str` constants as atomic instead of refs to `str` constants.
2020-10-27Simplify specialize_constructorNadrieril-175/+13
Also removes the ugly caching that was introduced in #76918. It was bolted on without deeper knowledge of the workings of the algorithm. This commit manages to be more performant without any of the complexity. It should be better on representative workloads too.
2020-10-27Unify the paths through `is_useful`Nadrieril-103/+53
2020-10-27Recompute `MissingConstructors` when neededNadrieril-39/+56
This only happens in a slow (diagnostics) path, so the code clarity gain is worth it.
2020-10-27Pass more things through `PatCtxt`Nadrieril-128/+75
This is even a perf improvement on the match-heavy benchmarks.
2020-10-27Let MissingConstructors handle the subtleties of missing constructorsNadrieril-89/+72
2020-10-27Cache head constructor in PatStackNadrieril-68/+63
Since the constructor is recomputed a lot, caching is worth it.
2020-10-27Unify the two kinds of specialization by adding a Wildcard ctorNadrieril-97/+80
2020-10-27Inline `specialize_one_pattern`Nadrieril-51/+39
2020-10-27Factor out the two specialization stepsNadrieril-80/+107
2020-10-27Clarify specialization into two stepsNadrieril-56/+48
First is checking for constructor overlap, second is extracting the resulting fields.
2020-10-27Use pat_constructor to simplify specialize_one_patternNadrieril-105/+71
2020-10-27Split `split_grouped_constructor` into smaller functionsNadrieril-329/+345
2020-10-27Rollup merge of #78377 - LeSeulArtichaut:patch-docs, r=jonas-schievinkYuki Okushi-1/+1
Fix typo in debug statement
2020-10-26Auto merge of #68965 - eddyb:mir-inline-scope, r=nagisa,oli-obkbors-1/+3
rustc_mir: track inlined callees in SourceScopeData. We now record which MIR scopes are the roots of *other* (inlined) functions's scope trees, which allows us to generate the correct debuginfo in codegen, similar to what LLVM inlining generates. This PR makes the `ui` test `backtrace-debuginfo` pass, if the MIR inliner is turned on by default. Also, `#[track_caller]` is now correct in the face of MIR inlining (cc `@anp).` Fixes #76997. r? `@rust-lang/wg-mir-opt`
2020-10-25Fix typo in debug statementLeSeulArtichaut-1/+1
2020-10-24Rollup merge of #78072 - Nadrieril:cleanup-constant-matching, r=varkorJonas Schievink-345/+126
Cleanup constant matching in exhaustiveness checking This supercedes https://github.com/rust-lang/rust/pull/77390. I made the `Opaque` constructor work. I have opened two issues https://github.com/rust-lang/rust/issues/78071 and https://github.com/rust-lang/rust/issues/78057 from the discussion we had on the previous PR. They are not regressions nor directly related to the current PR so I thought we'd deal with them separately. I left a FIXME somewhere because I didn't know how to compare string constants for equality. There might even be some unicode things that need to happen there. In the meantime I preserved previous behavior. EDIT: I accidentally fixed #78071
2020-10-24Rollup merge of #76614 - NoraCodes:nora/control_flow_enum, r=scottmcmJonas Schievink-1/+2
change the order of type arguments on ControlFlow This allows ControlFlow<BreakType> which is much more ergonomic for common iterator combinator use cases. Addresses one component of #75744
2020-10-23Rollup merge of #78098 - camelid:fixup-docs, r=steveklabnikYuki Okushi-8/+32
Clean up and improve some docs * compiler docs * Don't format list as part of a code block * Clean up some other formatting * rustdoc book * Update CommonMark spec version to latest (0.28 -> 0.29) * Clean up some various wording and formatting
2020-10-22Don't re-export std::ops::ControlFlow in the compiler.Leonora Tindall-1/+2
2020-10-21Clean up and improve some docsCamelid-8/+32
* compiler docs * Don't format list as part of a code block * Clean up some other formatting * rustdoc book * Update CommonMark spec version to latest (0.28 -> 0.29) * Clean up some various wording and formatting
2020-10-21Explain the `Opaque` special case in specializationNadrieril-1/+18
2020-10-21Fix formattingbishtpawan-6/+7
2020-10-21rustc_mir: support MIR-inlining #[track_caller] functions.Eduard-Mihai Burtescu-0/+1
2020-10-21rustc_mir: track inlined callees in SourceScopeData.Eduard-Mihai Burtescu-1/+2
2020-10-20Fix build failure of rustfmtbishtpawan-2/+3
2020-10-18Add commentNadrieril-0/+3