Skip to content

Commit 415fd0c

Browse files
const prop: don't special case return place
1 parent 9e6f38a commit 415fd0c

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/librustc_mir/transform/const_prop.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -409,16 +409,12 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
409409
fn get_const(&self, local: Local) -> Option<OpTy<'tcx>> {
410410
let op = self.ecx.access_local(self.ecx.frame(), local, None).ok();
411411

412-
if local == RETURN_PLACE {
413-
// Try to read the return place as an immediate so that if it is representable as a
414-
// scalar, we can handle it as such, but otherwise, just return the value as is.
415-
return match op.map(|ret| self.ecx.try_read_immediate(ret)) {
416-
Some(Ok(Ok(imm))) => Some(imm.into()),
417-
_ => op,
418-
};
412+
// Try to read the local as an immediate so that if it is representable as a scalar, we can
413+
// handle it as such, but otherwise, just return the value as is.
414+
match op.map(|ret| self.ecx.try_read_immediate(ret)) {
415+
Some(Ok(Ok(imm))) => Some(imm.into()),
416+
_ => op,
419417
}
420-
421-
op
422418
}
423419

424420
fn remove_const(&mut self, local: Local) {

src/test/incremental/hashes/enum_constructors.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -274,29 +274,29 @@ pub enum Clike2 {
274274
// Change constructor path (C-like) --------------------------------------
275275
#[cfg(cfail1)]
276276
pub fn change_constructor_path_c_like() {
277-
let _ = Clike::B;
277+
let _x = Clike::B;
278278
}
279279

280280
#[cfg(not(cfail1))]
281281
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,mir_built,typeck_tables_of")]
282282
#[rustc_clean(cfg="cfail3")]
283283
pub fn change_constructor_path_c_like() {
284-
let _ = Clike2::B;
284+
let _x = Clike2::B;
285285
}
286286

287287

288288

289289
// Change constructor variant (C-like) --------------------------------------
290290
#[cfg(cfail1)]
291291
pub fn change_constructor_variant_c_like() {
292-
let _ = Clike::A;
292+
let _x = Clike::A;
293293
}
294294

295295
#[cfg(not(cfail1))]
296296
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,mir_built")]
297297
#[rustc_clean(cfg="cfail3")]
298298
pub fn change_constructor_variant_c_like() {
299-
let _ = Clike::C;
299+
let _x = Clike::C;
300300
}
301301

302302

0 commit comments

Comments
 (0)