Suggest const_mut_refs for mutable references in const fn

This commit is contained in:
Dylan MacKenzie 2020-09-23 21:04:07 -07:00
parent a6008fac97
commit a320ef751b

View file

@ -535,6 +535,7 @@ impl NonConstOp for UnsizingCast {
} }
} }
// Types that cannot appear in the signature or locals of a `const fn`.
pub mod ty { pub mod ty {
use super::*; use super::*;
@ -548,7 +549,13 @@ pub mod ty {
} }
fn emit_error(&self, ccx: &ConstCx<'_, '_>, span: Span) { fn emit_error(&self, ccx: &ConstCx<'_, '_>, span: Span) {
mcf_emit_error(ccx, span, "mutable references in const fn are unstable"); feature_err(
&ccx.tcx.sess.parse_sess,
sym::const_mut_refs,
span,
&format!("mutable references are not allowed in {}s", ccx.const_kind()),
)
.emit()
} }
} }