Uh oh!
There was an error while loading. Please reload this page.
Add explanations and suggestions to irrefutable_let_patterns lint - #79747
Conversation
rust-highfive
commented
Dec 5, 2020
r? @varkor (rust-highfive has picked a reviewer for you, use r? to override) |
camelid
commented
Dec 5, 2020
Ugh, |
ehuss
commented
Dec 5, 2020
My preference would be to not add one-off links like this. Ideally, every warning should (automatically) have some way to get more information. The issue is that it is not clear exactly what that should look like. Some options that were considered:
There is some history in #48041 and #48337 about trying to reduce the verbosity with |
I based this off of errors like: but if we want to wait for a unified approach before adding more, I'm okay with that. And I have another Con to add to using HTTP links: we currently don't check links produced in error messages, so they're prone to link rot. |
camelid
commented
Dec 5, 2020
Another example: |
varkor
commented
Dec 8, 2020
I think we ought to link to the stable version of the documentation (or, even better, to the relevant version). But that aside, it seems like a link to the documentation is not the best fix for this issue. We should be suggesting the user change the |
dd64a71 to
c3367abComparecamelid
commented
Jan 12, 2021
Starting with a rebase. |
This comment has been minimized.
This comment has been minimized.
c3367ab to
2b00f81Comparecamelid
commented
Jan 12, 2021
@varkor How does this look: ? I added similar notes and suggestions to if-let and if-let guard as well. Ideally they would be structured suggestions, but I think it would be tricky to recover the span information. Also, these aren't mechanical fixes which makes them more difficult to automate and not as useful to users. |
camelid
commented
Jan 12, 2021
Note that the current output uses |
irrefutable_let_patterns lint
This comment has been minimized.
This comment has been minimized.
2b00f81 to
dc9215dCompareUh oh!
There was an error while loading. Please reload this page.
varkor
commented
Jan 16, 2021
Yes, that's true. This is definitely an improvement as-is. |
camelid
commented
Jan 16, 2021
(I think I need to bless tests from the error message change.) |
This comment has been minimized.
This comment has been minimized.
camelid
commented
Jan 17, 2021
I can squash before you |
There was a problem hiding this comment.
| diag.help("consider replacing the if-let with a let"); | |
| diag.help("consider replacing the if-let with a `let`"); |
I wonder whether it would be more readable to write
| diag.help("consider replacing the if-let with a let"); | |
| diag.help("consider replacing the `if let` with a `let`"); |
as well.
There was a problem hiding this comment.
I intentionally removed the backticks on let to be consistent with if-let. I thought of doing the second option you suggest, but didn't because then it would be inconsistent with the error message. I'm still open to it, I just want to make sure we don't confuse people. What do you think?
There was a problem hiding this comment.
I'd be tempted to replace if-let with `if let` in general (including in the main error message). To me, it's slightly easier to read, and feels more consistent with other uses of code fragments in error messages.
There was a problem hiding this comment.
I like the look of if-let, though I do think it's probably clearer as `if let`. However, it seems like if-let and the like are used a lot, not just in the compiler but also in documentation. So can we do that as a separate change so this one doesn't wallow too long?
There was a problem hiding this comment.
That works (as long as we don't overlook that let needs to be enclosed in backticks in the message above as well).
varkor
commented
Feb 17, 2021
r=me after squashing. |
camelid
commented
Feb 17, 2021
Also: blocked on #82215 (not adding S-blocked since that PR will merge very soon). |
9bbd3fb to
9eba9c8Comparecamelid
commented
Feb 18, 2021
Starting with a squash to make the rebase easier (and since I need to anyway). |
9eba9c8 to
7baf39dComparecamelid
commented
Feb 18, 2021
Rebased. Ready for review! |
This comment has been minimized.
This comment has been minimized.
7baf39d to
2f2653fCompare
This comment has been minimized.
This comment has been minimized.
2f2653f to
5d2a2a1Comparevarkor
commented
Feb 19, 2021
Thanks, looks good! @bors r+ |
bors
commented
Feb 19, 2021
📌 Commit 5d2a2a1 has been approved by |
Rollup of 10 pull requests Successful merges: - rust-lang#79747 (Add explanations and suggestions to `irrefutable_let_patterns` lint) - rust-lang#81496 (name async generators something more human friendly in type error diagnostic) - rust-lang#81873 (Add Mutex::unlock) - rust-lang#82093 (Add tests for Atomic*::fetch_{min,max}) - rust-lang#82238 (ast: Keep expansion status for out-of-line module items) - rust-lang#82245 (Do not ICE when evaluating locals' types of invalid `yield`) - rust-lang#82259 (Fix popping singleton paths in when generating E0433) - rust-lang#82261 (rustdoc: Support argument files) - rust-lang#82274 (libtest: Fix unwrap panic on duplicate TestDesc) - rust-lang#82275 (Update cargo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes#79716.