diff options
| author | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2020-01-24 15:30:51 -0800 |
|---|---|---|
| committer | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2020-02-13 18:42:12 -0800 |
| commit | a64cd592247b0029352b57a7caf038e6d2ba6a05 (patch) | |
| tree | a7819dabb3620bda35ef1f9d88833e6594c8f3fa | |
| parent | 2ed25f069768c046464e68fd382c867ddb04a1e3 (diff) | |
Add `Place` getter to `Operand`
| -rw-r--r-- | src/librustc/mir/mod.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index f6c7174649f..d3a6ff654d6 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -1993,6 +1993,15 @@ impl<'tcx> Operand<'tcx> { Operand::Move(place) => Operand::Copy(place), } } + + /// Returns the `Place` that is the target of this `Operand`, or `None` if this `Operand` is a + /// constant. + pub fn place(&self) -> Option<&Place<'tcx>> { + match self { + Operand::Copy(place) | Operand::Move(place) => Some(place), + Operand::Constant(_) => None, + } + } } /////////////////////////////////////////////////////////////////////////// |
