Skip to content

E0109 is out of date #116876

Description

@QuineDot

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

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Oct 18, 2023
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    A-error-codesArea: Explanation of an error code (--explain)
    on Oct 18, 2023
  3. added
    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and tools
    C-bugCategory: This is a bug.
    and removed
    A-diagnosticsArea: Messages for errors, warnings, and lints
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Oct 19, 2023
  4. adityakode commented on Oct 24, 2023

    @adityakode

    Can I work on this ?

  5. gurry commented on Nov 2, 2023

    @gurry
    Contributor

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

  6. QuineDot commented on May 26, 2024

    @QuineDot
    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`
  7. LFS6502 commented on May 21, 2026

    @LFS6502
    Contributor

    @rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-error-codesArea: Explanation of an error code (--explain)C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions