Use bool in favor of Option<()> for diagnostics

This commit is contained in:
Michael Goulet 2024-08-21 00:57:58 -04:00
parent 4d5b3b1962
commit 25ff9b6bcb
48 changed files with 106 additions and 121 deletions

View file

@ -1330,7 +1330,7 @@ impl UnreachablePub {
BuiltinUnreachablePub {
what,
suggestion: (vis_span, applicability),
help: exportable.then_some(()),
help: exportable,
},
);
}

View file

@ -77,7 +77,7 @@ pub struct UnknownToolInScopedLint {
pub tool_name: Symbol,
pub lint_name: String,
#[help]
pub is_nightly_build: Option<()>,
pub is_nightly_build: bool,
}
#[derive(Diagnostic)]

View file

@ -24,7 +24,7 @@ fn check_expectations(tcx: TyCtxt<'_>, tool_filter: Option<Symbol>) {
&& tool_filter.map_or(true, |filter| expectation.lint_tool == Some(filter))
{
let rationale = expectation.reason.map(|rationale| ExpectationNote { rationale });
let note = expectation.is_unfulfilled_lint_expectations.then_some(());
let note = expectation.is_unfulfilled_lint_expectations;
tcx.emit_node_span_lint(
UNFULFILLED_LINT_EXPECTATIONS,
*hir_id,

View file

@ -936,7 +936,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
span: tool_ident.map(|ident| ident.span),
tool_name: tool_name.unwrap(),
lint_name: pprust::path_to_string(&meta_item.path),
is_nightly_build: sess.is_nightly_build().then_some(()),
is_nightly_build: sess.is_nightly_build(),
});
continue;
}

View file

@ -257,7 +257,7 @@ pub struct BuiltinUnreachablePub<'a> {
#[suggestion(code = "pub(crate)")]
pub suggestion: (Span, Applicability),
#[help]
pub help: Option<()>,
pub help: bool,
}
#[derive(LintDiagnostic)]
@ -572,7 +572,7 @@ pub struct Expectation {
#[subdiagnostic]
pub rationale: Option<ExpectationNote>,
#[note]
pub note: Option<()>,
pub note: bool,
}
#[derive(Subdiagnostic)]
@ -756,7 +756,7 @@ pub enum InvalidReferenceCastingDiag<'tcx> {
#[label]
orig_cast: Option<Span>,
#[note(lint_invalid_reference_casting_note_ty_has_interior_mutability)]
ty_has_interior_mutability: Option<()>,
ty_has_interior_mutability: bool,
},
#[diag(lint_invalid_reference_casting_assign_to_ref)]
#[note(lint_invalid_reference_casting_note_book)]
@ -764,7 +764,7 @@ pub enum InvalidReferenceCastingDiag<'tcx> {
#[label]
orig_cast: Option<Span>,
#[note(lint_invalid_reference_casting_note_ty_has_interior_mutability)]
ty_has_interior_mutability: Option<()>,
ty_has_interior_mutability: bool,
},
#[diag(lint_invalid_reference_casting_bigger_layout)]
#[note(lint_layout)]

View file

@ -54,8 +54,6 @@ impl<'tcx> LateLintPass<'tcx> for InvalidReferenceCasting {
&& let Some(ty_has_interior_mutability) =
is_cast_from_ref_to_mut_ptr(cx, init, &mut peel_casts)
{
let ty_has_interior_mutability = ty_has_interior_mutability.then_some(());
cx.emit_span_lint(
INVALID_REFERENCE_CASTING,
expr.span,