Skip to content

False positive on only_used_in_recursion #9384

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

Closed
didibear opened this issue Aug 27, 2022 · 2 comments
Closed

False positive on only_used_in_recursion #9384

didibear opened this issue Aug 27, 2022 · 2 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@didibear
Copy link

didibear commented Aug 27, 2022

Summary

The lint only_used_in_recursion is raising an error but I cannot figure out why.
You can check this Rust Playground here.

Lint Name

only_used_in_recursion

Reproducer

I tried this code (Rust Playground):

#![deny(clippy::only_used_in_recursion)]

struct Value(i32);

fn set_to_last(mut value: Value, values: &[i32]) {
    value.0 = *values.iter().last().unwrap(); 
}

I saw this happen:

error: parameter is only used in recursion
 --> src/lib.rs:6:16
  |
6 | fn set_to_last(mut value: Value, values: &[i32]) {
  |                ^^^^^^^^^ help: if this is intentional, prefix with an underscore: `_value`
  |
note: the lint level is defined here
 --> src/lib.rs:2:9
  |
2 | #![deny(clippy::only_used_in_recursion)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#only_used_in_recursion

I expected no error.

Version

rustc 1.63.0 (4b91a6ea7 2022-08-08)
binary: rustc
commit-hash: 4b91a6ea7258a947e59c6522cd5898e7c0a6a88f
commit-date: 2022-08-08
host: x86_64-apple-darwin
release: 1.63.0
LLVM version: 14.0.5

Additional Labels

No response

@didibear didibear added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Aug 27, 2022
@Jarcho
Copy link
Contributor

Jarcho commented Aug 27, 2022

This should be fixed in #8804

@kraktus
Copy link
Contributor

kraktus commented Sep 19, 2022

rust playground This is indeed fixed on the latest nightly clippy, can be closed 👍

@Jarcho Jarcho closed this as completed Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

No branches or pull requests

3 participants