Skip to content

Suggest == to wrong assign expr - #102708

Merged
bors merged 2 commits into
rust-lang:masterfrom
TaKO8Ki:improve-eqeq-suggestion
Oct 6, 2022
Merged

Suggest == to wrong assign expr#102708
bors merged 2 commits into
rust-lang:masterfrom
TaKO8Ki:improve-eqeq-suggestion

Conversation

@TaKO8Ki

@TaKO8KiTaKO8Ki commented Oct 5, 2022

Copy link
Copy Markdown
Member

Given the following code:

fnmain(){let x = 3;let y = 3;if x == x && y = y {println!("{}", x);}}

Current output is:

error[E0308]: mismatched types
--> src/main.rs:4:18
|
4 | if x == x && y = y {
| ^ expected `bool`, found integer
error[E0308]: mismatched types
--> src/main.rs:4:8
|
4 | if x == x && y = y {
| ^^^^^^^^^^^^^^^ expected `bool`, found `()`

This adds a suggestion:

error[E0308]: mismatched types
--> src/main.rs:6:18
|
6 | if x == x && y = y {
| ^ expected `bool`, found integer
error[E0308]: mismatched types
--> src/main.rs:6:8
|
6 | if x == x && y = y {
| ^^^^^^^^^^^^^^^ expected `bool`, found `()`
|
+ help: you might have meant to compare for equality+ |+ 6 | if x == x && y == y {+ | +

And this fixes a part of #97469

@TaKO8Ki

Copy link
Copy Markdown
MemberAuthor

r? compiler

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @estebank

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 5, 2022
@TaKO8KiTaKO8Ki added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 5, 2022
@estebank

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Oct 5, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit b7c42c5 has been approved by estebank

It is now in the queue for this repository.

@borsbors 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-review Status: Awaiting review from the assignee but also interested parties. labels Oct 5, 2022
@TaKO8KiTaKO8Ki changed the title Suggest == to the rest of assign exprSuggest == to wrong assign exprOct 5, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 6, 2022
…iaskrgr
Rollup of 5 pull requests
Successful merges:
- rust-lang#102672 (rustdoc: remove unused CSS class `in-band`)
- rust-lang#102693 (Revert "Use getentropy when possible on all Apple platforms")
- rust-lang#102694 (Suggest calling method if fn does not exist)
- rust-lang#102708 (Suggest `==` to wrong assign expr)
- rust-lang#102710 (Add test for issue 82633)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 0512a06 into rust-lang:masterOct 6, 2022
@rustbotrustbot added this to the 1.66.0 milestone Oct 6, 2022
@TaKO8Ki
TaKO8Ki deleted the improve-eqeq-suggestion branch October 6, 2022 08:58
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Oct 13, 2022
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant 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.

5 participants

@TaKO8Ki@rust-highfive@estebank@bors@rustbot