Skip to content

Commit c3e1e7a

Browse files
committed
simplify more, ret_deref -> has_deref
1 parent c0e4230 commit c3e1e7a

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

compiler/rustc_codegen_ssa/src/mir/place.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -435,13 +435,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
435435
LocalRef::Place(place) => place,
436436
LocalRef::UnsizedPlace(place) => bx.load_operand(place).deref(cx),
437437
LocalRef::Operand(..) => {
438-
if place_ref.ret_deref().is_some() {
438+
if place_ref.has_deref() {
439439
base = 1;
440440
let cg_base = self.codegen_consume(
441441
bx,
442442
mir::PlaceRef { projection: &place_ref.projection[..0], ..place_ref },
443443
);
444-
445444
cg_base.deref(bx.cx())
446445
} else {
447446
bug!("using operand local {:?} as place", place_ref);

compiler/rustc_middle/src/mir/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1463,11 +1463,11 @@ impl<'tcx> Place<'tcx> {
14631463

14641464
/// If MirPhase >= Derefered and if projection contains Deref,
14651465
/// It's guaranteed to be in the first place
1466-
pub fn ret_deref(&self) -> Option<PlaceElem<'tcx>> {
1466+
pub fn has_deref(&self) -> bool {
14671467
if !self.projection.is_empty() && self.projection[0] == PlaceElem::Deref {
1468-
return Some(self.projection[0]);
1468+
true
14691469
} else {
1470-
None
1470+
false
14711471
}
14721472
}
14731473

@@ -1545,11 +1545,11 @@ impl<'tcx> PlaceRef<'tcx> {
15451545

15461546
/// If MirPhase >= Derefered and if projection contains Deref,
15471547
/// It's guaranteed to be in the first place
1548-
pub fn ret_deref(&self) -> Option<PlaceElem<'tcx>> {
1548+
pub fn has_deref(&self) -> bool {
15491549
if !self.projection.is_empty() && self.projection[0] == PlaceElem::Deref {
1550-
return Some(self.projection[0]);
1550+
true
15511551
} else {
1552-
None
1552+
false
15531553
}
15541554
}
15551555

compiler/rustc_mir_transform/src/add_retag.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct AddRetag;
1515
/// (Concurrent accesses by other threads are no problem as these are anyway non-atomic
1616
/// copies. Data races are UB.)
1717
fn is_stable(place: PlaceRef<'_>) -> bool {
18-
if place.ret_deref().is_some() {
18+
if place.has_deref() {
1919
// Which place this evaluates to can change with any memory write,
2020
// so cannot assume deref to be stable.
2121
return false;
@@ -83,8 +83,7 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
8383
let place_base_raw = |place: &Place<'tcx>| {
8484
// If this is a `Deref`, get the type of what we are deref'ing.
8585
if place.ret_deref().is_some() {
86-
let base_proj = &place.projection[..0];
87-
let ty = Place::ty_from(place.local, base_proj, &*local_decls, tcx).ty;
86+
let ty = place.ty(local_decls, tcx).ty;
8887
ty.is_unsafe_ptr()
8988
} else {
9089
// Not a deref, and thus not raw.

0 commit comments

Comments
 (0)