-
Notifications
You must be signed in to change notification settings - Fork 1.6k
needless_pass_by_ref_mut
should not trigger for cfg-gated mod/fn
#11185
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
Likely you'll want to traverse up the |
I don't think it's a good idea to disable the lint if we enter a |
Then we could perhaps at least add a note then to allow it if it's inside a |
I don't understand what you mean by "add a note". |
Should've clarified; like with how |
Oh I see. Yes that sounds like a nice idea indeed. |
Summary
In target specific modules, some functions may only mutate arguments for a specific platform. Keeping the same signature to take
&mut
for all of them makes higher level abstractions simpler.If we expose this platform differences, it will propagate upwards and force every users to
#[cfg]
between&
and&mut
. This violates the abstraction goal of the library.A solution to this issue is to treat every
#[cfg] fn
and#[cfg] mod { pub fn }
as part of public interface, and suppress warnings that would cause signature changes on them.Lint Name
needless_pass_by_ref_mut
Reproducer
I saw this happen:
I expected to see this happen:
Version
Additional Labels
@rustbot label +I-false-positive +I-suggestion-causes-error
I think this fits
I-suggestion-causes-error
because the change breaks on other cfg-gated platforms.The text was updated successfully, but these errors were encountered: