File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -1184,9 +1184,34 @@ impl PlaceContext {
11841184 PlaceContext :: MutatingUse (
11851185 MutatingUseContext :: Store
11861186 | MutatingUseContext :: Call
1187+ | MutatingUseContext :: Yield
11871188 | MutatingUseContext :: AsmOutput ,
11881189 ) => true ,
11891190 _ => false ,
11901191 }
11911192 }
1193+
1194+ /// Returns `true` if this context could read the contents of the place.
1195+ pub fn is_read ( & self ) -> bool {
1196+ match * self {
1197+ PlaceContext :: MutatingUse (
1198+ MutatingUseContext :: Store | MutatingUseContext :: Call | MutatingUseContext :: Yield ,
1199+ )
1200+ | PlaceContext :: NonUse ( _) => false ,
1201+
1202+ PlaceContext :: MutatingUse ( _) | PlaceContext :: NonMutatingUse ( _) => true ,
1203+ }
1204+ }
1205+
1206+ /// Returns `true` if this context does not read from this place but does write to it.
1207+ ///
1208+ /// This is relevant for inline assembly, which has read/write parameters.
1209+ pub fn is_write_only ( & self ) -> bool {
1210+ matches ! (
1211+ self ,
1212+ PlaceContext :: MutatingUse (
1213+ MutatingUseContext :: Store | MutatingUseContext :: Call | MutatingUseContext :: Yield
1214+ )
1215+ )
1216+ }
11921217}
You can’t perform that action at this time.
0 commit comments