Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Badel2 opened this issue Feb 1, 2018 · 0 comments
Labels
A-associated-items Area: Associated items (types, constants & functions) A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-trait-system Area: Trait system C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@Badel2
Copy link
Contributor

Badel2 commented Feb 1, 2018

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

@cuviper cuviper added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-trait-system Area: Trait system A-associated-items Area: Associated items (types, constants & functions) labels Feb 3, 2018
kennytm added a commit to kennytm/rust that referenced this issue Feb 6, 2018
… r=nikomatsakis

Document that associated constants prevent a trait from being made into an object

Fixes rust-lang#47952

Add a short mention of associated constants to E0038
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-trait-system Area: Trait system C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

2 participants