-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Cargo fix --prepare-for should only apply edition fixes #5738
Comments
@Mark-Simulacrum on IRC suggested we pass |
@alexcrichton I'll give it a try, but this previously didn't work |
Oh bah you are indeed correct (still!). That's due to this block of code. That means probably we could either:
I'm leaning towards the last option now, but it'd probably be easier to go with the second. @killercup do you have a preference? |
Great research! I think the last option might be one with the least issues going forward – adjusting an allow-list when people add new edition specific lints is trivial. What do you mean with "easier to go with the second" – tracking (and keeping track of!) all enabled-by-default lints in rustc for the foreseeable future? Sheesh! |
Oh more just easier to implement because it's just modifying a string that's already in the code :) I'm cool w/ the third option though! |
Bumping this to the RC1 milestone |
I had a go at fixing this in #5948 (using the third option), but Alex notes:
but suggests we could still go with this option by changing the compiler to get the lint to expose its lint group and using that. But it might be fun to see how to fix rustc so Either way I'd need some rustc mentorship. |
Yeah and to recap what we discussed, two ideas I have for fixing this in rustc are:
I'm not sure how to do the latter but the former is related to this block of code. I think to fix that we'd basically want to remove that block entirely and handle @dwijnand are you interested in doing the |
Yep! |
Ok so the general idea is that during linting we walk the entire AST, keeping a set of the current lint levels for all lints. This set is modified whenever we encounter lint attributes, and is otherwise automatically managed whenever we walk up/down the AST. Overall this means that when issuing a lint you don't actually say anything about the lint level. Only during the linting passes do we later realize what the lint level actually is and that dictates how the lint itself is issued. Currently there's a hardwired statement (linked above) which simply treats all warnings as being overriden by the lint I think instead we'll want to tweak how the "warnings" lint is treated. Instead of having it override, we should have processing of the "warnings" lint be special (whenever we see an attribute or a CLI flag changing it). Changing the warnings lint should change all lints that are currently set to warn to allow. This means that we'd process Does that makes sense? If so, I think this will change by tewaking this enum to have special dedicated fields in each variant for "the warnings lint changed". The special warnings handling block would be removed and instead the |
After several passes, yes. But to drive it home could you give me a few working and not working examples (expected vs intended behaviour)? I'm actually not too familiar with rust's lints or rustc's CLI. Thanks! |
Sure!
And... that's probably mostly it! The handling of levels in crate is pretty similar to handling of levels on the CLI, so these can be translated roughly to cli flags as well |
Alright, thank you. I'll see what I can do. |
Hey @alexcrichton, So after some initial troubles getting started with rustc development, I've finally been able to play with this part of the compiler to see if I can figure it out. Unfortunately progress is quite slow. Could you explain to me more what you had in mind when you said the |
Sure yeah! So The lint level is then determined by the first node we actually find. As we walk upwards we'll find Instead what needs to happen is what while we're doing this traversal we need to also keep track of the state of the Does that make sense? |
No rustc continues to defeat me, for now. But being a sucker for the sunk cost fallacy I might come back to this before the year is out... |
Ok no worries! Feel free to reach out with any issues of course |
Originally reported as rust-lang/rustfix#129
As per rust-lang/rustfix#120 it applies all suggestions, which include the builtin lints.
The text was updated successfully, but these errors were encountered: