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

Detect spurious ; before assoc fn body #105369

Merged
merged 1 commit into from
Dec 12, 2022

Conversation

chenyukang
Copy link
Member

Fixes #105226

r? @TaKO8Ki

@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 Dec 6, 2022
src/test/ui/parser/issues/issue-60075.stderr Outdated Show resolved Hide resolved
@@ -707,7 +707,7 @@ impl<'a> Parser<'a> {
}
match parse_item(self) {
Ok(None) => {
let is_unnecessary_semicolon = !items.is_empty()
let mut is_unnecessary_semicolon = !items.is_empty()
// When the close delim is `)` in a case like the following, `token.kind` is expected to be `token::CloseDelim(Delimiter::Parenthesis)`,
// but the actual `token.kind` is `token::CloseDelim(Delimiter::Bracket)`.
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
// but the actual `token.kind` is `token::CloseDelim(Delimiter::Bracket)`.
// but the actual `token.kind` is `token::CloseDelim(Delimiter::Brace)`.

I mistakenly wrote Bracket for Brace. Could you fix that instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok,I didn't notice it, I will rollback my changes on your part.

I also think TokenTreesReader::parse_token_tree does a very weird thing for this scenario, I had some try to fix it:
#104012 (comment)

currently pending on: #104012

compiler/rustc_parse/src/parser/item.rs Outdated Show resolved Hide resolved
@chenyukang chenyukang force-pushed the yukang/fix-105226 branch 2 times, most recently from 4fa5694 to 5599f2a Compare December 7, 2022 08:20
@TaKO8Ki
Copy link
Member

TaKO8Ki commented Dec 11, 2022

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Dec 11, 2022

📌 Commit 5599f2a has been approved by TaKO8Ki

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 Dec 11, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Dec 11, 2022
…KO8Ki

Detect spurious ; before assoc fn body

Fixes rust-lang#105226

r? `@TaKO8Ki`
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 11, 2022
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#101648 (Better documentation for env::home_dir()'s broken behaviour)
 - rust-lang#105283 (Don't call `diagnostic_hir_wf_check` query if we have infer variables)
 - rust-lang#105369 (Detect spurious ; before assoc fn body)
 - rust-lang#105472 (Make encode_info_for_trait_item use queries instead of accessing the HIR)
 - rust-lang#105521 (separate heading from body)
 - rust-lang#105555 (llvm-wrapper: adapt for LLVM API changes)
 - rust-lang#105560 (Extend rustdoc hashtag prepended line test)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 4154e14 into rust-lang:master Dec 12, 2022
@rustbot rustbot added this to the 1.68.0 milestone Dec 12, 2022
Comment on lines +14 to +20
error: associated function in `impl` without body
--> $DIR/issue-105226.rs:7:5
|
LL | fn hello<P>(&self, val: &P) where P: fmt::Display; {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
| |
| help: provide a definition for the function: `{ <body> }`
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally we would also avoid emitting this error by making the parser recover from the spurious ;

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.

Detect spurious ; before assoc fn body
5 participants