Skip to content
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

Make diagnostics clearer for ? operators #86382

Merged
merged 1 commit into from
Sep 17, 2021
Merged

Conversation

JohnTitor
Copy link
Member

Re-submission of #75029, fixes #71309
This also revives the content methods removed by #83185.
r? @estebank

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 16, 2021
Copy link
Contributor

@estebank estebank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+ on all the changes but the one to the suggestion.

Comment on lines 8 to 11
help: you can convert an `i32` to a `u32` and panic if the converted value doesn't fit
|
LL | let y: u32 = x.try_into().unwrap();
| ^^^^^^^^^^^^^^^^^^^^^
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason this suggestion is fine in stable and nightly, but it isn't here.

Comment on lines 868 to 870
// #71309: `src` may contain `?` at the end, trim it
// as it makes suggestions incorrect.
let suggestion = format!(
"{}{}.try_into().unwrap()",
prefix,
with_opt_paren(&src).trim_end_matches('?')
);
(expr.span, msg, suggestion)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! I see. That trim_end_matches is incorrect. The case I mentioned is supposed to suggest x?.try_into().unwrap(), but this "blind" removal of the trailing ? is getting rid of it. Do we have a test where the removal of the ? is correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, somehow I misunderstood your previous review comment (#75029 (comment)), fixed.

@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 6, 2021
@camelid camelid added the A-diagnostics Area: Messages for errors, warnings, and lints label Jul 23, 2021
@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 15, 2021
@bors
Copy link
Contributor

bors commented Aug 16, 2021

☔ The latest upstream changes (presumably #80357) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Contributor

@estebank estebank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me after rebase

@inquisitivecrystal inquisitivecrystal added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 24, 2021
@jackh726 jackh726 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 9, 2021
@JohnTitor
Copy link
Member Author

@bors r=estebank

@bors
Copy link
Contributor

bors commented Sep 17, 2021

📌 Commit 378300a has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 17, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 17, 2021
Rollup of 10 pull requests

Successful merges:

 - rust-lang#86382 (Make diagnostics clearer for `?` operators)
 - rust-lang#87529 (Fix ICE in `improper_ctypes_definitions` lint with all-ZST transparent types)
 - rust-lang#88339 (Add TcpListener::into_incoming and IntoIncoming)
 - rust-lang#88735 (Don't lint about missing code examples in derived traits)
 - rust-lang#88751 (Couple of changes to FileSearch and SearchPath)
 - rust-lang#88883 (Move some tests to more reasonable directories - 7)
 - rust-lang#88887 (Const Deref)
 - rust-lang#88911 (Improve error message for type mismatch in generator arguments)
 - rust-lang#89014 (PassWrapper: handle separate Module*SanitizerPass)
 - rust-lang#89033 (Set the library path in sysroot-crates-are-unstable)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit f4f7704 into rust-lang:master Sep 17, 2021
@rustbot rustbot added this to the 1.57.0 milestone Sep 17, 2021
@JohnTitor JohnTitor deleted the try-desugar branch September 17, 2021 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"try expression alternatives have incompatible types" is confusing wording
9 participants