-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tweak if let
suggestion to be more liberal with suggestion and to not ICE
#77283
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
Applicability::MaybeIncorrect, | ||
); | ||
} | ||
let (mut msg, applicability, eq) = if self.can_coerce(rhs_ty, lhs_ty) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, so the ordering switched from left/right to right/left here, which (IIRC) with coercion is quite significant. Was that intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the expression we want to take as "ground truth" to detect if foo = bar
when if let foo = bar
was meant is the rhs
.
The ICE is in the beta now. |
Niko indicated that the flip in coercion order was likely fine during the last meeting -- @estebank, would you be up for squashing the commits here a bit? Ideally I'd prefer to avoid 4 commits for such a small and dense change :) r=me though. |
@Mark-Simulacrum done. |
@bors r+ Thanks! |
📌 Commit cabf6d0 has been approved by |
…crum Tweak `if let` suggestion to be more liberal with suggestion and to not ICE Fix rust-lang#77218. Fix rust-lang#77238.
…crum Tweak `if let` suggestion to be more liberal with suggestion and to not ICE Fix rust-lang#77218. Fix rust-lang#77238.
☀️ Test successful - checks-actions |
…ulacrum [beta] backports This backports a number of PRs to beta: * Add delay_span_bug to no longer ICE rust-lang#78645 * Do not ICE on invalid input rust-lang#78422 * revert rust-lang#75443, update mir validator rust-lang#78410 * Do not try to report on closures to avoid ICE rust-lang#78268 * Disable "optimization to avoid load of address" in InstCombine rust-lang#78195 * Disable MatchBranchSimplification rust-lang#78151 * Do not ICE with TraitPredicates containing [type error] rust-lang#77930 * Tweak `if let` suggestion to be more liberal with suggestion and to not ICE rust-lang#77283 * Use different mirror for linux headers in musl-toolchain CI script. rust-lang#78316
…ing, r=petrochenkov Implement destructuring assignment for structs and slices This is the second step towards implementing destructuring assignment (RFC: rust-lang/rfcs#2909, tracking issue: rust-lang#71126). This PR is the second part of rust-lang#71156, which was split up to allow for easier review. Note that the first PR (rust-lang#78748) is not merged yet, so it is included as the first commit in this one. I thought this would allow the review to start earlier because I have some time this weekend to respond to reviews. If `@petrochenkov` prefers to wait until the first PR is merged, I totally understand, of course. This PR implements destructuring assignment for (tuple) structs and slices. In order to do this, the following *parser change* was necessary: struct expressions are not required to have a base expression, i.e. `Struct { a: 1, .. }` becomes legal (in order to act like a struct pattern). Unfortunately, this PR slightly regresses the diagnostics implemented in rust-lang#77283. However, it is only a missing help message in `src/test/ui/issues/issue-77218.rs`. Other instances of this diagnostic are not affected. Since I don't exactly understand how this help message works and how to fix it yet, I was hoping it's OK to regress this temporarily and fix it in a follow-up PR. Thanks to `@varkor` who helped with the implementation, particularly around the struct rest changes. r? `@petrochenkov`
…ing, r=petrochenkov Implement destructuring assignment for structs and slices This is the second step towards implementing destructuring assignment (RFC: rust-lang/rfcs#2909, tracking issue: rust-lang#71126). This PR is the second part of rust-lang#71156, which was split up to allow for easier review. Note that the first PR (rust-lang#78748) is not merged yet, so it is included as the first commit in this one. I thought this would allow the review to start earlier because I have some time this weekend to respond to reviews. If ``@petrochenkov`` prefers to wait until the first PR is merged, I totally understand, of course. This PR implements destructuring assignment for (tuple) structs and slices. In order to do this, the following *parser change* was necessary: struct expressions are not required to have a base expression, i.e. `Struct { a: 1, .. }` becomes legal (in order to act like a struct pattern). Unfortunately, this PR slightly regresses the diagnostics implemented in rust-lang#77283. However, it is only a missing help message in `src/test/ui/issues/issue-77218.rs`. Other instances of this diagnostic are not affected. Since I don't exactly understand how this help message works and how to fix it yet, I was hoping it's OK to regress this temporarily and fix it in a follow-up PR. Thanks to ``@varkor`` who helped with the implementation, particularly around the struct rest changes. r? ``@petrochenkov``
The diagnostics implemented here regressed slightly due to my PR #78836. In the file if Some(3) = foo {} is lowered to if { let Some(_x) = foo; 3 = _x } {} Hence the code of this PR doesn't recognize it as something where I'm not sure how to best fix this, so pinging @estebank in case he wants to look into this. |
@fanzier thank you for the heads up :( |
…ing, r=petrochenkov Implement destructuring assignment for structs and slices This is the second step towards implementing destructuring assignment (RFC: rust-lang/rfcs#2909, tracking issue: rust-lang#71126). This PR is the second part of rust-lang#71156, which was split up to allow for easier review. Note that the first PR (rust-lang#78748) is not merged yet, so it is included as the first commit in this one. I thought this would allow the review to start earlier because I have some time this weekend to respond to reviews. If ``@petrochenkov`` prefers to wait until the first PR is merged, I totally understand, of course. This PR implements destructuring assignment for (tuple) structs and slices. In order to do this, the following *parser change* was necessary: struct expressions are not required to have a base expression, i.e. `Struct { a: 1, .. }` becomes legal (in order to act like a struct pattern). Unfortunately, this PR slightly regresses the diagnostics implemented in rust-lang#77283. However, it is only a missing help message in `src/test/ui/issues/issue-77218.rs`. Other instances of this diagnostic are not affected. Since I don't exactly understand how this help message works and how to fix it yet, I was hoping it's OK to regress this temporarily and fix it in a follow-up PR. Thanks to ``@varkor`` who helped with the implementation, particularly around the struct rest changes. r? ``@petrochenkov``
Fix #77218. Fix #77238.