mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Rollup merge of #129344 - compiler-errors:less-option-unit-diagnostics, r=jieyouxu
Use `bool` in favor of `Option<()>` for diagnostics
We originally only supported `Option<()>` for optional notes/labels, but we now support `bool`. Let's use that, since it usually leads to more readable code.
I'm not removing the support from the derive macro, though I guess we could error on it... 🤔
This commit is contained in:
commit
937a18daf9
@ -86,9 +86,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
// Multiple different abi names may actually be the same ABI
|
||||
// If the specified ABIs are not the same name, alert the user that they resolve to the same ABI
|
||||
let source_map = self.tcx.sess.source_map();
|
||||
let equivalent = (source_map.span_to_snippet(*prev_sp)
|
||||
!= source_map.span_to_snippet(*abi_span))
|
||||
.then_some(());
|
||||
let equivalent = source_map.span_to_snippet(*prev_sp)
|
||||
!= source_map.span_to_snippet(*abi_span);
|
||||
|
||||
self.dcx().emit_err(AbiSpecifiedMultipleTimes {
|
||||
abi_span: *abi_span,
|
||||
|
@ -184,7 +184,7 @@ pub struct AbiSpecifiedMultipleTimes {
|
||||
#[label]
|
||||
pub prev_span: Span,
|
||||
#[note]
|
||||
pub equivalent: Option<()>,
|
||||
pub equivalent: bool,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
@ -963,14 +963,13 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||
self_ty,
|
||||
items,
|
||||
}) => {
|
||||
let error =
|
||||
|annotation_span, annotation, only_trait: bool| errors::InherentImplCannot {
|
||||
span: self_ty.span,
|
||||
annotation_span,
|
||||
annotation,
|
||||
self_ty: self_ty.span,
|
||||
only_trait: only_trait.then_some(()),
|
||||
};
|
||||
let error = |annotation_span, annotation, only_trait| errors::InherentImplCannot {
|
||||
span: self_ty.span,
|
||||
annotation_span,
|
||||
annotation,
|
||||
self_ty: self_ty.span,
|
||||
only_trait,
|
||||
};
|
||||
|
||||
self.with_in_trait_impl(None, |this| {
|
||||
this.visibility_not_permitted(
|
||||
@ -1195,7 +1194,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||
} else if where_clauses.after.has_where_token {
|
||||
self.dcx().emit_err(errors::WhereClauseAfterTypeAlias {
|
||||
span: where_clauses.after.span,
|
||||
help: self.session.is_nightly_build().then_some(()),
|
||||
help: self.session.is_nightly_build(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -484,7 +484,7 @@ pub struct InherentImplCannot<'a> {
|
||||
#[label(ast_passes_type)]
|
||||
pub self_ty: Span,
|
||||
#[note(ast_passes_only_trait)]
|
||||
pub only_trait: Option<()>,
|
||||
pub only_trait: bool,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
@ -528,7 +528,7 @@ pub struct WhereClauseAfterTypeAlias {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
#[help]
|
||||
pub help: Option<()>,
|
||||
pub help: bool,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
@ -846,7 +846,7 @@ pub fn find_deprecation(
|
||||
sess.dcx().emit_err(
|
||||
session_diagnostics::DeprecatedItemSuggestion {
|
||||
span: mi.span,
|
||||
is_nightly: sess.is_nightly_build().then_some(()),
|
||||
is_nightly: sess.is_nightly_build(),
|
||||
details: (),
|
||||
},
|
||||
);
|
||||
|
@ -342,7 +342,7 @@ pub(crate) struct DeprecatedItemSuggestion {
|
||||
pub span: Span,
|
||||
|
||||
#[help]
|
||||
pub is_nightly: Option<()>,
|
||||
pub is_nightly: bool,
|
||||
|
||||
#[note]
|
||||
pub details: (),
|
||||
|
@ -384,7 +384,7 @@ impl<'tcx> NonConstOp<'tcx> for HeapAllocation {
|
||||
ccx.dcx().create_err(errors::UnallowedHeapAllocations {
|
||||
span,
|
||||
kind: ccx.const_kind(),
|
||||
teach: ccx.tcx.sess.teach(E0010).then_some(()),
|
||||
teach: ccx.tcx.sess.teach(E0010),
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -444,16 +444,16 @@ impl<'tcx> NonConstOp<'tcx> for CellBorrow {
|
||||
if let hir::ConstContext::Static(_) = ccx.const_kind() {
|
||||
ccx.dcx().create_err(errors::InteriorMutableDataRefer {
|
||||
span,
|
||||
opt_help: Some(()),
|
||||
opt_help: true,
|
||||
kind: ccx.const_kind(),
|
||||
teach: ccx.tcx.sess.teach(E0492).then_some(()),
|
||||
teach: ccx.tcx.sess.teach(E0492),
|
||||
})
|
||||
} else {
|
||||
ccx.dcx().create_err(errors::InteriorMutableDataRefer {
|
||||
span,
|
||||
opt_help: None,
|
||||
opt_help: false,
|
||||
kind: ccx.const_kind(),
|
||||
teach: ccx.tcx.sess.teach(E0492).then_some(()),
|
||||
teach: ccx.tcx.sess.teach(E0492),
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -481,12 +481,12 @@ impl<'tcx> NonConstOp<'tcx> for MutBorrow {
|
||||
hir::BorrowKind::Raw => ccx.tcx.dcx().create_err(errors::UnallowedMutableRaw {
|
||||
span,
|
||||
kind: ccx.const_kind(),
|
||||
teach: ccx.tcx.sess.teach(E0764).then_some(()),
|
||||
teach: ccx.tcx.sess.teach(E0764),
|
||||
}),
|
||||
hir::BorrowKind::Ref => ccx.dcx().create_err(errors::UnallowedMutableRefs {
|
||||
span,
|
||||
kind: ccx.const_kind(),
|
||||
teach: ccx.tcx.sess.teach(E0764).then_some(()),
|
||||
teach: ccx.tcx.sess.teach(E0764),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ pub(crate) struct UnallowedMutableRefs {
|
||||
pub span: Span,
|
||||
pub kind: ConstContext,
|
||||
#[note(const_eval_teach_note)]
|
||||
pub teach: Option<()>,
|
||||
pub teach: bool,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
@ -161,7 +161,7 @@ pub(crate) struct UnallowedMutableRaw {
|
||||
pub span: Span,
|
||||
pub kind: ConstContext,
|
||||
#[note(const_eval_teach_note)]
|
||||
pub teach: Option<()>,
|
||||
pub teach: bool,
|
||||
}
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(const_eval_non_const_fmt_macro_call, code = E0015)]
|
||||
@ -196,7 +196,7 @@ pub(crate) struct UnallowedHeapAllocations {
|
||||
pub span: Span,
|
||||
pub kind: ConstContext,
|
||||
#[note(const_eval_teach_note)]
|
||||
pub teach: Option<()>,
|
||||
pub teach: bool,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
@ -214,10 +214,10 @@ pub(crate) struct InteriorMutableDataRefer {
|
||||
#[label]
|
||||
pub span: Span,
|
||||
#[help]
|
||||
pub opt_help: Option<()>,
|
||||
pub opt_help: bool,
|
||||
pub kind: ConstContext,
|
||||
#[note(const_eval_teach_note)]
|
||||
pub teach: Option<()>,
|
||||
pub teach: bool,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
@ -281,7 +281,7 @@ pub(crate) struct IncompleteParse<'a> {
|
||||
pub macro_path: &'a ast::Path,
|
||||
pub kind_name: &'a str,
|
||||
#[note(expand_macro_expands_to_match_arm)]
|
||||
pub expands_to_match_arm: Option<()>,
|
||||
pub expands_to_match_arm: bool,
|
||||
|
||||
#[suggestion(
|
||||
expand_suggestion_add_semi,
|
||||
|
@ -1031,7 +1031,7 @@ pub(crate) fn ensure_complete_parse<'a>(
|
||||
label_span: span,
|
||||
macro_path,
|
||||
kind_name,
|
||||
expands_to_match_arm: expands_to_match_arm.then_some(()),
|
||||
expands_to_match_arm,
|
||||
add_semicolon,
|
||||
});
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -505,7 +505,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
||||
span: self.span,
|
||||
expr_ty: self.expr_ty,
|
||||
cast_ty: fcx.ty_to_string(self.cast_ty),
|
||||
teach: fcx.tcx.sess.teach(E0607).then_some(()),
|
||||
teach: fcx.tcx.sess.teach(E0607),
|
||||
});
|
||||
}
|
||||
CastError::IntToFatCast(known_metadata) => {
|
||||
|
@ -706,7 +706,7 @@ pub(crate) struct CastThinPointerToFatPointer<'tcx> {
|
||||
pub expr_ty: Ty<'tcx>,
|
||||
pub cast_ty: String,
|
||||
#[note(hir_typeck_teach_help)]
|
||||
pub(crate) teach: Option<()>,
|
||||
pub(crate) teach: bool,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
@ -720,7 +720,7 @@ pub(crate) struct PassToVariadicFunction<'tcx, 'a> {
|
||||
pub sugg_span: Option<Span>,
|
||||
pub replace: String,
|
||||
#[help]
|
||||
pub help: Option<()>,
|
||||
pub help: bool,
|
||||
#[note(hir_typeck_teach_help)]
|
||||
pub(crate) teach: Option<()>,
|
||||
pub(crate) teach: bool,
|
||||
}
|
||||
|
@ -406,9 +406,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
) {
|
||||
let (sugg_span, replace, help) =
|
||||
if let Ok(snippet) = sess.source_map().span_to_snippet(span) {
|
||||
(Some(span), format!("{snippet} as {cast_ty}"), None)
|
||||
(Some(span), format!("{snippet} as {cast_ty}"), false)
|
||||
} else {
|
||||
(None, "".to_string(), Some(()))
|
||||
(None, "".to_string(), true)
|
||||
};
|
||||
|
||||
sess.dcx().emit_err(errors::PassToVariadicFunction {
|
||||
@ -418,7 +418,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
help,
|
||||
replace,
|
||||
sugg_span,
|
||||
teach: sess.teach(E0617).then_some(()),
|
||||
teach: sess.teach(E0617),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -189,10 +189,10 @@ pub struct CreateLock<'a> {
|
||||
pub lock_err: std::io::Error,
|
||||
pub session_dir: &'a Path,
|
||||
#[note(incremental_lock_unsupported)]
|
||||
pub is_unsupported_lock: Option<()>,
|
||||
pub is_unsupported_lock: bool,
|
||||
#[help(incremental_cargo_help_1)]
|
||||
#[help(incremental_cargo_help_2)]
|
||||
pub is_cargo: Option<()>,
|
||||
pub is_cargo: bool,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
@ -486,12 +486,12 @@ fn lock_directory(
|
||||
// the lock should be exclusive
|
||||
Ok(lock) => Ok((lock, lock_file_path)),
|
||||
Err(lock_err) => {
|
||||
let is_unsupported_lock = flock::Lock::error_unsupported(&lock_err).then_some(());
|
||||
let is_unsupported_lock = flock::Lock::error_unsupported(&lock_err);
|
||||
Err(sess.dcx().emit_err(errors::CreateLock {
|
||||
lock_err,
|
||||
session_dir,
|
||||
is_unsupported_lock,
|
||||
is_cargo: rustc_session::utils::was_invoked_from_cargo().then_some(()),
|
||||
is_cargo: rustc_session::utils::was_invoked_from_cargo(),
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
@ -1330,7 +1330,7 @@ impl UnreachablePub {
|
||||
BuiltinUnreachablePub {
|
||||
what,
|
||||
suggestion: (vis_span, applicability),
|
||||
help: exportable.then_some(()),
|
||||
help: exportable,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -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)]
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)]
|
||||
|
@ -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,
|
||||
|
@ -160,7 +160,7 @@ pub struct TypeLengthLimit {
|
||||
pub span: Span,
|
||||
pub shrunk: String,
|
||||
#[note(middle_written_to_path)]
|
||||
pub was_written: Option<()>,
|
||||
pub was_written: bool,
|
||||
pub path: PathBuf,
|
||||
pub type_length: usize,
|
||||
}
|
||||
|
@ -581,9 +581,9 @@ impl<'tcx> Instance<'tcx> {
|
||||
let mut path = PathBuf::new();
|
||||
let was_written = if let Some(path2) = written_to_path {
|
||||
path = path2;
|
||||
Some(())
|
||||
true
|
||||
} else {
|
||||
None
|
||||
false
|
||||
};
|
||||
tcx.dcx().emit_fatal(error::TypeLengthLimit {
|
||||
// We don't use `def_span(def_id)` so that diagnostics point
|
||||
|
@ -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()
|
||||
|
@ -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]
|
||||
@ -621,7 +621,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)]
|
||||
@ -863,7 +863,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>,
|
||||
|
@ -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,
|
||||
|
@ -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 => {
|
||||
|
@ -580,9 +580,9 @@ fn check_recursion_limit<'tcx>(
|
||||
let mut path = PathBuf::new();
|
||||
let was_written = if let Some(written_to_path) = written_to_path {
|
||||
path = written_to_path;
|
||||
Some(())
|
||||
true
|
||||
} else {
|
||||
None
|
||||
false
|
||||
};
|
||||
tcx.dcx().emit_fatal(RecursionLimit {
|
||||
span,
|
||||
|
@ -16,7 +16,7 @@ pub struct RecursionLimit {
|
||||
pub def_span: Span,
|
||||
pub def_path_str: String,
|
||||
#[note(monomorphize_written_to_path)]
|
||||
pub was_written: Option<()>,
|
||||
pub was_written: bool,
|
||||
pub path: PathBuf,
|
||||
}
|
||||
|
||||
|
@ -913,7 +913,7 @@ pub(crate) struct InvalidLiteralSuffixOnTupleIndex {
|
||||
#[help(parse_tuple_exception_line_1)]
|
||||
#[help(parse_tuple_exception_line_2)]
|
||||
#[help(parse_tuple_exception_line_3)]
|
||||
pub exception: Option<()>,
|
||||
pub exception: bool,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
@ -1299,7 +1299,7 @@ pub(crate) struct ComparisonOperatorsCannotBeChained {
|
||||
pub suggest_turbofish: Option<Span>,
|
||||
#[help(parse_sugg_turbofish_syntax)]
|
||||
#[help(parse_sugg_parentheses_for_function_args)]
|
||||
pub help_turbofish: Option<()>,
|
||||
pub help_turbofish: bool,
|
||||
#[subdiagnostic]
|
||||
pub chaining_sugg: Option<ComparisonOperatorsCannotBeChainedSugg>,
|
||||
}
|
||||
@ -1578,7 +1578,7 @@ pub(crate) struct PathSingleColon {
|
||||
pub suggestion: Span,
|
||||
|
||||
#[note(parse_type_ascription_removed)]
|
||||
pub type_ascription: Option<()>,
|
||||
pub type_ascription: bool,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
@ -1589,7 +1589,7 @@ pub(crate) struct ColonAsSemi {
|
||||
pub span: Span,
|
||||
|
||||
#[note(parse_type_ascription_removed)]
|
||||
pub type_ascription: Option<()>,
|
||||
pub type_ascription: bool,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
@ -2462,7 +2462,7 @@ pub(crate) struct TrailingVertNotAllowed {
|
||||
pub start: Option<Span>,
|
||||
pub token: Token,
|
||||
#[note(parse_note_pattern_alternatives_use_single_vert)]
|
||||
pub note_double_vert: Option<()>,
|
||||
pub note_double_vert: bool,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
@ -2894,7 +2894,7 @@ pub(crate) struct BadItemKind {
|
||||
pub descr: &'static str,
|
||||
pub ctx: &'static str,
|
||||
#[help]
|
||||
pub help: Option<()>,
|
||||
pub help: bool,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
@ -1403,7 +1403,7 @@ impl<'a> Parser<'a> {
|
||||
let mut err = ComparisonOperatorsCannotBeChained {
|
||||
span: vec![op.span, self.prev_token.span],
|
||||
suggest_turbofish: None,
|
||||
help_turbofish: None,
|
||||
help_turbofish: false,
|
||||
chaining_sugg: None,
|
||||
};
|
||||
|
||||
@ -1436,7 +1436,7 @@ impl<'a> Parser<'a> {
|
||||
{
|
||||
err.suggest_turbofish = Some(op.span.shrink_to_lo());
|
||||
} else {
|
||||
err.help_turbofish = Some(());
|
||||
err.help_turbofish = true;
|
||||
}
|
||||
|
||||
let snapshot = self.create_snapshot_for_diagnostic();
|
||||
@ -1468,7 +1468,7 @@ impl<'a> Parser<'a> {
|
||||
{
|
||||
err.suggest_turbofish = Some(op.span.shrink_to_lo());
|
||||
} else {
|
||||
err.help_turbofish = Some(());
|
||||
err.help_turbofish = true;
|
||||
}
|
||||
// Consume the fn call arguments.
|
||||
match self.consume_fn_args() {
|
||||
@ -1487,7 +1487,7 @@ impl<'a> Parser<'a> {
|
||||
{
|
||||
// All we know is that this is `foo < bar >` and *nothing* else. Try to
|
||||
// be helpful, but don't attempt to recover.
|
||||
err.help_turbofish = Some(());
|
||||
err.help_turbofish = true;
|
||||
}
|
||||
|
||||
// If it looks like a genuine attempt to chain operators (as opposed to a
|
||||
@ -1895,7 +1895,7 @@ impl<'a> Parser<'a> {
|
||||
{
|
||||
self.dcx().emit_err(ColonAsSemi {
|
||||
span: self.token.span,
|
||||
type_ascription: self.psess.unstable_features.is_nightly_build().then_some(()),
|
||||
type_ascription: self.psess.unstable_features.is_nightly_build(),
|
||||
});
|
||||
self.bump();
|
||||
return true;
|
||||
|
@ -2162,13 +2162,13 @@ impl<'a> Parser<'a> {
|
||||
self.dcx().emit_warn(errors::InvalidLiteralSuffixOnTupleIndex {
|
||||
span,
|
||||
suffix,
|
||||
exception: Some(()),
|
||||
exception: true,
|
||||
});
|
||||
} else {
|
||||
self.dcx().emit_err(errors::InvalidLiteralSuffixOnTupleIndex {
|
||||
span,
|
||||
suffix,
|
||||
exception: None,
|
||||
exception: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1248,8 +1248,8 @@ impl<'a> Parser<'a> {
|
||||
let span = self.psess.source_map().guess_head_span(span);
|
||||
let descr = kind.descr();
|
||||
let help = match kind {
|
||||
ItemKind::DelegationMac(deleg) if deleg.suffixes.is_none() => None,
|
||||
_ => Some(()),
|
||||
ItemKind::DelegationMac(deleg) if deleg.suffixes.is_none() => false,
|
||||
_ => true,
|
||||
};
|
||||
self.dcx().emit_err(errors::BadItemKind { span, descr, ctx, help });
|
||||
None
|
||||
|
@ -333,7 +333,7 @@ impl<'a> Parser<'a> {
|
||||
span: self.token.span,
|
||||
start: lo,
|
||||
token: self.token.clone(),
|
||||
note_double_vert: matches!(self.token.kind, token::OrOr).then_some(()),
|
||||
note_double_vert: matches!(self.token.kind, token::OrOr),
|
||||
});
|
||||
self.bump();
|
||||
true
|
||||
|
@ -261,11 +261,7 @@ impl<'a> Parser<'a> {
|
||||
self.dcx().emit_err(PathSingleColon {
|
||||
span: self.prev_token.span,
|
||||
suggestion: self.prev_token.span.shrink_to_hi(),
|
||||
type_ascription: self
|
||||
.psess
|
||||
.unstable_features
|
||||
.is_nightly_build()
|
||||
.then_some(()),
|
||||
type_ascription: self.psess.unstable_features.is_nightly_build(),
|
||||
});
|
||||
}
|
||||
continue;
|
||||
@ -334,11 +330,7 @@ impl<'a> Parser<'a> {
|
||||
err = self.dcx().create_err(PathSingleColon {
|
||||
span: self.token.span,
|
||||
suggestion: self.prev_token.span.shrink_to_hi(),
|
||||
type_ascription: self
|
||||
.psess
|
||||
.unstable_features
|
||||
.is_nightly_build()
|
||||
.then_some(()),
|
||||
type_ascription: self.psess.unstable_features.is_nightly_build(),
|
||||
});
|
||||
}
|
||||
// Attempt to find places where a missing `>` might belong.
|
||||
|
@ -2619,8 +2619,7 @@ fn check_duplicates(
|
||||
warning: matches!(
|
||||
duplicates,
|
||||
FutureWarnFollowing | FutureWarnPreceding
|
||||
)
|
||||
.then_some(()),
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ fn report_duplicate_item(
|
||||
orig_span,
|
||||
crate_name: tcx.crate_name(item_def_id.krate),
|
||||
orig_crate_name: tcx.crate_name(original_def_id.krate),
|
||||
different_crates: (item_def_id.krate != original_def_id.krate).then_some(()),
|
||||
different_crates: (item_def_id.krate != original_def_id.krate),
|
||||
name,
|
||||
});
|
||||
}
|
||||
|
@ -752,7 +752,7 @@ pub struct UnusedDuplicate {
|
||||
#[note]
|
||||
pub other: Span,
|
||||
#[warning]
|
||||
pub warning: Option<()>,
|
||||
pub warning: bool,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
@ -911,7 +911,7 @@ pub struct DuplicateDiagnosticItemInCrate {
|
||||
#[note(passes_diagnostic_item_first_defined)]
|
||||
pub orig_span: Option<Span>,
|
||||
#[note]
|
||||
pub different_crates: Option<()>,
|
||||
pub different_crates: bool,
|
||||
pub crate_name: Symbol,
|
||||
pub orig_crate_name: Symbol,
|
||||
pub name: Symbol,
|
||||
|
@ -1158,7 +1158,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
|
||||
fn contains_macro_use(&mut self, attrs: &[ast::Attribute]) -> bool {
|
||||
for attr in attrs {
|
||||
if attr.has_name(sym::macro_escape) {
|
||||
let inner_attribute = matches!(attr.style, ast::AttrStyle::Inner).then_some(());
|
||||
let inner_attribute = matches!(attr.style, ast::AttrStyle::Inner);
|
||||
self.r
|
||||
.dcx()
|
||||
.emit_warn(errors::MacroExternDeprecated { span: attr.span, inner_attribute });
|
||||
|
@ -850,7 +850,7 @@ pub(crate) struct MacroExternDeprecated {
|
||||
#[primary_span]
|
||||
pub(crate) span: Span,
|
||||
#[help]
|
||||
pub inner_attribute: Option<()>,
|
||||
pub inner_attribute: bool,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
@ -382,7 +382,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
infer_subdiags,
|
||||
multi_suggestions,
|
||||
bad_label,
|
||||
was_written: None,
|
||||
was_written: false,
|
||||
path: Default::default(),
|
||||
}),
|
||||
TypeAnnotationNeeded::E0283 => self.dcx().create_err(AmbiguousImpl {
|
||||
@ -393,7 +393,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
infer_subdiags,
|
||||
multi_suggestions,
|
||||
bad_label,
|
||||
was_written: None,
|
||||
was_written: false,
|
||||
path: Default::default(),
|
||||
}),
|
||||
TypeAnnotationNeeded::E0284 => self.dcx().create_err(AmbiguousReturn {
|
||||
@ -404,7 +404,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
infer_subdiags,
|
||||
multi_suggestions,
|
||||
bad_label,
|
||||
was_written: None,
|
||||
was_written: false,
|
||||
path: Default::default(),
|
||||
}),
|
||||
}
|
||||
@ -586,7 +586,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
infer_subdiags,
|
||||
multi_suggestions,
|
||||
bad_label: None,
|
||||
was_written: path.as_ref().map(|_| ()),
|
||||
was_written: path.is_some(),
|
||||
path: path.unwrap_or_default(),
|
||||
}),
|
||||
TypeAnnotationNeeded::E0283 => self.dcx().create_err(AmbiguousImpl {
|
||||
@ -597,7 +597,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
infer_subdiags,
|
||||
multi_suggestions,
|
||||
bad_label: None,
|
||||
was_written: path.as_ref().map(|_| ()),
|
||||
was_written: path.is_some(),
|
||||
path: path.unwrap_or_default(),
|
||||
}),
|
||||
TypeAnnotationNeeded::E0284 => self.dcx().create_err(AmbiguousReturn {
|
||||
@ -608,7 +608,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
infer_subdiags,
|
||||
multi_suggestions,
|
||||
bad_label: None,
|
||||
was_written: path.as_ref().map(|_| ()),
|
||||
was_written: path.is_some(),
|
||||
path: path.unwrap_or_default(),
|
||||
}),
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ pub struct AnnotationRequired<'a> {
|
||||
#[subdiagnostic]
|
||||
pub multi_suggestions: Vec<SourceKindMultiSuggestion<'a>>,
|
||||
#[note(trait_selection_full_type_written)]
|
||||
pub was_written: Option<()>,
|
||||
pub was_written: bool,
|
||||
pub path: PathBuf,
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ pub struct AmbiguousImpl<'a> {
|
||||
#[subdiagnostic]
|
||||
pub multi_suggestions: Vec<SourceKindMultiSuggestion<'a>>,
|
||||
#[note(trait_selection_full_type_written)]
|
||||
pub was_written: Option<()>,
|
||||
pub was_written: bool,
|
||||
pub path: PathBuf,
|
||||
}
|
||||
|
||||
@ -245,7 +245,7 @@ pub struct AmbiguousReturn<'a> {
|
||||
#[subdiagnostic]
|
||||
pub multi_suggestions: Vec<SourceKindMultiSuggestion<'a>>,
|
||||
#[note(trait_selection_full_type_written)]
|
||||
pub was_written: Option<()>,
|
||||
pub was_written: bool,
|
||||
pub path: PathBuf,
|
||||
}
|
||||
|
||||
|
@ -284,7 +284,7 @@ fn error(
|
||||
) -> Result<!, ErrorGuaranteed> {
|
||||
let reported = tcx.dcx().emit_err(GenericConstantTooComplex {
|
||||
span: root_span,
|
||||
maybe_supported: None,
|
||||
maybe_supported: false,
|
||||
sub,
|
||||
});
|
||||
|
||||
@ -298,7 +298,7 @@ fn maybe_supported_error(
|
||||
) -> Result<!, ErrorGuaranteed> {
|
||||
let reported = tcx.dcx().emit_err(GenericConstantTooComplex {
|
||||
span: root_span,
|
||||
maybe_supported: Some(()),
|
||||
maybe_supported: true,
|
||||
sub,
|
||||
});
|
||||
|
||||
|
@ -18,7 +18,7 @@ pub struct GenericConstantTooComplex {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
#[note(ty_utils_maybe_supported)]
|
||||
pub maybe_supported: Option<()>,
|
||||
pub maybe_supported: bool,
|
||||
#[subdiagnostic]
|
||||
pub sub: GenericConstantTooComplexSub,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user