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

Add suggestions when encountering chained comparisons #68108

Merged
merged 1 commit into from
Jan 12, 2020

Conversation

varkor
Copy link
Member

@varkor varkor commented Jan 11, 2020

Ideally, we'd also prevent the type error, which is just extra noise, but that will require moving the error from the parser, and I think the suggestion makes things clear enough for now.

Fixes #65659.

@rust-highfive
Copy link
Collaborator

r? @matthewjasper

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 11, 2020
@varkor varkor force-pushed the chained-comparison-suggestions branch from 2ac4602 to 21f8ac2 Compare January 11, 2020 00:35
src/librustc_parse/parser/expr.rs Show resolved Hide resolved
src/librustc_parse/parser/diagnostics.rs Outdated Show resolved Hide resolved
src/librustc_parse/parser/diagnostics.rs Outdated Show resolved Hide resolved
src/test/ui/parser/chained-comparison-suggestion.rs Outdated Show resolved Hide resolved
@Centril
Copy link
Contributor

Centril commented Jan 11, 2020

r? @Centril

r=me with comments addressed.

@rust-highfive

This comment has been minimized.

@Centril Centril 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 Jan 11, 2020
@varkor varkor force-pushed the chained-comparison-suggestions branch from 21f8ac2 to 088a180 Compare January 11, 2020 01:55
@varkor
Copy link
Member Author

varkor commented Jan 11, 2020

@bors r=Centril

@bors
Copy link
Contributor

bors commented Jan 11, 2020

📌 Commit 088a180 has been approved by Centril

@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 Jan 11, 2020
Centril added a commit to Centril/rust that referenced this pull request Jan 11, 2020
…ns, r=Centril

Add suggestions when encountering chained comparisons

Ideally, we'd also prevent the type error, which is just extra noise, but that will require moving the error from the parser, and I think the suggestion makes things clear enough for now.

Fixes rust-lang#65659.
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jan 11, 2020
…ns, r=Centril

Add suggestions when encountering chained comparisons

Ideally, we'd also prevent the type error, which is just extra noise, but that will require moving the error from the parser, and I think the suggestion makes things clear enough for now.

Fixes rust-lang#65659.
Centril added a commit to Centril/rust that referenced this pull request Jan 12, 2020
…ns, r=Centril

Add suggestions when encountering chained comparisons

Ideally, we'd also prevent the type error, which is just extra noise, but that will require moving the error from the parser, and I think the suggestion makes things clear enough for now.

Fixes rust-lang#65659.
bors added a commit that referenced this pull request Jan 12, 2020
Rollup of 6 pull requests

Successful merges:

 - #67494 (Constify more of alloc::Layout)
 - #67867 (Correctly check for opaque types in `assoc_ty_def`)
 - #67948 (Galloping search for binary_search_util)
 - #68045 (Move more of `rustc::lint` into `rustc_lint`)
 - #68089 (Unstabilize `Vec::remove_item`)
 - #68108 (Add suggestions when encountering chained comparisons)

Failed merges:

r? @ghost
@bors bors merged commit 088a180 into rust-lang:master Jan 12, 2020
@joshtriplett
Copy link
Member

Will this result in a suggestion to change something like l < x() < u to l < x() && x() < u (which will call x twice)? Is there any way we can avoid that?

@varkor varkor deleted the chained-comparison-suggestions branch January 20, 2020 14:07
@varkor
Copy link
Member Author

varkor commented Jan 20, 2020

@joshtriplett: yes, it will, though it will not be automatically replaced using rustfix, etc. If we feel this might be misleading, we can open up an issue to clarify this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error for chained less-than/greater-than comparisons misleading.
6 participants