Skip to content

Commit a320ef7

Browse files
Suggest const_mut_refs for mutable references in const fn
1 parent a6008fa commit a320ef7

File tree

1 file changed

+8
-1
lines changed
  • compiler/rustc_mir/src/transform/check_consts

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ impl NonConstOp for UnsizingCast {
535535
}
536536
}
537537

538+
// Types that cannot appear in the signature or locals of a `const fn`.
538539
pub mod ty {
539540
use super::*;
540541

@@ -548,7 +549,13 @@ pub mod ty {
548549
}
549550

550551
fn emit_error(&self, ccx: &ConstCx<'_, '_>, span: Span) {
551-
mcf_emit_error(ccx, span, "mutable references in const fn are unstable");
552+
feature_err(
553+
&ccx.tcx.sess.parse_sess,
554+
sym::const_mut_refs,
555+
span,
556+
&format!("mutable references are not allowed in {}s", ccx.const_kind()),
557+
)
558+
.emit()
552559
}
553560
}
554561

0 commit comments

Comments
 (0)