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

Diagnostic tweaks #85102

Merged
merged 3 commits into from
Nov 26, 2021
Merged

Diagnostic tweaks #85102

merged 3 commits into from
Nov 26, 2021

Conversation

estebank
Copy link
Contributor

@estebank estebank commented May 9, 2021

  • 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
Collaborator

r? @lcnr

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

This comment has been minimized.

if expected_ty == self.tcx.types.bool {
// If this is caused by a missing `let` in a `while let`,
// silence this redundant error, as we already emit E0070.
let parent = self.tcx.hir().get_parent_node(blk.hir_id);
Copy link
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
Contributor Author

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
Contributor Author

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 🤔

@lcnr
Copy link
Contributor

lcnr commented May 24, 2021

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

r? @varkor

@rust-highfive rust-highfive assigned varkor and unassigned lcnr May 24, 2021
@crlf0710 crlf0710 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
@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 Jun 27, 2021
@varkor varkor 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 estebank force-pushed the point-at-assignment branch from 695ac5e to 4ed4719 Compare July 19, 2021 17:46
@rust-log-analyzer

This comment has been minimized.

@bors

This comment has been minimized.

@estebank estebank force-pushed the point-at-assignment branch from 028eed7 to 4791472 Compare August 12, 2021 13:07
@bors

This comment has been minimized.

@estebank estebank force-pushed the point-at-assignment branch 2 times, most recently from 173b6cd to 8ffc3ae Compare August 16, 2021 14:22
@estebank estebank 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
@inquisitivecrystal inquisitivecrystal added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 24, 2021
@JohnCSimon JohnCSimon removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 13, 2021
@bors
Copy link
Contributor

bors commented Nov 25, 2021

💔 Test failed - checks-actions

@bors bors 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
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 estebank force-pushed the point-at-assignment branch from d4e5cf4 to 2e1792a Compare November 25, 2021 18:39
@estebank
Copy link
Contributor Author

@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Nov 25, 2021

📌 Commit 2e1792a has been approved by oli-obk

@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-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
Copy link
Contributor

bors commented Nov 26, 2021

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

@bors
Copy link
Contributor

bors commented Nov 26, 2021

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 26, 2021
@bors bors merged commit 9adfd9d into rust-lang:master Nov 26, 2021
@rustbot rustbot added this to the 1.58.0 milestone Nov 26, 2021
@rust-timer
Copy link
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 free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.