diff options
| author | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2020-09-23 21:04:07 -0700 |
|---|---|---|
| committer | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2020-09-23 21:04:07 -0700 |
| commit | a320ef751bcf3a0c09384cf887ea7eceab2fbee7 (patch) | |
| tree | a1fbd4f669c8c87ad372995acb918b83f97a221b | |
| parent | a6008fac97f81a3fc51668b0c7fa0e2e6f2a599b (diff) | |
| download | rust-a320ef751bcf3a0c09384cf887ea7eceab2fbee7.tar.gz rust-a320ef751bcf3a0c09384cf887ea7eceab2fbee7.zip | |
Suggest `const_mut_refs` for mutable references in const fn
| -rw-r--r-- | compiler/rustc_mir/src/transform/check_consts/ops.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/rustc_mir/src/transform/check_consts/ops.rs b/compiler/rustc_mir/src/transform/check_consts/ops.rs index e14dcf92b89..d978d927981 100644 --- a/compiler/rustc_mir/src/transform/check_consts/ops.rs +++ b/compiler/rustc_mir/src/transform/check_consts/ops.rs @@ -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::*; @@ -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() } } |
