Use bool in favor of Option<()> for diagnostics
This commit is contained in:
parent
4d5b3b1962
commit
25ff9b6bcb
48 changed files with 106 additions and 121 deletions
|
@ -1564,7 +1564,7 @@ fn check_type_alias_type_params_are_used<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalD
|
|||
// * compare the param span to the pred span to detect lone user-written `Sized` bounds
|
||||
let has_explicit_bounds = bounded_params.is_empty()
|
||||
|| (*bounded_params).get(¶m.index).is_some_and(|&&pred_sp| pred_sp != span);
|
||||
let const_param_help = (!has_explicit_bounds).then_some(());
|
||||
let const_param_help = !has_explicit_bounds;
|
||||
|
||||
let mut diag = tcx.dcx().create_err(errors::UnusedGenericParameter {
|
||||
span,
|
||||
|
|
|
@ -1972,8 +1972,7 @@ fn report_bivariance<'tcx>(
|
|||
}
|
||||
|
||||
let const_param_help =
|
||||
matches!(param.kind, hir::GenericParamKind::Type { .. } if !has_explicit_bounds)
|
||||
.then_some(());
|
||||
matches!(param.kind, hir::GenericParamKind::Type { .. } if !has_explicit_bounds);
|
||||
|
||||
let mut diag = tcx.dcx().create_err(errors::UnusedGenericParameter {
|
||||
span: param.span,
|
||||
|
|
|
@ -1606,7 +1606,7 @@ pub(crate) struct UnusedGenericParameter {
|
|||
#[subdiagnostic]
|
||||
pub help: UnusedGenericParameterHelp,
|
||||
#[help(hir_analysis_const_param_help)]
|
||||
pub const_param_help: Option<()>,
|
||||
pub const_param_help: bool,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
@ -1643,9 +1643,9 @@ pub(crate) struct UnconstrainedGenericParameter {
|
|||
pub param_name: Symbol,
|
||||
pub param_def_kind: &'static str,
|
||||
#[note(hir_analysis_const_param_note)]
|
||||
pub const_param_note: Option<()>,
|
||||
pub const_param_note: bool,
|
||||
#[note(hir_analysis_const_param_note2)]
|
||||
pub const_param_note2: Option<()>,
|
||||
pub const_param_note2: bool,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
|
|
@ -137,8 +137,7 @@ fn enforce_impl_params_are_constrained(
|
|||
}
|
||||
};
|
||||
if err {
|
||||
let const_param_note =
|
||||
matches!(param.kind, ty::GenericParamDefKind::Const { .. }).then_some(());
|
||||
let const_param_note = matches!(param.kind, ty::GenericParamDefKind::Const { .. });
|
||||
let mut diag = tcx.dcx().create_err(UnconstrainedGenericParameter {
|
||||
span: tcx.def_span(param.def_id),
|
||||
param_name: param.name,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue