@@ -409,11 +409,6 @@ impl<'tcx> NonConstOp<'tcx> for TransientCellBorrow {
409
409
fn status_in_item ( & self , _: & ConstCx < ' _ , ' tcx > ) -> Status {
410
410
Status :: Unstable ( sym:: const_refs_to_cell)
411
411
}
412
- fn importance ( & self ) -> DiagnosticImportance {
413
- // The cases that cannot possibly work will already emit a `CellBorrow`, so we should
414
- // not additionally emit a feature gate error if activating the feature gate won't work.
415
- DiagnosticImportance :: Secondary
416
- }
417
412
fn build_error ( & self , ccx : & ConstCx < ' _ , ' tcx > , span : Span ) -> DiagnosticBuilder < ' tcx > {
418
413
ccx. tcx
419
414
. sess
@@ -427,6 +422,11 @@ impl<'tcx> NonConstOp<'tcx> for TransientCellBorrow {
427
422
/// it in the future for static items.
428
423
pub struct CellBorrow ;
429
424
impl < ' tcx > NonConstOp < ' tcx > for CellBorrow {
425
+ fn importance ( & self ) -> DiagnosticImportance {
426
+ // Most likely the code will try to do mutation with these borrows, which
427
+ // triggers its own errors. Only show this one if that does not happen.
428
+ DiagnosticImportance :: Secondary
429
+ }
430
430
fn build_error ( & self , ccx : & ConstCx < ' _ , ' tcx > , span : Span ) -> DiagnosticBuilder < ' tcx > {
431
431
// FIXME: Maybe a more elegant solution to this if else case
432
432
if let hir:: ConstContext :: Static ( _) = ccx. const_kind ( ) {
@@ -459,8 +459,8 @@ impl<'tcx> NonConstOp<'tcx> for MutBorrow {
459
459
}
460
460
461
461
fn importance ( & self ) -> DiagnosticImportance {
462
- // If there were primary errors (like non-const function calls), do not emit further
463
- // errors about mutable references .
462
+ // Most likely the code will try to do mutation with these borrows, which
463
+ // triggers its own errors. Only show this one if that does not happen .
464
464
DiagnosticImportance :: Secondary
465
465
}
466
466
0 commit comments