Skip to content

const indexing broken in nightly with bit shift (<<) #30226

Closed
@Johnson-A

Description

@Johnson-A
const index: usize = 1;

fn main() {
    let array = [1,2,3];
    let test = 1 + array[index]; // This works fine
    let error = 1 << array[index]; // error: const indexing is an unstable feature
}

For some reason, indexing an array with a const requires an unstable feature when there is a bit shift operator. help: in Nightly builds, add #![feature(const_indexing)] to the crate attributes to enable. When adding the feature, there are no more errors but this feature shouldn't be necessary.

rustc 1.6.0-nightly (d49e365 2015-12-05)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions