Skip to content

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

Closed
@Badel2

Description

@Badel2
Contributor

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

Activity

added
C-enhancementCategory: An issue proposing an enhancement or a PR with one.
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and tools
A-associated-itemsArea: Associated items (types, constants & functions)
on Feb 3, 2018
added a commit that references this issue on Feb 6, 2018

Rollup merge of rust-lang#48026 - Badel2:doc-assoc-const-object-safe,…

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

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

        Participants

        @cuviper@Badel2

        Issue actions

          Missing docs about associated constants preventing trait from being made into an object · Issue #47952 · rust-lang/rust