@@ -72,7 +72,10 @@ case class AB(a: Int, b: String)
7272object Main {
7373 val example = AB (42 , " lol" )
7474 example match {
75- case AB (a, b) => println(" Not used" )
75+ case AB (foo, bar) => println(" Not used" )
76+ }
77+ example match {
78+ case AB (a, b) => println(" Not used, but canonical names" )
7679 }
7780}
7881// after
@@ -81,16 +84,16 @@ object Main {
8184 example match {
8285 case AB (_, _) => println(" Not used" )
8386 }
87+ example match {
88+ case AB (a, b) => println(" Not used, but canonical names" )
89+ }
8490}
8591```
8692
87- On Scala 3, ` -Wunused:unsafe-warn-patvars ` is required.
88-
89- On Scala 2.13.15+, canonical patterns (vars with the same names as the
90- attributes) do not trigger unused warnings, so the input above will not
91- be rewritten. See https://github.com/scala/bug/issues/13035 .
93+ On Scala 3, an additional ` -Wunused:unsafe-warn-patvars ` option is required
94+ until Scala 3.7.0.
9295
93- ### Remove unused function parameters (Scala 2 only)
96+ ### Remove unused function parameters
9497
9598``` scala
9699// before
@@ -103,6 +106,8 @@ object Main {
103106}
104107```
105108
109+ On Scala 3, this is only supported for 3.7.0+.
110+
106111## Formatting
107112
108113> This rule does a best-effort at preserving original formatting. In some cases,
@@ -176,8 +181,7 @@ $ scala3 -W
176181 - nowarn,
177182 - all,
178183 - imports :
179- Warn if an import selector is not referenced.
180- NOTE : overrided by -Wunused:strict-no-implicit-warn,
184+ Warn if an import selector is not referenced.,
181185 - privates :
182186 Warn if a private member is unused,
183187 - locals :
@@ -188,13 +192,13 @@ $ scala3 -W
188192 Warn if an implicit parameter is unused,
189193 - params :
190194 Enable -Wunused:explicits,implicits,
195+ - patvars :
196+ Warn if a variable bound in a pattern is unused,
191197 - linted :
192198 Enable -Wunused:imports,privates,locals,implicits,
193199 - strict-no-implicit-warn :
194200 Same as -Wunused:import, only for imports of explicit named members.
195- NOTE : This overrides -Wunused:imports and NOT set by -Wunused:all,
201+ NOTE : This overrides -Wunused:imports and NOT set by -Wunused:all,
196202 - unsafe-warn-patvars :
197- (UNSAFE) Warn if a variable bound in a pattern is unused.
198- This warning can generate false positive, as warning cannot be
199- suppressed yet.
203+ Deprecated alias for `patvars`
200204```
0 commit comments