Add missing docs and remove dead code

This commit is contained in:
Ryan Levick 2021-07-06 13:47:03 +02:00
parent 33cc7b1fe2
commit 5af5a6d49d
2 changed files with 11 additions and 5 deletions

View File

@ -521,7 +521,8 @@ pub fn struct_dummy(&self) -> DiagnosticBuilder<'_> {
} }
/// Construct a builder at the `Warning` level at the given `span` and with the `msg`. /// Construct a builder at the `Warning` level at the given `span` and with the `msg`.
/// Cancel the builder if warnings cannot be emitted ///
/// The builder will be canceled if warnings cannot be emitted.
pub fn struct_span_warn(&self, span: impl Into<MultiSpan>, msg: &str) -> DiagnosticBuilder<'_> { pub fn struct_span_warn(&self, span: impl Into<MultiSpan>, msg: &str) -> DiagnosticBuilder<'_> {
let mut result = self.struct_warn(msg); let mut result = self.struct_warn(msg);
result.set_span(span); result.set_span(span);
@ -529,6 +530,9 @@ pub fn struct_span_warn(&self, span: impl Into<MultiSpan>, msg: &str) -> Diagnos
} }
/// Construct a builder at the `Warning` level at the given `span` and with the `msg`. /// Construct a builder at the `Warning` level at the given `span` and with the `msg`.
///
/// This will "force" the warning meaning it will not be canceled even
/// if warnings cannot be emitted.
pub fn struct_span_force_warn( pub fn struct_span_force_warn(
&self, &self,
span: impl Into<MultiSpan>, span: impl Into<MultiSpan>,
@ -564,7 +568,8 @@ pub fn struct_span_warn_with_code(
} }
/// Construct a builder at the `Warning` level with the `msg`. /// Construct a builder at the `Warning` level with the `msg`.
/// Cancel the builder if warnings cannot be emitted ///
/// The builder will be canceled if warnings cannot be emitted.
pub fn struct_warn(&self, msg: &str) -> DiagnosticBuilder<'_> { pub fn struct_warn(&self, msg: &str) -> DiagnosticBuilder<'_> {
let mut result = DiagnosticBuilder::new(self, Level::Warning, msg); let mut result = DiagnosticBuilder::new(self, Level::Warning, msg);
if !self.flags.can_emit_warnings { if !self.flags.can_emit_warnings {
@ -574,6 +579,9 @@ pub fn struct_warn(&self, msg: &str) -> DiagnosticBuilder<'_> {
} }
/// Construct a builder at the `Warning` level with the `msg`. /// Construct a builder at the `Warning` level with the `msg`.
///
/// This will "force" a warning meaning it will not be canceled even
/// if warnings cannot be emitted.
pub fn struct_force_warn(&self, msg: &str) -> DiagnosticBuilder<'_> { pub fn struct_force_warn(&self, msg: &str) -> DiagnosticBuilder<'_> {
DiagnosticBuilder::new(self, Level::Warning, msg) DiagnosticBuilder::new(self, Level::Warning, msg)
} }

View File

@ -251,9 +251,6 @@ fn struct_lint_level_impl(
let has_future_breakage = let has_future_breakage =
future_incompatible.map_or(false, |incompat| incompat.future_breakage.is_some()); future_incompatible.map_or(false, |incompat| incompat.future_breakage.is_some());
let is_force_warn = matches!(level, Level::ForceWarn)
|| matches!(src, LintLevelSource::CommandLine(_, Level::ForceWarn));
let mut err = match (level, span) { let mut err = match (level, span) {
(Level::Allow, span) => { (Level::Allow, span) => {
if has_future_breakage { if has_future_breakage {
@ -359,6 +356,7 @@ fn struct_lint_level_impl(
} }
} }
let is_force_warn = matches!(level, Level::ForceWarn);
err.code(DiagnosticId::Lint { name, has_future_breakage, is_force_warn }); err.code(DiagnosticId::Lint { name, has_future_breakage, is_force_warn });
if let Some(future_incompatible) = future_incompatible { if let Some(future_incompatible) = future_incompatible {