Skip to content

Constants should not require 'static bound for their typeparams #33573

Closed
@nagisa

Description

@nagisa

Code like

trait Lattice {
    const BOTTOM: Self;
}

impl<T> Lattice for Option<T> {
    const BOTTOM: Option<T> = None;
}

fails to compile (after #33572) despite being “just” all-right because compiler demands for a 'static lifetime on T, which is completely unnecessary (constants are instantiated inline).

Expected results: should compile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions