-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
elided_lifetime_in_path
triggers for the format!
macro
#48385
Comments
cc @Dylan-DPC |
I think the more general problem is that lints should be hygienic - we should only check them against ast nodes from this code, not those generated by a macro. |
I've seen someone bit by something similar. They had a So +1 for this kind of fix. |
That won't help with |
Any pointers on how to suppress this warning for macros outside of the current crate? |
Clippy has a function. |
It does feel wrong to do this on a lint-by-lint basis, though, right? Maybe as part of Lines 404 to 420 in 27a046e
We could e.g. return the "dummy" value for spans that are not in the current crate: Line 413 in 27a046e
|
It's not that simple, though. The node being linted may be outside of a macro, but it may contain macroy things that affect the lint. The correct way to handle this is to identify all the "important" nodes and do a macro check. (Also: All currently supported ways of doing a macro check will not lint stuff like |
So actually rust/src/librustc/ty/context.rs Lines 2222 to 2247 in 27a046e
That is, this seems like an identical problem to deciding whether the lint is enabled. We're basically talking about adding some measure of hygiene to that check, right? (Also, I'm totally willing to be believe we should just work around this for now, and defer any more general changes to be done as part of a hygiene-overhaul-sort-of-thing.) |
(One annoying problem: that fn does not presently have a span.) |
It's almost identical to that problem, and I think we can get away with that approximation for now. I can think of counterexamples but it just makes the lints slightly overconservative so nbd. However, bear in mind that we may not want this at all for future compat lints (we already catalog these so we can special case this). |
Interesting point. Probably we don't, yes. =) (The story around future compatibility and dependencies is sort of complicated, I think, but see also #34596) |
Issue for adding macro checks to lints at #48855 |
This issue is also related to this topic: #51903. |
This is now fixed (lint was rewritten in #52069).
|
I was trying to use
deny(elided_lifetime_in_path)
and encountered the problem that this doesn't work:I get
I suppose the easiest fix is to fix the
format!
expansion, but maybe better to suppress this warning for macros outside of the current crate? Feels like a more general problem.The text was updated successfully, but these errors were encountered: