Skip to content
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

Cannot use associated const to specify static array length #52070

Closed
diwic opened this issue Jul 5, 2018 · 2 comments
Closed

Cannot use associated const to specify static array length #52070

diwic opened this issue Jul 5, 2018 · 2 comments
Labels
A-associated-items Area: Associated items (types, constants & functions) A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...)

Comments

@diwic
Copy link
Contributor

diwic commented Jul 5, 2018

pub trait Foo {
    const SIZE: usize;
    fn whatever() {
        // compiles fine
        let _x = [Self::SIZE, 3usize];
        // fails with error[E0599]: no associated item named `SIZE` found for type `Self` in the current scope
        let _y = [3usize; Self::SIZE];
    }
}

This looks like a bug to me - I believe both rows should compile just fine.
It exists in both stable and nightly.

@oli-obk oli-obk added A-associated-items Area: Associated items (types, constants & functions) A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) labels Jul 5, 2018
@vitalyd
Copy link

vitalyd commented Jul 30, 2018

This is essentially a dupe of #43408

@oli-obk oli-obk closed this as completed Jan 28, 2019
@tarcieri
Copy link
Contributor

#60551 is a similar issue specific to associated constants

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-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...)
Projects
None yet
Development

No branches or pull requests

4 participants