Introduce impl restrictions to AST, lower to rustc_middle by jhpratt · Pull Request #141754 · rust-lang/rust (original) (raw)

While it will ultimately be used to parse visibility, this is also intended to reduce friction for any future restrictions that are added and have keyword-only syntax permitted.

As to the difference between Unrestricted and Implied, Unrestricted is an explicit keyword-only modifier, while Implied is "figure this out some other way". The reason Implied doesn't exist later on is that it is determined what the appropriate level is. In reality this means unrestricted, as if something is inaccessible (from visibility) then we don't care about the impl restriction.

For both impl and mut unrestricted isn't permitted (at least for now), but being able to parse this is plausibly useful to provide improved diagnostics.

Of course, if you feel strongly about this, I can leave it out, but it'll almost certainly be re-introduced in the future.