You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<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.
The text was updated successfully, but these errors were encountered:
Not certain how I missed the existing issues when searching for it. I suspect I accidentally had it filtered to only open issues. Ah well. I still think it should be done, but this issue is not necessary.
Fine, no warnings.
But give it a default implementation that doesn’t use all those arguments (a perfectly plausible and reasonable situation):
A warning:
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 thefn foo
, which then silences other legitimate unused variables warnings in the body of the function.The text was updated successfully, but these errors were encountered: