Skip to content

Missing docs about associated constants preventing trait from being made into an object #47952

Closed
@Badel2

Description

@Badel2

The following code (from #29924)

trait Trait {
    const N: usize;
}

impl Trait {
}

Doesn't compile because of the following error:

error[E0038]: the trait `Trait` cannot be made into an object
 --> src/main.rs:5:6
  |
5 | impl Trait {
  |      ^^^^^ the trait `Trait` cannot be made into an object
  |
  = note: the trait cannot contain associated consts like `N`

I couldn't find anywhere why a trait cannot contain associated consts, so I suggest to update the error index with a short explaination: https://doc.rust-lang.org/error-index.html#E0038

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-trait-systemArea: Trait systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions