Skip to content

Diagnostic tweaks - #85102

Merged
bors merged 3 commits into
rust-lang:masterfrom
estebank:point-at-assignment
Nov 26, 2021
Merged

Diagnostic tweaks#85102
bors merged 3 commits into
rust-lang:masterfrom
estebank:point-at-assignment

Conversation

@estebank

@estebankestebank commented May 9, 2021

Copy link
Copy Markdown
Contributor
  • On type mismatch caused by assignment, point at the source of the expectation
  • Hide redundant errors
  • Suggest while let when let is missing in some cases

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @lcnr

(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 May 9, 2021
@rust-log-analyzer

This comment has been minimized.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this code seems really fragile 🤔

can you instead check the parent which should be a Match expr with MatchSource::WhileDesugar? at least that's what i expect

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

We can't do this because this is not a WhileDesugar. It would be if we had an while let, but we instead have an while.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

An alternative would be to keep global state with all of the HirIds for which we should silence these errors 🤔

Comment threadsrc/test/ui/type/type-check/assignment-expected-bool.stderr Outdated
@lcnr

lcnr commented May 24, 2021

Copy link
Copy Markdown
Contributor

I am not able to review any PRs in the near future.

r? @varkor

@rust-highfiverust-highfive assigned varkor and unassigned lcnrMay 24, 2021
@crlf0710crlf0710 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 Jun 11, 2021
@JohnCSimonJohnCSimon 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 Jun 27, 2021
Comment threadsrc/test/ui/issues/issue-24036.stderr Outdated
Comment threadsrc/test/ui/type/type-check/assignment-expected-bool.stderr Outdated
@varkorvarkor 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 Jun 30, 2021
@bors

This comment has been minimized.

@estebank
estebankforce-pushed the point-at-assignment branch from 695ac5e to 4ed4719CompareJuly 19, 2021 17:46
@rust-log-analyzer

This comment has been minimized.

@bors

This comment has been minimized.

@bors

This comment has been minimized.

@estebank
estebankforce-pushed the point-at-assignment branch 2 times, most recently from 173b6cd to 8ffc3aeCompareAugust 16, 2021 14:22
@estebankestebank added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 17, 2021
@inquisitivecrystalinquisitivecrystal added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 24, 2021
@JohnCSimonJohnCSimon removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 13, 2021
@bors

bors commented Nov 25, 2021

Copy link
Copy Markdown
Collaborator

💔 Test failed - checks-actions

@borsbors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 25, 2021
@rust-log-analyzer

This comment has been minimized.

@matthiaskrgr

Copy link
Copy Markdown
Member

Clippy tests need an update:

2021-11-25T11:59:58.4590876Z test [ui] ui/large_const_arrays.rs ... ok
2021-11-25T11:59:58.4609082Z 2021-11-25T11:59:58.4610210Z failures:
2021-11-25T11:59:58.4610794Z 2021-11-25T11:59:58.4611536Z failures:
2021-11-25T11:59:58.4613343Z [ui] ui/crashes/ice-6250.rs
2021-11-25T11:59:58.4614024Z 2021-11-25T11:59:58.4615404Z test result: FAILED. 661 passed; 1 failed; 3 ignored; 0 measured; 0 filtered out; finished in 7.44s
2021-11-25T11:59:58.4616521Z 2021-11-25T11:59:58.4617373Z test compile_test ... FAILED
2021-11-25T11:59:58.4618031Z 2021-11-25T11:59:58.4618796Z failures:
2021-11-25T11:59:58.4619435Z 2021-11-25T11:59:58.4620611Z ---- compile_test stdout ----
2021-11-25T11:59:58.4621581Z diff of stderr:
2021-11-25T11:59:58.4622137Z 2021-11-25T11:59:58.4623232Z error[E0658]: destructuring assignments are unstable
2021-11-25T11:59:58.4624767Z --> $DIR/ice-6250.rs:12:25
2021-11-25T11:59:58.4625601Z |
2021-11-25T11:59:58.4626644Z LL | Some(reference) = cache.data.get(key) {
2021-11-25T11:59:58.4628046Z | --------------- ^
2021-11-25T11:59:58.4628859Z | |
2021-11-25T11:59:58.4629847Z | cannot assign to this expression
2021-11-25T11:59:58.4630817Z |
2021-11-25T11:59:58.4633059Z = note: see issue #71126 <https://github.com/rust-lang/rust/issues/71126> for more information
2021-11-25T11:59:58.4635341Z = help: add `#![feature(destructuring_assignment)]` to the crate attributes to enable
2021-11-25T11:59:58.4636672Z 2021-11-25T11:59:58.4637717Z error[E0601]: `main` function not found in crate `ice_6250`
2021-11-25T11:59:58.4639183Z --> $DIR/ice-6250.rs:4:1
2021-11-25T11:59:58.4640022Z |
2021-11-25T11:59:58.4640983Z LL | / pub struct Cache {
2021-11-25T11:59:58.4641549Z LL | | data: Vec<i32>,
2021-11-25T11:59:58.4642035Z LL | | }
2021-11-25T11:59:58.4642450Z LL | |
2021-11-25T11:59:58.4642850Z ... |
2021-11-25T11:59:58.4643250Z LL | | }
2021-11-25T11:59:58.4643667Z LL | | }
2021-11-25T11:59:58.4644848Z | |_^ consider adding a `main` function to `$DIR/ice-6250.rs`
2021-11-25T11:59:58.4645485Z 2021-11-25T11:59:58.4645995Z error[E0308]: mismatched types
2021-11-25T11:59:58.4646749Z --> $DIR/ice-6250.rs:12:14
2021-11-25T11:59:58.4647225Z |
2021-11-25T11:59:58.4647729Z +LL | for reference in vec![1, 2, 3] {
2021-11-25T11:59:58.4648646Z + | --------- expected due to the type of this binding
2021-11-25T11:59:58.4649262Z +...
2021-11-25T11:59:58.4649862Z LL | Some(reference) = cache.data.get(key) {
2021-11-25T11:59:58.4650938Z | ^^^^^^^^^ expected integer, found `&i32`
2021-11-25T11:59:58.4651499Z |
2021-11-25T11:59:58.4652215Z help: consider dereferencing the borrow
2021-11-25T11:59:58.4652809Z |
2021-11-25T11:59:58.4653403Z LL | Some(*reference) = cache.data.get(key) {
2021-11-25T11:59:58.4654013Z | +
2021-11-25T11:59:58.4654427Z 2021-11-25T11:59:58.4654947Z error[E0308]: mismatched types
2021-11-25T11:59:58.4655789Z --> $DIR/ice-6250.rs:12:9
2021-11-25T11:59:58.4656266Z |
2021-11-25T11:59:58.4656856Z LL | Some(reference) = cache.data.get(key) {
2021-11-25T11:59:58.4657602Z | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`
2021-11-25T11:59:58.4658154Z 2021-11-25T11:59:58.4658703Z error: aborting due to 4 previous errors
2021-11-25T11:59:58.4659264Z 2021-11-25T11:59:58.4659887Z Some errors have detailed explanations: E0308, E0601, E0658.
2021-11-25T11:59:58.4660952Z For more information about an error, try `rustc --explain E0308`.
2021-11-25T11:59:58.4661619Z 2021-11-25T11:59:58.4661887Z 2021-11-25T11:59:58.4662505Z The actual stderr differed from the expected stderr.
2021-11-25T11:59:58.4664146Z Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/test/crashes/ice-6250.stage-id.stderr
2021-11-25T11:59:58.4665723Z To update references, rerun the tests and pass the `--bless` flag
2021-11-25T11:59:58.4670363Z To only update this specific test, also pass `--test-args crashes/ice-6250.rs`
2021-11-25T11:59:58.4671001Z ```

* Do not emit unnecessary E0308 after E0070
* Show fewer errors on `while let` missing `let`
* Hide redundant E0308 on `while let` missing `let`
* Point at binding definition when possible on invalid assignment
* do not point at closure twice
* do not suggest `if let` for literals in lhs
* account for parameter types
@estebank

Copy link
Copy Markdown
ContributorAuthor

@bors r=oli-obk

@bors

bors commented Nov 25, 2021

Copy link
Copy Markdown
Collaborator

📌 Commit 2e1792a has been approved by oli-obk

@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 Nov 25, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 25, 2021
…-obk
Diagnostic tweaks
* On type mismatch caused by assignment, point at the source of the expectation
* Hide redundant errors
* Suggest `while let` when `let` is missing in some cases
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 25, 2021
…-obk
Diagnostic tweaks
* On type mismatch caused by assignment, point at the source of the expectation
* Hide redundant errors
* Suggest `while let` when `let` is missing in some cases
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 25, 2021
…-obk
Diagnostic tweaks
* On type mismatch caused by assignment, point at the source of the expectation
* Hide redundant errors
* Suggest `while let` when `let` is missing in some cases
@bors

bors commented Nov 26, 2021

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 2e1792a with merge 9adfd9d...

@bors

bors commented Nov 26, 2021

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 9adfd9d to master...

@borsbors added the merged-by-bors This PR was explicitly merged by bors. label Nov 26, 2021
@bors
bors merged commit 9adfd9d into rust-lang:masterNov 26, 2021
@rustbotrustbot added this to the 1.58.0 milestone Nov 26, 2021
@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (9adfd9d): comparison url.

Summary: This benchmark run did not return any relevant changes.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

@estebank
estebank deleted the point-at-assignment branch November 9, 2023 05:14
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-borsThis PR was explicitly merged by bors.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.

14 participants

@estebank@rust-highfive@rust-log-analyzer@lcnr@bors@wesleywiser@oli-obk@matthiaskrgr@rust-timer@varkor@crlf0710@JohnCSimon@inquisitivecrystal@rustbot