]> git.lizzy.rs Git - rust.git/commitdiff
Remove `QUALIF_ERROR_BIT` checking
authorDylan MacKenzie <ecstaticmorse@gmail.com>
Thu, 14 Nov 2019 00:56:08 +0000 (16:56 -0800)
committerDylan MacKenzie <ecstaticmorse@gmail.com>
Fri, 15 Nov 2019 18:33:31 +0000 (10:33 -0800)
src/librustc_mir/transform/promote_consts.rs
src/librustc_mir/transform/qualify_consts.rs

index b4da437279db13279325a63f365ced78a993b088..c79d382a37480a9c6a5a1787bc458036a570077a 100644 (file)
@@ -582,30 +582,9 @@ fn validate_operand(&self, operand: &Operand<'tcx>) -> Result<(), Unpromotable>
             Operand::Copy(place) |
             Operand::Move(place) => self.validate_place(place.as_ref()),
 
-            Operand::Constant(constant) => {
-                if let ty::ConstKind::Unevaluated(def_id, _) = constant.literal.val {
-                    if self.tcx.trait_of_item(def_id).is_some() {
-                        // Don't peek inside trait associated constants.
-                        // (see below what we do for other consts, for now)
-                    } else {
-                        // HACK(eddyb) ensure that errors propagate correctly.
-                        // FIXME(eddyb) remove this once the old promotion logic
-                        // is gone - we can always promote constants even if they
-                        // fail to pass const-checking, as compilation would've
-                        // errored independently and promotion can't change that.
-                        let bits = self.tcx.at(constant.span).mir_const_qualif(def_id);
-                        if bits == super::qualify_consts::QUALIF_ERROR_BIT {
-                            self.tcx.sess.delay_span_bug(
-                                constant.span,
-                                "promote_consts: MIR had errors",
-                            );
-                            return Err(Unpromotable);
-                        }
-                    }
-                }
-
-                Ok(())
-            }
+            // The qualifs for a constant (e.g. `HasMutInterior`) are checked in
+            // `validate_rvalue` upon access.
+            Operand::Constant(_) => Ok(()),
         }
     }
 
index 964efdec2b9d227e4016a522ef60c3b47c9624f4..ee5dfae6ce2512276f7cef70a5247bfe2cef38c4 100644 (file)
@@ -1285,7 +1285,7 @@ fn mir_const_qualif(tcx: TyCtxt<'_>, def_id: DefId) -> u8 {
 
     if body.return_ty().references_error() {
         tcx.sess.delay_span_bug(body.span, "mir_const_qualif: MIR had errors");
-        return QUALIF_ERROR_BIT;
+        return 0;
     }
 
     Checker::new(tcx, def_id, body, Mode::Const).check_const()