Skip to content

Commit bb2a423

Browse files
committed
Allow &mut in const fns when feature gate is enabled
1 parent 12ac49a commit bb2a423

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/librustc_mir/transform/qualify_min_const_fn.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,14 @@ pub fn is_min_const_fn(tcx: TyCtxt<'tcx>, def_id: DefId, body: &'a Body<'tcx>) -
8080
fn check_ty(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, span: Span, fn_def_id: DefId) -> McfResult {
8181
for ty in ty.walk() {
8282
match ty.kind {
83-
ty::Ref(_, _, hir::Mutability::Mutable) => return Err((
84-
span,
85-
"mutable references in const fn are unstable".into(),
86-
)),
83+
ty::Ref(_, _, hir::Mutability::Mutable) => {
84+
if !tcx.features().const_fn_mut_refs {
85+
return Err((
86+
span,
87+
"mutable references in const fn are unstable".into(),
88+
))
89+
}
90+
}
8791
ty::Opaque(..) => return Err((span, "`impl Trait` in const fn is unstable".into())),
8892
ty::FnPtr(..) => {
8993
if !tcx.const_fn_is_allowed_fn_ptr(fn_def_id) {

0 commit comments

Comments
 (0)