Skip to content

Commit 5aae53e

Browse files
committed
Introduce has_no_projection
1 parent 73e86a2 commit 5aae53e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/librustc/mir/tcx.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl<'tcx> Place<'tcx> {
136136
let mut place_ty = PlaceTy::from(self.base.ty(local_decls));
137137

138138
// apply .projection_ty() to all elems but only returns the final one.
139-
if !self.elems.is_empty() {
139+
if !self.has_no_projection() {
140140
for elem in self.elems.iter() {
141141
place_ty = place_ty.projection_ty(tcx, elem);
142142
}
@@ -207,6 +207,10 @@ impl<'tcx> Place<'tcx> {
207207
}
208208
}
209209

210+
pub fn has_no_projection(&self) -> bool {
211+
self.elems.is_empty()
212+
}
213+
210214
// for projection returns the base place;
211215
// Base.[a, b, c] => Base.[a, b]
212216
// ^-- projection
@@ -230,7 +234,7 @@ impl<'tcx> Place<'tcx> {
230234
elem_index: usize,
231235
) -> Place<'tcx> {
232236
// only works for place with projections
233-
assert!(!self.elems.is_empty());
237+
assert!(!self.has_no_projection());
234238

235239
if elem_index < 1 {
236240
// Base.[a]

0 commit comments

Comments
 (0)