Skip to content

Error message should be improved for associated consts in array lengths #44168

Closed
@nwin

Description

@nwin

The following code

pub trait HasLength {
    const LENGTH: usize;
}

fn foo<T: Copy + HasLength>(x: T) -> [T; T::LENGTH] { [x; T::LENGTH] }

results in an error “error[E0599]: no associated item named LENGTH found for type T in the current scope”. Which is not true, it just doesn’t work in arrays yet (see #29646). The error message should reflect that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.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