@@ -409,11 +409,6 @@ impl<'tcx> NonConstOp<'tcx> for TransientCellBorrow {
409409 fn status_in_item ( & self , _: & ConstCx < ' _ , ' tcx > ) -> Status {
410410 Status :: Unstable ( sym:: const_refs_to_cell)
411411 }
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- }
417412 fn build_error ( & self , ccx : & ConstCx < ' _ , ' tcx > , span : Span ) -> DiagnosticBuilder < ' tcx > {
418413 ccx. tcx
419414 . sess
@@ -427,6 +422,11 @@ impl<'tcx> NonConstOp<'tcx> for TransientCellBorrow {
427422/// it in the future for static items.
428423pub struct CellBorrow ;
429424impl < ' 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+ }
430430 fn build_error ( & self , ccx : & ConstCx < ' _ , ' tcx > , span : Span ) -> DiagnosticBuilder < ' tcx > {
431431 // FIXME: Maybe a more elegant solution to this if else case
432432 if let hir:: ConstContext :: Static ( _) = ccx. const_kind ( ) {
@@ -459,8 +459,8 @@ impl<'tcx> NonConstOp<'tcx> for MutBorrow {
459459 }
460460
461461 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 .
464464 DiagnosticImportance :: Secondary
465465 }
466466
0 commit comments