You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was messing with macros and came across the error message "error: no type for local variable 10 [E0513]". The following code will reproduce the error using the Rust playground, on Stable, Beta, and Nightly channels:
fn main() {
let v: usize = 2;
let x: [i32; v] = [0, 1];
}
I would have expected an error message such as "expected constant expression, found non-constant expression." It looks like an easy fix, but I imagine E0513 can occur in other situations as well. Replacing let v: usize in the above code sample with const v: usize will compile and run just fine.
The text was updated successfully, but these errors were encountered:
You cannot use constant expressions in type context either. (apparently I misremembered and confused it with some other thing) I agree, though, that the error message is pretty bad.
I was messing with macros and came across the error message "
error: no type for local variable 10 [E0513]
". The following code will reproduce the error using the Rust playground, on Stable, Beta, and Nightly channels:I would have expected an error message such as "expected constant expression, found non-constant expression." It looks like an easy fix, but I imagine E0513 can occur in other situations as well. Replacing
let v: usize
in the above code sample withconst v: usize
will compile and run just fine.The text was updated successfully, but these errors were encountered: