Skip to content

Commit fd77500

Browse files
committed
Clear up nonpromotable const fn call qualification
1 parent ee7f4a2 commit fd77500

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/librustc_mir/transform/qualify_consts.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1000,11 +1000,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
10001000
}
10011001

10021002
// non-const fn calls.
1003-
if is_const_fn {
1004-
if !is_promotable_const_fn && self.mode == Mode::Fn {
1005-
self.qualif = Qualif::NOT_PROMOTABLE;
1006-
}
1007-
} else {
1003+
if !is_const_fn {
10081004
self.qualif = Qualif::NOT_CONST;
10091005
if self.mode != Mode::Fn {
10101006
self.tcx.sess.delay_span_bug(
@@ -1022,6 +1018,11 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
10221018
// Be conservative about the returned value of a const fn.
10231019
let tcx = self.tcx;
10241020
let ty = dest.ty(self.mir, tcx).to_ty(tcx);
1021+
if is_const_fn && !is_promotable_const_fn && self.mode == Mode::Fn {
1022+
self.qualif = Qualif::NOT_PROMOTABLE;
1023+
} else {
1024+
self.qualif = Qualif::empty();
1025+
}
10251026
self.add_type(ty);
10261027
}
10271028
self.assign(dest, location);

0 commit comments

Comments
 (0)