Skip to content

needless_pass_by_ref_mut does not honor the avoid_breaking_exported_api config #11374

Closed

Description

Summary

The config value avoid_breaking_exported_api configuration is documented as:

avoid-breaking-exported-api: bool(defaults to true): Suppress lints whenever the suggested change would cause breakage for other crates.

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

pub fn foo(s: &mut Vec<u32>, b: &u32, x: &mut u32) {
    *x += *b + s.len() as u32;
}

I saw this happen:

warning: this argument is a mutable reference, but not used mutably
 --> src/lib.rs:1:15
  |
1 | pub fn foo(s: &mut Vec<u32>, b: &u32, x: &mut u32) {
  |               ^^^^^^^^^^^^^ help: consider changing to: `&Vec<u32>`
  |
  = warning: changing this function will impact semver compatibility

I expected to see this happen: no lint emission.

Version

rustc 1.73.0-nightly (07438b092 2023-08-16)
binary: rustc
commit-hash: 07438b0928c6691d6ee734a5a77823ec143be94d
commit-date: 2023-08-16
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 17.0.0

Additional Labels

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

A-documentationArea: Adding or improving documentationC-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions