diff options
| author | Christian Poveda <christianpoveda@protonmail.com> | 2019-11-17 21:11:46 -0500 |
|---|---|---|
| committer | Christian Poveda <christianpoveda@protonmail.com> | 2019-12-02 09:03:40 -0500 |
| commit | bb2a4238946563ef87eed6fe7e833ca731fa4c79 (patch) | |
| tree | b0a509a835bc816aa00df5d4b0e4c04831553b39 /src | |
| parent | 12ac49afc9e1c33fe94f01dfca9efda4d7fed0b2 (diff) | |
| download | rust-bb2a4238946563ef87eed6fe7e833ca731fa4c79.tar.gz rust-bb2a4238946563ef87eed6fe7e833ca731fa4c79.zip | |
Allow &mut in const fns when feature gate is enabled
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/transform/qualify_min_const_fn.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/librustc_mir/transform/qualify_min_const_fn.rs b/src/librustc_mir/transform/qualify_min_const_fn.rs index e40d6a5952e..28240f6beca 100644 --- a/src/librustc_mir/transform/qualify_min_const_fn.rs +++ b/src/librustc_mir/transform/qualify_min_const_fn.rs @@ -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) { |
