Open petrochenkov opened 6 years ago
Doesn’t seem like too much of a problem to me especially that formatting it conventionally
fn main() {
0 < <*const u8 as Trait>::CONST;
}
breaks up the <<
token and produces "expected" results.
Yeah, this is mostly a theoretical concern.
Triage: Normally I do not touch prio labels since it is up to the owning team to decide prio, but when there seems to be an agreement that this is "mostly a theoretical concern", it seems fine to mark this P-low. Marking as P-low.
Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=35f2e9b9c6d48c33199bc878363a15df
0<<*const u8 as Trait>::CONST
here unambiguously means0 < (<*const u8 as Trait>::CONST)
because it can't be parsed as a shift, but rustc tries to parse it as a shift and report an error:Note that you can't detect this situation using limited lookahead in general case, for example
is unambiguously a type too, but we don't know it until we see
'static
.This syntax allows to construct fully ambiguous examples as well, e.g.
can be interpreted as both
((x << y) as z) > (::a)
andx < (<y as z>::a)
.