From fd77500ed1d12dfdffff95e65530c2806a324f22 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Thu, 25 Oct 2018 21:18:22 +0200 Subject: [PATCH] Clear up nonpromotable const fn call qualification --- src/librustc_mir/transform/qualify_consts.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 1305d02a87b6a..e7d694ffba91c 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -1000,11 +1000,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { } // non-const fn calls. - if is_const_fn { - if !is_promotable_const_fn && self.mode == Mode::Fn { - self.qualif = Qualif::NOT_PROMOTABLE; - } - } else { + if !is_const_fn { self.qualif = Qualif::NOT_CONST; if self.mode != Mode::Fn { self.tcx.sess.delay_span_bug( @@ -1022,6 +1018,11 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { // Be conservative about the returned value of a const fn. let tcx = self.tcx; let ty = dest.ty(self.mir, tcx).to_ty(tcx); + if is_const_fn && !is_promotable_const_fn && self.mode == Mode::Fn { + self.qualif = Qualif::NOT_PROMOTABLE; + } else { + self.qualif = Qualif::empty(); + } self.add_type(ty); } self.assign(dest, location);