-
Notifications
You must be signed in to change notification settings - Fork 1.6k
needless_pass_by_ref_mut
does not honor the avoid_breaking_exported_api
config
#11374
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
Comments
It is as intended. It's something that we discussed in the original PR iirc and finally we decided to go with this implementation because even if it breaks API, it might still want something the users might want to update (maybe they did a code refactoring and missed that?). So in this case, we simply show a label to let the users decide what they want to do: ignore the lint in this location or fix it and then update crate version accordingly. |
Clippy should never suggest breaking public API. That is the point of this config value. If you should release a new version of your crate, you should temporarily set this config value to The user should never want to change public API, except when releasing a new version. So Clippy lints on public API are considered noise that you almost always have to Using this config value in this lint differently than in all other lints is inconsistent as well. |
There are a few problems with your position imo:
|
Yes, this is a more global issue and we should improve our documentation, so that things like this are easier to discover. And this is actively being worked on. However, that doesn't excuse being inconsistent with this config value across lints and make the config value behave differently than documented.
The config value exists in the first place, because people complained that they don't want to do this. Because more often than not, allowing the lint is the only way to address a lint suggesting to break public API.
That is besides the point. Suggesting people to do that might already make them apply the lint without giving it a second thought. That is the problem. IIRC this config value is even from a time where we didn't even care about IMO this lint should be |
I think I'm on the minority side on this one then: I disable this config on every new project I make because I want to see everything I might have missed. Hiding such valuable information by default is really problematic. But people from the opposite will have pretty much the same argument, so not much to debate here sadly...
Sadly yes. The lint will become mostly useless but if that's what's wanted, I'll update the lint to be coherent.
I'm not sure it's a good idea but maybe I'm just overthinking it... |
I'm in favor of this once the current version (fixing |
I have a pretty strong opinion on this, but I'd be happy to discuss this in the next Clippy meeting. |
Please ping me when the discussion happens (so I can at least follow it). |
As agreed in the meeting I'll change the behavior to not lint at all, if the config is set. |
Thanks! |
…Frednet Honor `avoid-breaking-exported-api` in `needless_pass_by_ref_mut` Until now, the lint only emitted a warning, when breaking public API. Now it doesn't lint at all when the config value is not set to `false`, bringing it in line with the other lints using this config value. Also ensures that this config value is documented in the lint. changelog: none (I don't think a changelog is necessary, since this lint is in `nursery`) --- Fixes #11374 cc `@GuillaumeGomez` Marking as draft: Does this lint even break public API? If I change a function signature from `fn foo(x: &mut T)` to `fn foo(x: &T)`, I can still call it with `foo(&mut x)`. The only "breaking" thing is that the `clippy::unnecessary_mut_passed` lint will complain that `&mut` at the callsite is not necessary, possibly trickling down to the crate user having to remote a `mut` from a variable. [Playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=058165a7663902e84af1d23e35c10d66). Are there examples where this actually breaks public API, that I'm missing?
Summary
The config value
avoid_breaking_exported_api
configuration is documented as:However, this lint just produces a warning message that this lint breaks API instead of suppressing it.
Bonus issue: This config argument is not documented with the lint. The lint name has to be added to the macro in
conf.rs
.cc @GuillaumeGomez
Lint Name
needless_pass_by_ref_mut
Reproducer
I tried this code: Playground
I saw this happen:
I expected to see this happen: no lint emission.
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: