1
Fork 0

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

@ -793,7 +793,7 @@ impl UnsafeOpKind {
missing.iter().map(|feature| Cow::from(feature.to_string())).collect(),
),
missing_target_features_count: missing.len(),
note: if build_enabled.is_empty() { None } else { Some(()) },
note: !build_enabled.is_empty(),
build_target_features: DiagArgValue::StrListSepByAnd(
build_enabled
.iter()
@ -958,7 +958,7 @@ impl UnsafeOpKind {
missing.iter().map(|feature| Cow::from(feature.to_string())).collect(),
),
missing_target_features_count: missing.len(),
note: if build_enabled.is_empty() { None } else { Some(()) },
note: !build_enabled.is_empty(),
build_target_features: DiagArgValue::StrListSepByAnd(
build_enabled
.iter()
@ -977,7 +977,7 @@ impl UnsafeOpKind {
missing.iter().map(|feature| Cow::from(feature.to_string())).collect(),
),
missing_target_features_count: missing.len(),
note: if build_enabled.is_empty() { None } else { Some(()) },
note: !build_enabled.is_empty(),
build_target_features: DiagArgValue::StrListSepByAnd(
build_enabled
.iter()

View file

@ -161,7 +161,7 @@ pub(crate) struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe {
pub(crate) missing_target_features: DiagArgValue,
pub(crate) missing_target_features_count: usize,
#[note]
pub(crate) note: Option<()>,
pub(crate) note: bool,
pub(crate) build_target_features: DiagArgValue,
pub(crate) build_target_features_count: usize,
#[subdiagnostic]
@ -413,7 +413,7 @@ pub(crate) struct CallToFunctionWithRequiresUnsafe {
pub(crate) missing_target_features: DiagArgValue,
pub(crate) missing_target_features_count: usize,
#[note]
pub(crate) note: Option<()>,
pub(crate) note: bool,
pub(crate) build_target_features: DiagArgValue,
pub(crate) build_target_features_count: usize,
#[subdiagnostic]
@ -431,7 +431,7 @@ pub(crate) struct CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
pub(crate) missing_target_features: DiagArgValue,
pub(crate) missing_target_features_count: usize,
#[note]
pub(crate) note: Option<()>,
pub(crate) note: bool,
pub(crate) build_target_features: DiagArgValue,
pub(crate) build_target_features_count: usize,
#[subdiagnostic]
@ -623,7 +623,7 @@ pub(crate) struct LowerRangeBoundMustBeLessThanOrEqualToUpper {
#[label]
pub(crate) span: Span,
#[note(mir_build_teach_note)]
pub(crate) teach: Option<()>,
pub(crate) teach: bool,
}
#[derive(Diagnostic)]
@ -865,7 +865,7 @@ pub(crate) struct PatternNotCovered<'s, 'tcx> {
#[subdiagnostic]
pub(crate) adt_defined_here: Option<AdtDefinedHere<'tcx>>,
#[note(mir_build_privately_uninhabited)]
pub(crate) witness_1_is_privately_uninhabited: Option<()>,
pub(crate) witness_1_is_privately_uninhabited: bool,
#[note(mir_build_pattern_ty)]
pub(crate) _p: (),
pub(crate) pattern_ty: Ty<'tcx>,

View file

@ -718,7 +718,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
uncovered: Uncovered::new(pat.span, &cx, witnesses),
inform,
interpreted_as_const,
witness_1_is_privately_uninhabited: witness_1_is_privately_uninhabited.then_some(()),
witness_1_is_privately_uninhabited,
_p: (),
pattern_ty,
let_suggestion,

View file

@ -256,7 +256,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
RangeEnd::Included => {
self.tcx.dcx().emit_err(LowerRangeBoundMustBeLessThanOrEqualToUpper {
span,
teach: self.tcx.sess.teach(E0030).then_some(()),
teach: self.tcx.sess.teach(E0030),
})
}
RangeEnd::Excluded => {