Less greedily parse [const] bounds by fmease · Pull Request #146422 · rust-lang/rust (original) (raw)

Important

If you're coming here from any beta backport nomination thread on Zulip, only the last commit is truly relevant (the first commit doesn't need to be backported, it only contains test modifications)!

Don't consider [ to start a bound, only consider [const] in its entirety to do so. This drastically reduces (but doesn't eliminate!) the chance of real breakages. Like const, ~const and async before, [const] unavoidably brings along theoretical breakages, see preexisting tests: macro-const-trait-bound-theoretical-regression.rs and macro-async-trait-bound-theoretical-regression.rs.

Side note: It's unfortunate that we have to do this but apart from the known fact that MBE hurts forward compatibility, the [const] syntax is simply a bit scuffed (also CC'ing #146122, section (3)).

Fixes [after beta backport] #146417.

r? @oli-obk or anyone