@@ -72,7 +72,10 @@ case class AB(a: Int, b: String)
72
72
object Main {
73
73
val example = AB (42 , " lol" )
74
74
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" )
76
79
}
77
80
}
78
81
// after
@@ -81,16 +84,16 @@ object Main {
81
84
example match {
82
85
case AB (_, _) => println(" Not used" )
83
86
}
87
+ example match {
88
+ case AB (a, b) => println(" Not used, but canonical names" )
89
+ }
84
90
}
85
91
```
86
92
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.
92
95
93
- ### Remove unused function parameters (Scala 2 only)
96
+ ### Remove unused function parameters
94
97
95
98
``` scala
96
99
// before
@@ -103,6 +106,8 @@ object Main {
103
106
}
104
107
```
105
108
109
+ On Scala 3, this is only supported for 3.7.0+.
110
+
106
111
## Formatting
107
112
108
113
> This rule does a best-effort at preserving original formatting. In some cases,
@@ -176,8 +181,7 @@ $ scala3 -W
176
181
- nowarn,
177
182
- all,
178
183
- 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.,
181
185
- privates :
182
186
Warn if a private member is unused,
183
187
- locals :
@@ -188,13 +192,13 @@ $ scala3 -W
188
192
Warn if an implicit parameter is unused,
189
193
- params :
190
194
Enable -Wunused:explicits,implicits,
195
+ - patvars :
196
+ Warn if a variable bound in a pattern is unused,
191
197
- linted :
192
198
Enable -Wunused:imports,privates,locals,implicits,
193
199
- strict-no-implicit-warn :
194
200
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,
196
202
- 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`
200
204
```
0 commit comments