fn main() {
let _ = vec![(const { 1 }); 0];
let _ = vec![const { 1 }; 0];
}
Compiler firstly tells me line 3 is illegal (error: no rules expected the token const), then complain about the extra bracket in line 2 (warning: unnecessary parentheses around function argument), which suggests me turn line 2 into line 3.
I'm submitting issue about that, but I am not sure it is a bug or regression.
It's a breaking change to parse const block as expr fragment under edition 2021 . It works under edition 2024. We should suppress the warning under edition 2021.
So we'll change the meaning of expr in the 2024 edition so that it will accept const blocks, and leave it up to the ecosystem to decide for their own macros if they want to change from expr_2021 to expr_2024.
(The standard library will probably correspondingly change the vec! macro to expr_2024 once that's possible.)
Strictly speaking, thread_local! does more than just "support" inline const (it switches from lazy to static initialization and can be more efficient as a result). It also supported this before inline const was stable.
That's somewhat interesting. I suppose all of them just pass $($:tt)* through to format_args!, which uses the main compiler machinery for parsing, not the macro_rules! binding classes, explaining this.