From 7d2f9182e0a59a7c8a8c9dc37cdc5a3d06dc6f4f Mon Sep 17 00:00:00 2001 From: Matthias Kurz Date: Mon, 27 Feb 2023 19:19:00 +0100 Subject: [PATCH] scaladoc should take -Werror/-Xfatal-warnings into account --- .../tools/dotc/config/ScalaSettings.scala | 95 +++++++++---------- .../src/dotty/tools/scaladoc/Scaladoc.scala | 2 +- 2 files changed, 48 insertions(+), 49 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index a71f28f49410..068fe6d93127 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -111,6 +111,53 @@ trait CommonScalaSettings: val help: Setting[Boolean] = BooleanSetting("-help", "Print a synopsis of standard options.", aliases = List("--help", "-h")) val pageWidth: Setting[Int] = IntSetting("-pagewidth", "Set page width", ScalaSettings.defaultPageWidth, aliases = List("--page-width")) val silentWarnings: Setting[Boolean] = BooleanSetting("-nowarn", "Silence all warnings.", aliases = List("--no-warnings")) + val XfatalWarnings: Setting[Boolean] = BooleanSetting("-Werror", "Fail the compilation if there are any warnings.", aliases = List("-Xfatal-warnings")) + val Wconf: Setting[List[String]] = MultiStringSetting( + "-Wconf", + "patterns", + default = List(), + descr = + s"""Configure compiler warnings. + |Syntax: -Wconf::,:,... + |multiple are combined with &, i.e., &...& + | + | + | - Any message: any + | + | - Message categories: cat=deprecation, cat=feature, cat=unchecked + | + | - Message content: msg=regex + | The regex need only match some part of the message, not all of it. + | + | - Message id: id=E129 + | The message id is printed with the warning. + | + | - Message name: name=PureExpressionInStatementPosition + | The message name is printed with the warning in verbose warning mode. + | + |In verbose warning mode the compiler prints matching filters for warnings. + |Verbose mode can be enabled globally using `-Wconf:any:verbose`, or locally + |using the @nowarn annotation (example: `@nowarn("v") def test = try 1`). + | + | + | - error / e + | - warning / w + | - verbose / v (emit warning, show additional help for writing `-Wconf` filters) + | - info / i (infos are not counted as warnings and not affected by `-Werror`) + | - silent / s + | + |The default configuration is empty. + | + |User-defined configurations are added to the left. The leftmost rule matching + |a warning message defines the action. + | + |Examples: + | - change every warning into an error: -Wconf:any:error + | - silence deprecations: -Wconf:cat=deprecation:s + | + |Note: on the command-line you might need to quote configurations containing `*` or `&` + |to prevent the shell from expanding patterns.""".stripMargin, + ) 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")) @@ -162,7 +209,6 @@ private sealed trait WarningSettings: self: SettingGroup => val Whelp: Setting[Boolean] = BooleanSetting("-W", "Print a synopsis of warning options.") - val XfatalWarnings: Setting[Boolean] = BooleanSetting("-Werror", "Fail the compilation if there are any warnings.", aliases = List("-Xfatal-warnings")) val WvalueDiscard: Setting[Boolean] = BooleanSetting("-Wvalue-discard", "Warn when non-Unit expression results are unused.") val WNonUnitStatement = BooleanSetting("-Wnonunit-statement", "Warn when block statements are non-Unit expressions.") 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: def strictNoImplicitWarn(using Context) = isChoiceSet("strict-no-implicit-warn") - val Wconf: Setting[List[String]] = MultiStringSetting( - "-Wconf", - "patterns", - default = List(), - descr = - s"""Configure compiler warnings. - |Syntax: -Wconf::,:,... - |multiple are combined with &, i.e., &...& - | - | - | - Any message: any - | - | - Message categories: cat=deprecation, cat=feature, cat=unchecked - | - | - Message content: msg=regex - | The regex need only match some part of the message, not all of it. - | - | - Message id: id=E129 - | The message id is printed with the warning. - | - | - Message name: name=PureExpressionInStatementPosition - | The message name is printed with the warning in verbose warning mode. - | - |In verbose warning mode the compiler prints matching filters for warnings. - |Verbose mode can be enabled globally using `-Wconf:any:verbose`, or locally - |using the @nowarn annotation (example: `@nowarn("v") def test = try 1`). - | - | - | - error / e - | - warning / w - | - verbose / v (emit warning, show additional help for writing `-Wconf` filters) - | - info / i (infos are not counted as warnings and not affected by `-Werror`) - | - silent / s - | - |The default configuration is empty. - | - |User-defined configurations are added to the left. The leftmost rule matching - |a warning message defines the action. - | - |Examples: - | - change every warning into an error: -Wconf:any:error - | - silence deprecations: -Wconf:cat=deprecation:s - | - |Note: on the command-line you might need to quote configurations containing `*` or `&` - |to prevent the shell from expanding patterns.""".stripMargin, - ) - /** -X "Extended" or "Advanced" settings */ private sealed trait XSettings: self: SettingGroup => diff --git a/scaladoc/src/dotty/tools/scaladoc/Scaladoc.scala b/scaladoc/src/dotty/tools/scaladoc/Scaladoc.scala index 260529b024db..38413e5b5a2f 100644 --- a/scaladoc/src/dotty/tools/scaladoc/Scaladoc.scala +++ b/scaladoc/src/dotty/tools/scaladoc/Scaladoc.scala @@ -6,7 +6,7 @@ import java.nio.file.Paths import collection.immutable.ArraySeq -import dotty.tools.dotc.config.Settings._ +import dotty.tools.dotc.config.Settings.{Setting, SettingGroup} import dotty.tools.dotc.config.{ CommonScalaSettings, AllScalaSettings } import dotty.tools.dotc.reporting.Reporter import dotty.tools.dotc.core.Contexts._