Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit a64cd59

Browse files
Add Place getter to Operand
1 parent 2ed25f0 commit a64cd59

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/librustc/mir/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,6 +1993,15 @@ impl<'tcx> Operand<'tcx> {
19931993
Operand::Move(place) => Operand::Copy(place),
19941994
}
19951995
}
1996+
1997+
/// Returns the `Place` that is the target of this `Operand`, or `None` if this `Operand` is a
1998+
/// constant.
1999+
pub fn place(&self) -> Option<&Place<'tcx>> {
2000+
match self {
2001+
Operand::Copy(place) | Operand::Move(place) => Some(place),
2002+
Operand::Constant(_) => None,
2003+
}
2004+
}
19962005
}
19972006

19982007
///////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)