Skip to content

Commit 7d2f918

Browse files
mkurzsom-snytt
authored andcommitted
scaladoc should take -Werror/-Xfatal-warnings into account
1 parent 16f1680 commit 7d2f918

File tree

2 files changed

+48
-49
lines changed

2 files changed

+48
-49
lines changed

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 47 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,53 @@ trait CommonScalaSettings:
111111
val help: Setting[Boolean] = BooleanSetting("-help", "Print a synopsis of standard options.", aliases = List("--help", "-h"))
112112
val pageWidth: Setting[Int] = IntSetting("-pagewidth", "Set page width", ScalaSettings.defaultPageWidth, aliases = List("--page-width"))
113113
val silentWarnings: Setting[Boolean] = BooleanSetting("-nowarn", "Silence all warnings.", aliases = List("--no-warnings"))
114+
val XfatalWarnings: Setting[Boolean] = BooleanSetting("-Werror", "Fail the compilation if there are any warnings.", aliases = List("-Xfatal-warnings"))
115+
val Wconf: Setting[List[String]] = MultiStringSetting(
116+
"-Wconf",
117+
"patterns",
118+
default = List(),
119+
descr =
120+
s"""Configure compiler warnings.
121+
|Syntax: -Wconf:<filters>:<action>,<filters>:<action>,...
122+
|multiple <filters> are combined with &, i.e., <filter>&...&<filter>
123+
|
124+
|<filter>
125+
| - Any message: any
126+
|
127+
| - Message categories: cat=deprecation, cat=feature, cat=unchecked
128+
|
129+
| - Message content: msg=regex
130+
| The regex need only match some part of the message, not all of it.
131+
|
132+
| - Message id: id=E129
133+
| The message id is printed with the warning.
134+
|
135+
| - Message name: name=PureExpressionInStatementPosition
136+
| The message name is printed with the warning in verbose warning mode.
137+
|
138+
|In verbose warning mode the compiler prints matching filters for warnings.
139+
|Verbose mode can be enabled globally using `-Wconf:any:verbose`, or locally
140+
|using the @nowarn annotation (example: `@nowarn("v") def test = try 1`).
141+
|
142+
|<action>
143+
| - error / e
144+
| - warning / w
145+
| - verbose / v (emit warning, show additional help for writing `-Wconf` filters)
146+
| - info / i (infos are not counted as warnings and not affected by `-Werror`)
147+
| - silent / s
148+
|
149+
|The default configuration is empty.
150+
|
151+
|User-defined configurations are added to the left. The leftmost rule matching
152+
|a warning message defines the action.
153+
|
154+
|Examples:
155+
| - change every warning into an error: -Wconf:any:error
156+
| - silence deprecations: -Wconf:cat=deprecation:s
157+
|
158+
|Note: on the command-line you might need to quote configurations containing `*` or `&`
159+
|to prevent the shell from expanding patterns.""".stripMargin,
160+
)
114161

115162
val javaOutputVersion: Setting[String] = ChoiceSetting("-java-output-version", "version", "Compile code with classes specific to the given version of the Java platform available on the classpath and emit bytecode for this version. Corresponds to -release flag in javac.", ScalaSettings.supportedReleaseVersions, "", aliases = List("-release", "--release"))
116163

@@ -162,7 +209,6 @@ private sealed trait WarningSettings:
162209
self: SettingGroup =>
163210

164211
val Whelp: Setting[Boolean] = BooleanSetting("-W", "Print a synopsis of warning options.")
165-
val XfatalWarnings: Setting[Boolean] = BooleanSetting("-Werror", "Fail the compilation if there are any warnings.", aliases = List("-Xfatal-warnings"))
166212
val WvalueDiscard: Setting[Boolean] = BooleanSetting("-Wvalue-discard", "Warn when non-Unit expression results are unused.")
167213
val WNonUnitStatement = BooleanSetting("-Wnonunit-statement", "Warn when block statements are non-Unit expressions.")
168214
val WimplausiblePatterns = BooleanSetting("-Wimplausible-patterns", "Warn if comparison with a pattern value looks like it might always fail.")
@@ -225,53 +271,6 @@ private sealed trait WarningSettings:
225271
def strictNoImplicitWarn(using Context) =
226272
isChoiceSet("strict-no-implicit-warn")
227273

228-
val Wconf: Setting[List[String]] = MultiStringSetting(
229-
"-Wconf",
230-
"patterns",
231-
default = List(),
232-
descr =
233-
s"""Configure compiler warnings.
234-
|Syntax: -Wconf:<filters>:<action>,<filters>:<action>,...
235-
|multiple <filters> are combined with &, i.e., <filter>&...&<filter>
236-
|
237-
|<filter>
238-
| - Any message: any
239-
|
240-
| - Message categories: cat=deprecation, cat=feature, cat=unchecked
241-
|
242-
| - Message content: msg=regex
243-
| The regex need only match some part of the message, not all of it.
244-
|
245-
| - Message id: id=E129
246-
| The message id is printed with the warning.
247-
|
248-
| - Message name: name=PureExpressionInStatementPosition
249-
| The message name is printed with the warning in verbose warning mode.
250-
|
251-
|In verbose warning mode the compiler prints matching filters for warnings.
252-
|Verbose mode can be enabled globally using `-Wconf:any:verbose`, or locally
253-
|using the @nowarn annotation (example: `@nowarn("v") def test = try 1`).
254-
|
255-
|<action>
256-
| - error / e
257-
| - warning / w
258-
| - verbose / v (emit warning, show additional help for writing `-Wconf` filters)
259-
| - info / i (infos are not counted as warnings and not affected by `-Werror`)
260-
| - silent / s
261-
|
262-
|The default configuration is empty.
263-
|
264-
|User-defined configurations are added to the left. The leftmost rule matching
265-
|a warning message defines the action.
266-
|
267-
|Examples:
268-
| - change every warning into an error: -Wconf:any:error
269-
| - silence deprecations: -Wconf:cat=deprecation:s
270-
|
271-
|Note: on the command-line you might need to quote configurations containing `*` or `&`
272-
|to prevent the shell from expanding patterns.""".stripMargin,
273-
)
274-
275274
/** -X "Extended" or "Advanced" settings */
276275
private sealed trait XSettings:
277276
self: SettingGroup =>

scaladoc/src/dotty/tools/scaladoc/Scaladoc.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import java.nio.file.Paths
66

77
import collection.immutable.ArraySeq
88

9-
import dotty.tools.dotc.config.Settings._
9+
import dotty.tools.dotc.config.Settings.{Setting, SettingGroup}
1010
import dotty.tools.dotc.config.{ CommonScalaSettings, AllScalaSettings }
1111
import dotty.tools.dotc.reporting.Reporter
1212
import dotty.tools.dotc.core.Contexts._

0 commit comments

Comments
 (0)