Skip to content

Commit

Permalink
Allow &mut in const fns when feature gate is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdrz committed Dec 2, 2019
1 parent 12ac49a commit bb2a423
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/librustc_mir/transform/qualify_min_const_fn.rs
Expand Up @@ -80,10 +80,14 @@ pub fn is_min_const_fn(tcx: TyCtxt<'tcx>, def_id: DefId, body: &'a Body<'tcx>) -
fn check_ty(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, span: Span, fn_def_id: DefId) -> McfResult {
for ty in ty.walk() {
match ty.kind {
ty::Ref(_, _, hir::Mutability::Mutable) => return Err((
span,
"mutable references in const fn are unstable".into(),
)),
ty::Ref(_, _, hir::Mutability::Mutable) => {
if !tcx.features().const_fn_mut_refs {
return Err((
span,
"mutable references in const fn are unstable".into(),
))
}
}
ty::Opaque(..) => return Err((span, "`impl Trait` in const fn is unstable".into())),
ty::FnPtr(..) => {
if !tcx.const_fn_is_allowed_fn_ptr(fn_def_id) {
Expand Down

0 comments on commit bb2a423

Please sign in to comment.