I don't understand this what does this mean?



    2024 Edition differences

    Before the 2024 edition, reserved guards are accepted by the lexer and interpreted as multiple tokens. For example, the #"foo"# form is interpreted as three tokens. ## is interpreted as two tokens.

what does this mean ??

1 Like

Playground

With edition 2021:

Three token trees: "#" "\"string\"" "#"
Two token trees: "#" "#"

With edition 2024 (select it in the three-dots menu box next to the "STABLE" button), the program is invalid because the two syntaxes are reserved since this edition.

so it is all about the macros ????

In my understanding, it's about a change in how the language is parsed. Macros is one way of showing that.

Yes. Macros don't accept valid Rust, instead they accept “any valid sequence of Rust tokens”. That means that even extremely subtle change that wouldn't affect anything outside of macros could affect some fringe case in macros.

Thus these things are both important to precisely describe (otherwise it's impossible to support backward-compatibility for macros) yet may be mostly ignored, in practice (they are not important outside of macros and even in macros you need to be doing something pretty unusual to hit these corner cases).

Playground for comparison (note that it is invalid even with edition 2021)

By the way, It's also the first time I knew it.