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

supplying generic args to variant and enum results in weird error #93993

Open
lcnr opened this issue Feb 14, 2022 · 2 comments · May be fixed by #134981
Open

supplying generic args to variant and enum results in weird error #93993

lcnr opened this issue Feb 14, 2022 · 2 comments · May be fixed by #134981
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

@lcnr
Copy link
Contributor

lcnr commented Feb 14, 2022

fn main() {
    let x = Option::<u32>::Some::<u32>(3);
}

results in

[E0109]: type arguments are not allowed for this type
 --> src/main.rs:2:35
  |
2 |     let x = Option::<u32>::Some::<u32>(3);
  |                                   ^^^ type argument not allowed

this error is far from ideal. we ideally mention that variants may only have generic arguments if their enum doesn't have any. not sure what's the best wording here or how to best achieve this

@lcnr lcnr 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 Feb 14, 2022
@estebank
Copy link
Contributor

At the very least the wording should be type arguments are not allowed for enum variants.

@compiler-errors
Copy link
Member

error[E0109]: type arguments are not allowed on tuple variant `Some`
 --> src/main.rs:2:35
  |
2 |     let x = Option::<u32>::Some::<u32>(3);
  |                            ----   ^^^ type argument not allowed
  |                            |
  |                            not allowed on tuple variant `Some`

estebank added a commit to estebank/rust that referenced this issue Dec 31, 2024
```
error[E0109]: type arguments are not allowed on tuple variant `TSVariant`
  --> $DIR/enum-variant-generic-args.rs:54:29
   |
LL |     TSVariant::<()>(());
   |     ---------   ^^ type argument not allowed
   |     |
   |     not allowed on tuple variant `TSVariant`
   |
   = note: type arguments are not allowed for enum variants; specify them on the enum itself
```

Fix rust-lang#93993.
estebank added a commit to estebank/rust that referenced this issue Dec 31, 2024
```
error[E0109]: type arguments are not allowed on tuple variant `TSVariant`
  --> $DIR/enum-variant-generic-args.rs:54:29
   |
LL |     TSVariant::<()>(());
   |     ---------   ^^ type argument not allowed
   |     |
   |     not allowed on tuple variant `TSVariant`
   |
   = note: type arguments are not allowed for enum variants; specify them on the enum itself
```

Fix rust-lang#93993.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in 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.

3 participants