This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
compiler/rustc_middle/src/mir Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -1741,6 +1741,15 @@ impl<'tcx> Place<'tcx> {
17411741 pub fn as_ref ( & self ) -> PlaceRef < ' tcx > {
17421742 PlaceRef { local : self . local , projection : & self . projection }
17431743 }
1744+
1745+ /// Iterate over the projections in evaluation order, i.e., the first element is the base with
1746+ /// its projection and then subsequently more projections are added.
1747+ pub fn iter_projections ( self ) -> impl Iterator < Item =( PlaceRef < ' tcx > , PlaceElem < ' tcx > ) > + DoubleEndedIterator {
1748+ self . projection . iter ( ) . enumerate ( ) . map ( move |( i, proj) | {
1749+ let base = PlaceRef { local : self . local , projection : & self . projection [ ..i] } ;
1750+ ( base, proj)
1751+ } )
1752+ }
17441753}
17451754
17461755impl From < Local > for Place < ' _ > {
Original file line number Diff line number Diff line change @@ -136,6 +136,15 @@ impl<'tcx> Place<'tcx> {
136136 }
137137}
138138
139+ impl < ' tcx > PlaceRef < ' tcx > {
140+ pub fn ty < D > ( & self , local_decls : & D , tcx : TyCtxt < ' tcx > ) -> PlaceTy < ' tcx >
141+ where
142+ D : HasLocalDecls < ' tcx > ,
143+ {
144+ Place :: ty_from ( self . local , & self . projection , local_decls, tcx)
145+ }
146+ }
147+
139148pub enum RvalueInitializationState {
140149 Shallow ,
141150 Deep ,
You can’t perform that action at this time.
0 commit comments