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 explanatory note to 'expected item' error #115473

Merged
merged 1 commit into from
Sep 6, 2023

Conversation

gurry
Copy link
Contributor

@gurry gurry commented Sep 2, 2023

Fixes #113110

It changes the diagnostic from this:

error: expected item, found `5`
 --> ../test.rs:1:1
  |
1 | 5
  | ^ expected item

to this:

error: expected item, found `5`
 --> ../test.rs:1:1
  |
1 | 5
  | ^ expected item
  |
  = note: items are things that can appear at the root of a module
  = note: for a full list see https://doc.rust-lang.org/reference/items.html

@rustbot
Copy link
Collaborator

rustbot commented Sep 2, 2023

r? @nnethercote

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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 2, 2023
@gurry
Copy link
Contributor Author

gurry commented Sep 2, 2023

@rustbot label -S-waiting-on-review +S-waiting-on-author

@rustbot rustbot 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 2, 2023
@rust-log-analyzer

This comment has been minimized.

@gurry gurry force-pushed the 113110-expected-item branch 2 times, most recently from 17fd171 to 70e22f4 Compare September 2, 2023 11:14
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@gurry gurry marked this pull request as ready for review September 3, 2023 02:54
@gurry
Copy link
Contributor Author

gurry commented Sep 3, 2023

r? @workingjubilee

@gurry
Copy link
Contributor Author

gurry commented Sep 3, 2023

@rustbot review

@rustbot rustbot 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 Sep 3, 2023
@gurry
Copy link
Contributor Author

gurry commented Sep 5, 2023

r? @compiler-errors

@compiler-errors
Copy link
Member

@gurry: please be patient when awaiting a review in the future. no need to reassign twice in 4 days -- if it's been longer than a week or if there's some reason to believe the reviewer is inactive, then you can reassign the reviewer.

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Sep 5, 2023

📌 Commit 691362831f96dc14213e95f420a625d2dcd4a35a has been approved by compiler-errors

It is now in the queue for this repository.

@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 Sep 5, 2023
@compiler-errors
Copy link
Member

actually wait i'm not totally satisfied with the phrasing

@bors r-

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 5, 2023
} else {
"expected item"
err.span_label(span, "expected item")
.note("items are things that can appear at the root of a module")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.note("items are things that can appear at the root of a module")
.note("items are declarations that can appear at the root of a module")

Comment on lines 84 to 85
.note("items are things that can appear at the root of a module")
.note("for a full list see https://doc.rust-lang.org/reference/items.html");
Copy link
Member

Choose a reason for hiding this comment

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

or maybe we should just consolidate this into one note:

Suggested change
.note("items are things that can appear at the root of a module")
.note("for a full list see https://doc.rust-lang.org/reference/items.html");
.note("for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me make this change, update tests and push.

@gurry
Copy link
Contributor Author

gurry commented Sep 6, 2023

@gurry: please be patient when awaiting a review in the future. no need to reassign twice in 4 days -- if it's been longer than a week or if there's some reason to believe the reviewer is inactive, then you can reassign the reviewer.

@bors r+ rollup

Sorry, I'll be more patient in the future.

@gurry
Copy link
Contributor Author

gurry commented Sep 6, 2023

@rustbot review

@rustbot rustbot 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 Sep 6, 2023
@compiler-errors
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Sep 6, 2023

📌 Commit 6a286e7 has been approved by compiler-errors

It is now in the queue for this repository.

@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 Sep 6, 2023
fmease added a commit to fmease/rust that referenced this pull request Sep 6, 2023
…iler-errors

Add explanatory note to 'expected item' error

Fixes rust-lang#113110

It changes the diagnostic from this:

```
error: expected item, found `5`
 --> ../test.rs:1:1
  |
1 | 5
  | ^ expected item
 ```
to this:
```
error: expected item, found `5`
 --> ../test.rs:1:1
  |
1 | 5
  | ^ expected item
  |
  = note: items are things that can appear at the root of a module
  = note: for a full list see https://doc.rust-lang.org/reference/items.html
```
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 6, 2023
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#114511 (Remove the unhelpful let binding diag comes from FormatArguments)
 - rust-lang#115473 (Add explanatory note to 'expected item' error)
 - rust-lang#115574 (Replace `rustc_data_structures` dependency with `rustc_index` in `rustc_parse_format`)
 - rust-lang#115578 (Clarify cryptic comments)
 - rust-lang#115587 (fix rust-lang#115348)
 - rust-lang#115596 (A small change)
 - rust-lang#115598 (Fix log formatting in bootstrap)
 - rust-lang#115605 (Better Debug for `Ty` in smir)
 - rust-lang#115614 (Fix minor grammar typo)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 4a31cc8 into rust-lang:master Sep 6, 2023
11 checks passed
@rustbot rustbot added this to the 1.74.0 milestone Sep 6, 2023
@gurry gurry deleted the 113110-expected-item branch September 13, 2023 04:03
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. 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.

explain what an item is when invalid code is placed at the module-level
8 participants