Skip to content

Commit b518ccb

Browse files
Give MutDeref a real error message
1 parent de35c42 commit b518ccb

File tree

1 file changed

+9
-0
lines changed
  • compiler/rustc_mir/src/transform/check_consts

1 file changed

+9
-0
lines changed

compiler/rustc_mir/src/transform/check_consts/ops.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,15 @@ impl NonConstOp for MutDeref {
317317
fn status_in_item(&self, _: &ConstCx<'_, '_>) -> Status {
318318
Status::Unstable(sym::const_mut_refs)
319319
}
320+
321+
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
322+
feature_err(
323+
&ccx.tcx.sess.parse_sess,
324+
sym::const_mut_refs,
325+
span,
326+
&format!("mutation through a reference is not allowed in {}s", ccx.const_kind()),
327+
)
328+
}
320329
}
321330

322331
#[derive(Debug)]

0 commit comments

Comments
 (0)