Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upname-based comparison in new label-shadowing check has likely hygiene issues. #24278
Comments
steveklabnik
added
the
A-macros
label
Apr 10, 2015
pnkfelix
referenced this issue
May 12, 2015
Open
non-hygienic lifetime-shadowing check can make macros non-modular #25345
This comment has been minimized.
This comment has been minimized.
|
It looks like it can't be fixed by a simple hygienic comparison (
so, two label declarations are never equal if compared hygienically. I'm still studying mtwt and trying to understand what can be done with this issue. |
This comment has been minimized.
This comment has been minimized.
|
@petrochenkov just because Idents have different syntax contexts, does not necessarily mean they are not equal. Calling |
This comment has been minimized.
This comment has been minimized.
|
In the example above |
This comment has been minimized.
This comment has been minimized.
|
That seems correct - they don't shadow. The shadowing case is:
I think hygienic equality is what we want, if that doesn't work, there might be a bug in the mtwt implementation. |
This comment has been minimized.
This comment has been minimized.
|
According to the code and tests (https://github.com/rust-lang/rust/blob/master/src/test/compile-fail/loops-reject-duplicate-labels.rs) label duplication is supposed to be checked globally in a function, regardless of nesting (at least currently) (not sure why exactly). Some discussion here: #21633 |
This comment has been minimized.
This comment has been minimized.
|
Heh, well that seems wrong to me, but explains why there is trouble doing hygienic comparison. I don't see an easy solution in this case (it's possible a different hygiene algorithm can fix this, or at least allow us to fix it with an easy-ish hack, but I don't think that counts as easy). |
This comment has been minimized.
This comment has been minimized.
|
Also lol at that issue being E-Easy! |
This was referenced Feb 19, 2017
brson
added
the
T-compiler
label
Apr 11, 2017
This comment has been minimized.
This comment has been minimized.
|
Ping @pnkfelix @petrochenkov @nrc still a problem? |
brson
added
the
P-low
label
Apr 11, 2017
This comment has been minimized.
This comment has been minimized.
|
@brson |
This comment has been minimized.
This comment has been minimized.
|
This should "just work" in with declarative macros 2.0 (#40847) -- I'll add a test. |
pnkfelix commentedApr 10, 2015
Spawned off of #24162. Our lifetimes only carry a
Name, not anIdent, which means the comparisons for shadowing are only doing name based comparisons.But macros should be free to introduce labels, and have them be treated as independent due to hygiene.
This bug is believed to only introduce issues where code will cause a warning to be emitted by the new shadowing check when it should be accepted; i.e. there are not any known soundness issues associated with this problem.
(Note: While loop labels themselves are
Idents, much of the syntax system does not treat them the same way it treats "normal" variables with respect to e.g. hygiene. For example thesyntax::visitsystem does not invokevisit_identon loop labels.)