Closed
Description
trait X {
fn foo(bar: Bar);
}
But give it a default implementation that doesn’t use all those arguments (a perfectly plausible and reasonable situation):
trait X {
fn foo(bar: Bar) { }
}
<anon>:2:12: 2:15 warning: unused variable: `bar`, #[warn(unused_variables)] on by default
<anon>:2 fn foo(bar: Bar) { }
^~~
Arguments to a trait fn default implementation should be considered immune from unused variables warnings, because their names are a part of the API as it gets documented.
The alternatives are (a) prefixing the variable name with an underscore, which is ugly in generated API docs; and (b) tacking #[allow(unused_variables)]
onto the fn foo
, which then silences other legitimate unused variables warnings in the body of the function.