Skip to content

Commit 192c4a0

Browse files
committed
Change how force-warn lint diagnostics are recorded.
`is_force_warn` is only possible for diagnostics with `Level::Warning`, but it is currently stored in `Diagnostic::code`, which every diagnostic has. This commit: - removes the boolean `DiagnosticId::Lint::is_force_warn` field; - adds a `ForceWarning` variant to `Level`. Benefits: - The common `Level::Warning` case now has no arguments, replacing lots of `Warning(None)` occurrences. - `rustc_session::lint::Level` and `rustc_errors::Level` are more similar, both having `ForceWarning` and `Warning`.
1 parent 141b31a commit 192c4a0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/parse/session.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ mod tests {
446446
Some(ignore_list),
447447
);
448448
let span = MultiSpan::from_span(mk_sp(BytePos(0), BytePos(1)));
449-
let non_fatal_diagnostic = build_diagnostic(DiagnosticLevel::Warning(None), Some(span));
449+
let non_fatal_diagnostic = build_diagnostic(DiagnosticLevel::Warning, Some(span));
450450
emitter.emit_diagnostic(&non_fatal_diagnostic);
451451
assert_eq!(num_emitted_errors.load(Ordering::Acquire), 0);
452452
assert_eq!(can_reset_errors.load(Ordering::Acquire), true);
@@ -470,7 +470,7 @@ mod tests {
470470
None,
471471
);
472472
let span = MultiSpan::from_span(mk_sp(BytePos(0), BytePos(1)));
473-
let non_fatal_diagnostic = build_diagnostic(DiagnosticLevel::Warning(None), Some(span));
473+
let non_fatal_diagnostic = build_diagnostic(DiagnosticLevel::Warning, Some(span));
474474
emitter.emit_diagnostic(&non_fatal_diagnostic);
475475
assert_eq!(num_emitted_errors.load(Ordering::Acquire), 1);
476476
assert_eq!(can_reset_errors.load(Ordering::Acquire), false);
@@ -507,8 +507,8 @@ mod tests {
507507
);
508508
let bar_span = MultiSpan::from_span(mk_sp(BytePos(0), BytePos(1)));
509509
let foo_span = MultiSpan::from_span(mk_sp(BytePos(21), BytePos(22)));
510-
let bar_diagnostic = build_diagnostic(DiagnosticLevel::Warning(None), Some(bar_span));
511-
let foo_diagnostic = build_diagnostic(DiagnosticLevel::Warning(None), Some(foo_span));
510+
let bar_diagnostic = build_diagnostic(DiagnosticLevel::Warning, Some(bar_span));
511+
let foo_diagnostic = build_diagnostic(DiagnosticLevel::Warning, Some(foo_span));
512512
let fatal_diagnostic = build_diagnostic(DiagnosticLevel::Fatal, None);
513513
emitter.emit_diagnostic(&bar_diagnostic);
514514
emitter.emit_diagnostic(&foo_diagnostic);

0 commit comments

Comments
 (0)