]> git.lizzy.rs Git - rust.git/commitdiff
const prop: don't special case return place
authorJonas Schievink <jonasschievink@gmail.com>
Sun, 19 Apr 2020 12:25:07 +0000 (14:25 +0200)
committerJonas Schievink <jonasschievink@gmail.com>
Mon, 20 Apr 2020 19:18:20 +0000 (21:18 +0200)
src/librustc_mir/transform/const_prop.rs
src/test/incremental/hashes/enum_constructors.rs

index 1a0ac4a21dfa0c54ff1094c45fe79cba8c474cb1..39de685b1735bd2de45441a238f5e1f222d6ee84 100644 (file)
@@ -409,16 +409,12 @@ fn new(
     fn get_const(&self, local: Local) -> Option<OpTy<'tcx>> {
         let op = self.ecx.access_local(self.ecx.frame(), local, None).ok();
 
-        if local == RETURN_PLACE {
-            // Try to read the return place as an immediate so that if it is representable as a
-            // scalar, we can handle it as such, but otherwise, just return the value as is.
-            return match op.map(|ret| self.ecx.try_read_immediate(ret)) {
-                Some(Ok(Ok(imm))) => Some(imm.into()),
-                _ => op,
-            };
+        // Try to read the local as an immediate so that if it is representable as a scalar, we can
+        // handle it as such, but otherwise, just return the value as is.
+        match op.map(|ret| self.ecx.try_read_immediate(ret)) {
+            Some(Ok(Ok(imm))) => Some(imm.into()),
+            _ => op,
         }
-
-        op
     }
 
     fn remove_const(&mut self, local: Local) {
index 99c50f7e173568950164da76c0ee0d1703b3cd85..2c07cbcb2054b711f55bd91f8e0f7c337aa0183f 100644 (file)
@@ -274,14 +274,14 @@ pub enum Clike2 {
 // Change constructor path (C-like) --------------------------------------
 #[cfg(cfail1)]
 pub fn change_constructor_path_c_like() {
-    let _ = Clike::B;
+    let _x = Clike::B;
 }
 
 #[cfg(not(cfail1))]
 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,mir_built,typeck_tables_of")]
 #[rustc_clean(cfg="cfail3")]
 pub fn change_constructor_path_c_like() {
-    let _ = Clike2::B;
+    let _x = Clike2::B;
 }
 
 
@@ -289,14 +289,14 @@ pub fn change_constructor_path_c_like() {
 // Change constructor variant (C-like) --------------------------------------
 #[cfg(cfail1)]
 pub fn change_constructor_variant_c_like() {
-    let _ = Clike::A;
+    let _x = Clike::A;
 }
 
 #[cfg(not(cfail1))]
 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,mir_built")]
 #[rustc_clean(cfg="cfail3")]
 pub fn change_constructor_variant_c_like() {
-    let _ = Clike::C;
+    let _x = Clike::C;
 }