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

E0109 is out of date #116876

Open
QuineDot opened this issue Oct 18, 2023 · 3 comments
Open

E0109 is out of date #116876

QuineDot opened this issue Oct 18, 2023 · 3 comments
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools A-error-codes Area: Explanation of an error code (--explain) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@QuineDot
Copy link

Code

fn main() {
    let _ = Option::<_>::None::<()>;
    type Alias<T> = Option<T>;
    let _ = Alias::None::<()>;
}
// Followed by running `rustc --explain E0109`

Current output

[Bottom of `rustc --explain E0109`]

Note that generic arguments for `enum` variant constructors go after the variant, not after the `enum`. For example, you would write `Option::None::<u32>`, rather than `Option::<u32>::None`.

Desired output

Note that generic arguments for `enum` variant constructors can go after the variant *or* after the `enum`, but not both.  For example, you can write `Option::None::<u32>` or `Option::<u32>::None`, but not `Option::<u32>::None::<u32>`.

Additionally, generic arguments for `type` aliases of `enum`s go after the `enum`, not after the variant.  For example, if `Alias<T>` is a `type` alias of `Option<T>`, you would write `Alias::<u32>::None`, rather than `Alias::None::<u32>`.

Rationale and extra context

Generic arguments can go after the enum now. Moreover, for type aliases of enums, generic arguments must go after the enum and not after the variant.

See this stabilization report for details. In brief,

  • Option::<T>::None has worked since Rust 1.33
  • Alias::<T>::None has worked since Rust 1.37, but
  • Alias::None::<T> doesn't work so far (Rust 1.73)

Other cases

No response

Anything else?

@rustbot labels +A-error-codes

@QuineDot QuineDot 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 Oct 18, 2023
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. A-error-codes Area: Explanation of an error code (--explain) labels Oct 18, 2023
@fmease fmease added A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-bug Category: This is a bug. and removed A-diagnostics Area: Messages for errors, warnings, and lints needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Oct 19, 2023
@adityakode
Copy link

Can I work on this ?

@gurry
Copy link
Contributor

gurry commented Nov 2, 2023

Yes, why not? Just claim the issue as explained here and start working on it.

@QuineDot
Copy link
Author

I forgot I filed this but just ran into it again while checking something else out, heh.

pub enum Foo<'a, T = String> {
    Bar(&'a T),
    Baz,
}

fn main() {
    // These two work
    let foo = Foo::Baz::<'_, String>;
    let foo = Foo::<'_, String>::Baz;
    // This fails
    let foo = Foo::<'_>::Baz::<String>;
}

Playground. The inline error is actually incorrect too.

error[E0109]: type arguments are not allowed on unit variant `Baz`
  --> src/main.rs:11:32
   |
11 |     let foo = Foo::<'_>::Baz::<String>;
   |                          ---   ^^^^^^ type argument not allowed
   |                          |
   |                          not allowed on unit variant `Baz`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools A-error-codes Area: Explanation of an error code (--explain) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants