Closed
Description
It appears that when it's not obvious the index type is usize
, we fall back to overloaded indexing:
const FOO: i32 = [12, 34][0 + 1];
Fails in constant checking, on stable:
<anon>:1:18: 1:33 error: user-defined operators are not allowed in constants [E0011]
<anon>:1 const FOO: i32 = [12, 34][0 + 1];
^~~~~~~~~~~~~~~
And also with the new MIR-based constant checker, on nightly:
error: calls in constants are limited to constant functions, struct and enum constructors [E0015]
--> <anon>:1:18
1 |> const FOO: i32 = [12, 34][0 + 1];
|> ^^^^^^^^^^^^^^^