Skip to content

Recover impl<T ?Sized> correctly #111449

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged

Conversation

compiler-errors
Copy link
Member

Fixes #111327

r? @Nilstrieb but you can re-roll

Alternatively, happy to close this if we're okay with just saying "sorry #111327 is just a poor side-effect of parser ambiguity" 🤷

@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 May 10, 2023
@Noratrieb
Copy link
Member

In my opinion every time a parser error special case causes a worse error than the generic "expected, found" error that's a bug and should be fixed. I will take a look later.

Copy link
Member

@Noratrieb Noratrieb left a comment

Choose a reason for hiding this comment

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

I don't exactly love the change but I think it's an improvement that, when added with enough comments clarifying that it's not necessary (ideally also inside the matches!), is an okay addition to the parser.

@@ -453,6 +453,7 @@ impl<'a> Parser<'a> {
// `<` (LIFETIME|IDENT) `:` - generic parameter with bounds
// `<` (LIFETIME|IDENT) `=` - generic parameter with a default
// `<` const - generic const parameter
// `<` IDENT `?` - RECOVERY for `impl<T ?Bound` missing a `:`
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a comment here on why we need the special case here? That the parser likes to parse T? as Option<T>.

@Noratrieb Noratrieb 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 May 15, 2023
@rust-cloud-vms rust-cloud-vms bot force-pushed the recover-impl-generics-correctly branch from 1d3c676 to a5763ff Compare May 15, 2023 17:21
@compiler-errors
Copy link
Member Author

@rustbot ready

@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 May 15, 2023
Copy link
Member

@Noratrieb Noratrieb left a comment

Choose a reason for hiding this comment

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

r=me

@compiler-errors
Copy link
Member Author

@bors r=Nilstrieb rollup

@bors
Copy link
Collaborator

bors commented May 15, 2023

📌 Commit a5763ff has been approved by Nilstrieb

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 May 15, 2023
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request May 16, 2023
…ics-correctly, r=Nilstrieb

Recover `impl<T ?Sized>` correctly

Fixes rust-lang#111327

r? `@Nilstrieb` but you can re-roll

Alternatively, happy to close this if we're okay with just saying "sorry rust-lang#111327 is just a poor side-effect of parser ambiguity" 🤷
Noratrieb added a commit to Noratrieb/rust that referenced this pull request May 16, 2023
…ics-correctly, r=Nilstrieb

Recover `impl<T ?Sized>` correctly

Fixes rust-lang#111327

r? ``@Nilstrieb`` but you can re-roll

Alternatively, happy to close this if we're okay with just saying "sorry rust-lang#111327 is just a poor side-effect of parser ambiguity" 🤷
Noratrieb added a commit to Noratrieb/rust that referenced this pull request May 16, 2023
…ics-correctly, r=Nilstrieb

Recover `impl<T ?Sized>` correctly

Fixes rust-lang#111327

r? ```@Nilstrieb``` but you can re-roll

Alternatively, happy to close this if we're okay with just saying "sorry rust-lang#111327 is just a poor side-effect of parser ambiguity" 🤷
bors added a commit to rust-lang-ci/rust that referenced this pull request May 16, 2023
Rollup of 10 pull requests

Successful merges:

 - rust-lang#111428 (refactor(resolve): clean up the early error return caused by non-call)
 - rust-lang#111449 (Recover `impl<T ?Sized>` correctly)
 - rust-lang#111572 (Document that `missing_copy_implementations` and `missing_debug_implementations` only apply to public items.)
 - rust-lang#111602 (Suppress "erroneous constant used" for constants tainted by errors)
 - rust-lang#111605 (fixup version placeholder for `cfi_encoding` feature)
 - rust-lang#111607 (Add clubby789 to the bootstrap review rotation)
 - rust-lang#111614 (Add more interesting nonsense to weird-exprs.rs)
 - rust-lang#111617 (Fixed typo)
 - rust-lang#111620 (Add eholk back to compiler-contributors reviewers)
 - rust-lang#111621 (Fix release date of 1.58.1 in release notes.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 87a0cd9 into rust-lang:master May 16, 2023
@rustbot rustbot added this to the 1.71.0 milestone May 16, 2023
@compiler-errors compiler-errors deleted the recover-impl-generics-correctly branch August 11, 2023 20:14
# for free to join this conversation on GitHub. Already have an account? # 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.

type parameters followed by ? are recovered incorrectly
4 participants