-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Stabilize "force warn" option #86516
Comments
Work that needs to be done to stabilize:
|
@rylev You mentioned that you're planning to work on stabilization. I'm happy to help out with this, but I don't want to steal your project. |
@inquisitivecrystal I’m happy to split the work with you. I was going to open a PR rename the option to |
Well, I'm happy to help out however I can. You working on the stabilization report is definitely a good idea, since I wouldn't have any clue how to do that. I'm not entirely sure I know how to do the documentation PR, but I can work it out. The other steps are simple enough that anyone can do them. I'd definitely be happy to take final stabilization, as I find those kind of fun. I guess overall, it would make sense for me to take stabilization, and maybe also the documentation if you'd like me to that? Incidentally, does this need to go through FCP after we get all the other stuff in order? |
I've got a WIP combined documentation and stabilization PR that's pretty close to completion. I'm hoping to be able to submit it as a draft in the next few days, though it wouldn't be merged until the stabilization report and FCP. @rylev, is that alright with you? |
@inquisitivecrystal Yep! Feel free to open the draft PR, and I will have the stabilization report done soon. |
Stabilization Report 🎉(Let me know if I missed anything) Description of behavior
The primary use case of this feature is for Possible points of contentionThis feature is relatively low risk as we don't foresee it being widely used, and behavior of lints is not a part of the stability guarantee for Rust. Therefore, in the worst case, this option can be removed completely (though we would need to ensure that passing the option would not cause an error). Small points of possible contention:
Documentation and Testing
This feature is being tested through the usage of Remaining issues for stabilization can found here: #86516 (comment) |
Can we elaborate on this point? I think it'd be useful to list the behavior in a sort of matrix with cap-lints on one axis and the environment the lint is issued in ( For example, does force-warn cause an allow'd lint to fire? If it does fire, is it forcing it to warn level, or does it become a regular warning and is affected by deny(warnings) to trigger a compilation error? A separate question is whether |
I have something of a last minute proposal. I was just updating the docs to reflect the fact that I have two alternatives. First, we could make cap-lints work the same way for force-warn that it does for everything else. This would require a change to cargo's fix system to set its cap lints to force-warn instead of warn, but that's a one-line change. Alternatively, we could say that setting cap-lints to warn actually sets it to force-warn. This is slightly inconsistent, but you could argue that it's probably what the user intends anyway. |
This is currently accepted. This sounds like an easy way to see all warnings for a codebase even if they are allowed by some other part of the codebase. Is that not a desirable?
This is not the only way that this option differs from forbid. For example, placing a This does not happen with |
If I understand correctly,
I personally consider that less confusing. shrugs Edit: There's a fair chance I'm wrong and we should just stick with what we have. It's just unfortunate ends up being really inconsistent, because it was designed around the needs of edition migration and doesn't really fit with the rest of the system. |
@rylev @Mark-Simulacrum This needs a decision so we can move forward. If we want to do a full FCP on this before stabilizing the edition, we're going to run a bit low on time soon. |
I had missed the comment from a couple weeks ago -- taking a look now, and nominating for T-lang discussion (to move us toward FCP to stabilize). @m-ou-se what is the timeline on this needing to stabilize if we want to avoid shifting other schedules? I would prefer not to rush with stabilization of course, but knowing how much time we have without bumping things would be good.
Hm. I don't see tests for this (based on I think in general this may be desirable, but we should at least have tests for it, and if we don't want to wait on those, not stabilize this part of the feature just yet.
I'll throw my hat into the bucket of choosing a longer name, to avoid consuming interesting option space. Perhaps we even want to slightly generalize: |
This needs to be stable when the edition is stable which is currently planed for 1.56 which will be cut sometime in September.
This indeed works now: #![allow(dead_code)]
fn main() {
println!("Hello, world!");
}
fn foo() {}
I indeed think we have some sort of logical inconsistency here. The However, #![warn(missing_abi)]
fn main() {
println!("Hello, world!");
}
extern fn foo() {}
This code warns even though the command line allows it. The other way around: #![allow(warnings)]
fn main() {
println!("Hello, world!");
}
extern fn foo() {}
In a way #![warn(missing_abi)]
#![allow(warnings)]
fn main() {
println!("Hello, world!");
}
extern fn foo() {}
If there's not a test for this we should definitely add one (assuming we want to keep this behavior). |
This seems reasonable to me. I think we should go ahead and take it as-is. I can also imagine wanting a "force deny" option in the future, but I don't want that to be a blocker for this. We shouldn't make cap-lints affect this, I think; poking through cap-lints seems like part of the point of the option. We should talk about the desired semantics for |
@rfcbot merge |
Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
In the lang team meeting, it was determined that the semantics seem to be correct as they are implemented. The only wrinkle is that |
I would like for us to rename the option to I'd be happy to put in the work on the rename, and we could limit to just supporting |
I believe that is what it does. That is, if a lint is denied or forbidden, it is lowered to a warning, and if it is allowed it is raised to a warning. |
@ehuss is correct, and I misspoke in the lang team meeting unfortunately. #![deny(dead_code)]
fn main() {
println!("Hello, world!");
}
fn foo() {}
|
OK - in that case, name seems fine, though it's not clear to me that the behavior is generally useful; that doesn't seem to preclude stabilization for the targeted use case. |
cc @joshtriplett and @nikomatsakis to make sure their aware of the fact that --force-warn causes warnings no matter what (and not warnings or worse as was suggested in the lang team meeting). |
That's not ideal; the semantics I'd expect are "at least a warning", not downgrading deny to warn. How difficult would it be to change that, to make it a minimum but not a maximum? |
It should be an easy change. I can have a PR soon. Do we need to bring this to the attention of the entire lang time to make a final call on which behavior we want? @ehuss - this shouldn't matter either way for the cargo fix use case, correct? |
Taking a look at what it would take to implement this, and it's unfortunately a little bit more complicated than a trivial change. The issue is that for deny-by-default lints for which we have set --force-warn $LINT we want to deny unless somewhere else in the code has changed the lint to a different level. This leads to a situation where we --force-warn $LINT (which is deny by default) and another part of the code allows $LINT. Without the --force-warn the code would compile (because the lint is allowed), but with --force-warn the code errors since we take the higher between ForceWarn and the lint's default (which is Deny). When a lint has been set to force warn, we don't know whether something like a command line flag or module attribute tried to lower a deny-by-default lint to another lower level. When we try to get the lint level we only have the lint's default level and the level it's been set to (presumably ForceWarn). This isn't impossible to overcome obviously, but I unfortunately won't be able to get to it before my vacation begins. @Mark-Simulacrum can you take this over? |
Yes, I can take this on. |
I can't think of any particular issues. If a lint is raised to an error, then the code wouldn't compile in the first place, and that is not something I spent some time trying to make the future-incompatible warnings use |
I don't understand why interaction with |
…matsakis Force warn improvements As part of stablization of the `--force-warn` option (rust-lang#86516) I've made the following changes: * Error when the `warnings` lint group is based to the `--force-warn` option * Tests have been updated to make it easier to understand the semantics of `--force-warn` r? `@nikomatsakis`
Wanted to reopen to let FCP complete (though it might be gone now automation wise) -- still have time to stop out. |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. The RFC will be merged soon. |
We need #85512 to be stabilized so that
cargo fix
can use it.The text was updated successfully, but these errors were encountered: