Skip to content
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

type parameters followed by ? are recovered incorrectly #111327

Closed
BoxyUwU opened this issue May 7, 2023 · 0 comments · Fixed by #111449
Closed

type parameters followed by ? are recovered incorrectly #111327

BoxyUwU opened this issue May 7, 2023 · 0 comments · Fixed by #111449
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@BoxyUwU
Copy link
Member

BoxyUwU commented May 7, 2023

Code

trait Trait {}

impl<T ?Sized> Trait for T {}

Current output

error: invalid `?` in type
 --> src/lib.rs:3:8
  |
3 | impl<T ?Sized> Trait for T {}
  |        ^ `?` is only allowed on expressions, not types
  |
help: if you meant to express that the type might not contain a value, use the `Option` wrapper type
  |
3 | impl<Option<T >Sized> Trait for T {}
  |      +++++++  ~

error: expected one of `>` or `as`, found `Sized`
 --> src/lib.rs:3:9
  |
3 | impl<T ?Sized> Trait for T {}
  |         ^^^^^ expected one of `>` or `as`

Desired output

It should suggest adding a `:` and not emit the two current errors, explaining that you forgot to write `:` before the `?Sized` bound.

Rationale and extra context

No response

Other cases

No response

Anything else?

No response

@BoxyUwU BoxyUwU added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 7, 2023
@compiler-errors compiler-errors self-assigned this May 7, 2023
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue 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 issue 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 issue 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 bors closed this as completed in 87a0cd9 May 16, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants