Rename DiagnosticImportance as DiagImportance.

This commit is contained in:
Nicholas Nethercote 2024-02-23 16:20:20 +11:00
parent 9b3520e876
commit 8f3b007abc
2 changed files with 14 additions and 16 deletions

View File

@ -318,12 +318,12 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
assert!(err.is_error()); assert!(err.is_error());
match op.importance() { match op.importance() {
ops::DiagnosticImportance::Primary => { ops::DiagImportance::Primary => {
let reported = err.emit(); let reported = err.emit();
self.error_emitted = Some(reported); self.error_emitted = Some(reported);
} }
ops::DiagnosticImportance::Secondary => self.secondary_errors.push(err), ops::DiagImportance::Secondary => self.secondary_errors.push(err),
} }
} }

View File

@ -29,7 +29,7 @@ pub enum Status {
} }
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub enum DiagnosticImportance { pub enum DiagImportance {
/// An operation that must be removed for const-checking to pass. /// An operation that must be removed for const-checking to pass.
Primary, Primary,
@ -44,8 +44,8 @@ pub trait NonConstOp<'tcx>: std::fmt::Debug {
Status::Forbidden Status::Forbidden
} }
fn importance(&self) -> DiagnosticImportance { fn importance(&self) -> DiagImportance {
DiagnosticImportance::Primary DiagImportance::Primary
} }
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx>; fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx>;
@ -427,10 +427,10 @@ impl<'tcx> NonConstOp<'tcx> for TransientCellBorrow {
/// it in the future for static items. /// it in the future for static items.
pub struct CellBorrow; pub struct CellBorrow;
impl<'tcx> NonConstOp<'tcx> for CellBorrow { impl<'tcx> NonConstOp<'tcx> for CellBorrow {
fn importance(&self) -> DiagnosticImportance { fn importance(&self) -> DiagImportance {
// Most likely the code will try to do mutation with these borrows, which // Most likely the code will try to do mutation with these borrows, which
// triggers its own errors. Only show this one if that does not happen. // triggers its own errors. Only show this one if that does not happen.
DiagnosticImportance::Secondary DiagImportance::Secondary
} }
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> {
// FIXME: Maybe a more elegant solution to this if else case // FIXME: Maybe a more elegant solution to this if else case
@ -463,10 +463,10 @@ impl<'tcx> NonConstOp<'tcx> for MutBorrow {
Status::Forbidden Status::Forbidden
} }
fn importance(&self) -> DiagnosticImportance { fn importance(&self) -> DiagImportance {
// Most likely the code will try to do mutation with these borrows, which // Most likely the code will try to do mutation with these borrows, which
// triggers its own errors. Only show this one if that does not happen. // triggers its own errors. Only show this one if that does not happen.
DiagnosticImportance::Secondary DiagImportance::Secondary
} }
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> {
@ -515,9 +515,9 @@ impl<'tcx> NonConstOp<'tcx> for MutDeref {
Status::Unstable(sym::const_mut_refs) Status::Unstable(sym::const_mut_refs)
} }
fn importance(&self) -> DiagnosticImportance { fn importance(&self) -> DiagImportance {
// Usually a side-effect of a `TransientMutBorrow` somewhere. // Usually a side-effect of a `TransientMutBorrow` somewhere.
DiagnosticImportance::Secondary DiagImportance::Secondary
} }
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> {
@ -625,12 +625,10 @@ pub mod ty {
Status::Unstable(sym::const_mut_refs) Status::Unstable(sym::const_mut_refs)
} }
fn importance(&self) -> DiagnosticImportance { fn importance(&self) -> DiagImportance {
match self.0 { match self.0 {
mir::LocalKind::Temp => DiagnosticImportance::Secondary, mir::LocalKind::Temp => DiagImportance::Secondary,
mir::LocalKind::ReturnPointer | mir::LocalKind::Arg => { mir::LocalKind::ReturnPointer | mir::LocalKind::Arg => DiagImportance::Primary,
DiagnosticImportance::Primary
}
} }
} }