Skip to content

order of top level items is relevant with const fn #29927

Closed
@oli-obk

Description

@oli-obk

This code wrongly states "expected constant integer for repeat count, but non-constant path in constant expression"

#![feature(const_fn)]
struct A {
    field: usize,
}
const fn f() -> usize {
    5
}
fn main() {
    let _ = [0; f()];
}

This one works

#![feature(const_fn)]
const fn f() -> usize {
    5
}
struct A {
    field: usize,
}
fn main() {
    let _ = [0; f()];
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions