2022-02-12 17:32:09 +00:00
|
|
|
#![warn(clippy::only_used_in_recursion)]
|
2023-07-27 11:40:22 +00:00
|
|
|
//@no-rustfix
|
2022-05-08 17:11:53 +00:00
|
|
|
fn _simple(x: u32) -> u32 {
|
|
|
|
x
|
2022-02-12 17:32:09 +00:00
|
|
|
}
|
|
|
|
|
2022-05-08 17:11:53 +00:00
|
|
|
fn _simple2(x: u32) -> u32 {
|
|
|
|
_simple(x)
|
2022-02-12 17:32:09 +00:00
|
|
|
}
|
|
|
|
|
2022-05-08 17:11:53 +00:00
|
|
|
fn _one_unused(flag: u32, a: usize) -> usize {
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: parameter is only used in recursion
|
2022-05-08 17:11:53 +00:00
|
|
|
if flag == 0 { 0 } else { _one_unused(flag - 1, a) }
|
2022-02-12 17:32:09 +00:00
|
|
|
}
|
|
|
|
|
2022-05-08 17:11:53 +00:00
|
|
|
fn _two_unused(flag: u32, a: u32, b: i32) -> usize {
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: parameter is only used in recursion
|
|
|
|
//~| ERROR: parameter is only used in recursion
|
2022-05-08 17:11:53 +00:00
|
|
|
if flag == 0 { 0 } else { _two_unused(flag - 1, a, b) }
|
2022-02-12 17:32:09 +00:00
|
|
|
}
|
|
|
|
|
2022-05-08 17:11:53 +00:00
|
|
|
fn _with_calc(flag: u32, a: i64) -> usize {
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: parameter is only used in recursion
|
2022-05-08 17:11:53 +00:00
|
|
|
if flag == 0 {
|
|
|
|
0
|
|
|
|
} else {
|
|
|
|
_with_calc(flag - 1, (-a + 10) * 5)
|
|
|
|
}
|
2022-02-12 17:32:09 +00:00
|
|
|
}
|
|
|
|
|
2022-05-08 17:11:53 +00:00
|
|
|
// Don't lint
|
|
|
|
fn _used_with_flag(flag: u32, a: u32) -> usize {
|
|
|
|
if flag == 0 { 0 } else { _used_with_flag(flag ^ a, a - 1) }
|
2022-02-12 17:32:09 +00:00
|
|
|
}
|
|
|
|
|
2022-05-08 17:11:53 +00:00
|
|
|
fn _used_with_unused(flag: u32, a: i32, b: i32) -> usize {
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: parameter is only used in recursion
|
|
|
|
//~| ERROR: parameter is only used in recursion
|
2022-05-08 17:11:53 +00:00
|
|
|
if flag == 0 {
|
|
|
|
0
|
|
|
|
} else {
|
|
|
|
_used_with_unused(flag - 1, -a, a + b)
|
|
|
|
}
|
2022-02-12 17:32:09 +00:00
|
|
|
}
|
|
|
|
|
2022-05-08 17:11:53 +00:00
|
|
|
fn _codependent_unused(flag: u32, a: i32, b: i32) -> usize {
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: parameter is only used in recursion
|
|
|
|
//~| ERROR: parameter is only used in recursion
|
2022-05-08 17:11:53 +00:00
|
|
|
if flag == 0 {
|
|
|
|
0
|
|
|
|
} else {
|
|
|
|
_codependent_unused(flag - 1, a * b, a + b)
|
|
|
|
}
|
2022-02-12 17:32:09 +00:00
|
|
|
}
|
|
|
|
|
2022-05-08 17:11:53 +00:00
|
|
|
fn _not_primitive(flag: u32, b: String) -> usize {
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: parameter is only used in recursion
|
2022-05-08 17:11:53 +00:00
|
|
|
if flag == 0 { 0 } else { _not_primitive(flag - 1, b) }
|
2022-02-12 17:32:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct A;
|
|
|
|
|
|
|
|
impl A {
|
2022-05-08 17:11:53 +00:00
|
|
|
fn _method(flag: usize, a: usize) -> usize {
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: parameter is only used in recursion
|
2022-05-08 17:11:53 +00:00
|
|
|
if flag == 0 { 0 } else { Self::_method(flag - 1, a) }
|
2022-03-05 12:39:00 +00:00
|
|
|
}
|
|
|
|
|
2022-05-08 17:11:53 +00:00
|
|
|
fn _method_self(&self, flag: usize, a: usize) -> usize {
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: parameter is only used in recursion
|
|
|
|
//~| ERROR: parameter is only used in recursion
|
2022-05-08 17:11:53 +00:00
|
|
|
if flag == 0 { 0 } else { self._method_self(flag - 1, a) }
|
2022-03-05 12:39:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trait B {
|
2022-05-08 17:11:53 +00:00
|
|
|
fn method(flag: u32, a: usize) -> usize;
|
|
|
|
fn method_self(&self, flag: u32, a: usize) -> usize;
|
2022-03-05 12:39:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl B for A {
|
2022-05-08 17:11:53 +00:00
|
|
|
fn method(flag: u32, a: usize) -> usize {
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: parameter is only used in recursion
|
2022-05-08 17:11:53 +00:00
|
|
|
if flag == 0 { 0 } else { Self::method(flag - 1, a) }
|
2022-03-05 12:39:00 +00:00
|
|
|
}
|
|
|
|
|
2022-05-08 17:11:53 +00:00
|
|
|
fn method_self(&self, flag: u32, a: usize) -> usize {
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: parameter is only used in recursion
|
2022-05-08 17:11:53 +00:00
|
|
|
if flag == 0 { 0 } else { self.method_self(flag - 1, a) }
|
2022-02-12 17:32:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-08 17:11:53 +00:00
|
|
|
impl B for () {
|
|
|
|
fn method(flag: u32, a: usize) -> usize {
|
|
|
|
if flag == 0 { 0 } else { a }
|
2022-03-07 03:15:00 +00:00
|
|
|
}
|
|
|
|
|
2022-05-08 17:11:53 +00:00
|
|
|
fn method_self(&self, flag: u32, a: usize) -> usize {
|
|
|
|
if flag == 0 { 0 } else { a }
|
2022-03-07 03:15:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-08 17:11:53 +00:00
|
|
|
impl B for u32 {
|
|
|
|
fn method(flag: u32, a: usize) -> usize {
|
|
|
|
if flag == 0 { 0 } else { <() as B>::method(flag, a) }
|
|
|
|
}
|
2022-02-12 17:32:09 +00:00
|
|
|
|
2022-05-08 17:11:53 +00:00
|
|
|
fn method_self(&self, flag: u32, a: usize) -> usize {
|
|
|
|
if flag == 0 { 0 } else { ().method_self(flag, a) }
|
|
|
|
}
|
2022-03-05 12:39:00 +00:00
|
|
|
}
|
|
|
|
|
2022-05-08 17:11:53 +00:00
|
|
|
trait C {
|
|
|
|
fn method(flag: u32, a: usize) -> usize {
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: parameter is only used in recursion
|
2022-05-08 17:11:53 +00:00
|
|
|
if flag == 0 { 0 } else { Self::method(flag - 1, a) }
|
|
|
|
}
|
2022-03-10 06:46:40 +00:00
|
|
|
|
2022-05-08 17:11:53 +00:00
|
|
|
fn method_self(&self, flag: u32, a: usize) -> usize {
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: parameter is only used in recursion
|
2022-05-08 17:11:53 +00:00
|
|
|
if flag == 0 { 0 } else { self.method_self(flag - 1, a) }
|
|
|
|
}
|
2022-03-10 06:46:40 +00:00
|
|
|
}
|
|
|
|
|
2022-05-08 17:11:53 +00:00
|
|
|
fn _ignore(flag: usize, _a: usize) -> usize {
|
|
|
|
if flag == 0 { 0 } else { _ignore(flag - 1, _a) }
|
2022-03-10 06:46:40 +00:00
|
|
|
}
|
|
|
|
|
2022-02-12 17:32:09 +00:00
|
|
|
fn main() {}
|