Skip to content

Commit

Permalink
Suggest const_mut_refs for mutable references in const fn
Browse files Browse the repository at this point in the history
  • Loading branch information
ecstatic-morse committed Sep 24, 2020
1 parent a6008fa commit a320ef7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion compiler/rustc_mir/src/transform/check_consts/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ impl NonConstOp for UnsizingCast {
}
}

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

Expand All @@ -548,7 +549,13 @@ pub mod ty {
}

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()
}
}

Expand Down

0 comments on commit a320ef7

Please sign in to comment.