Skip to content

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

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
oli-obk opened this issue Nov 19, 2015 · 1 comment
Closed

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

oli-obk opened this issue Nov 19, 2015 · 1 comment

Comments

@oli-obk
Copy link
Contributor

oli-obk commented Nov 19, 2015

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()];
}
@oli-obk
Copy link
Contributor Author

oli-obk commented Dec 7, 2015

accidentally fixed in #30084

@oli-obk oli-obk closed this as completed Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant