-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
const fn has no result expression #33031
Comments
Default to unit, but generate a warning. A const fn with no result is probably a mistake. |
It's not a particularly easy mistake to make, given that your function would have to be empty and return unit. More than that, in the future we may have asserts in const fns, so unit-returning const fns would be useful. |
We can't fix this yet, because we can't create struct and tuple |
I get the same error if I run: #![feature(const_fn)]
const fn foo(x: i32) -> i32 {
return x;
}
fn main() {
let x = foo(2);
println!("{}", x);
} Although, if I omit the semicolon in
|
This no longer ICEs. |
ICEs with
The result expression should probably default to unit?
The text was updated successfully, but these errors were encountered: