File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
compiler/rustc_middle/src Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -203,6 +203,26 @@ impl<'tcx> TyCtxt<'tcx> {
203
203
}
204
204
} )
205
205
}
206
+
207
+ #[ inline]
208
+ pub fn hir_owner_parent ( self , owner_id : OwnerId ) -> HirId {
209
+ if self . dep_graph . is_fully_enabled ( ) {
210
+ self . hir_owner_parent_q ( owner_id)
211
+ } else {
212
+ self . opt_local_parent ( owner_id. def_id ) . map_or ( CRATE_HIR_ID , |parent_def_id| {
213
+ let parent_owner_id = self . local_def_id_to_hir_id ( parent_def_id) . owner ;
214
+ HirId {
215
+ owner : parent_owner_id,
216
+ local_id : self . hir_crate ( ( ) ) . owners [ parent_owner_id. def_id ]
217
+ . unwrap ( )
218
+ . parenting
219
+ . get ( & owner_id. def_id )
220
+ . copied ( )
221
+ . unwrap_or ( ItemLocalId :: ZERO ) ,
222
+ }
223
+ } )
224
+ }
225
+ }
206
226
}
207
227
208
228
/// Hashes computed by [`TyCtxt::hash_owner_nodes`] if necessary.
@@ -224,7 +244,7 @@ pub fn provide(providers: &mut Providers) {
224
244
} ;
225
245
providers. opt_hir_owner_nodes =
226
246
|tcx, id| tcx. hir_crate ( ( ) ) . owners . get ( id) ?. as_owner ( ) . map ( |i| & i. nodes ) ;
227
- providers. hir_owner_parent = |tcx, owner_id| {
247
+ providers. hir_owner_parent_q = |tcx, owner_id| {
228
248
tcx. opt_local_parent ( owner_id. def_id ) . map_or ( CRATE_HIR_ID , |parent_def_id| {
229
249
let parent_owner_id = tcx. local_def_id_to_hir_id ( parent_def_id) . owner ;
230
250
HirId {
Original file line number Diff line number Diff line change @@ -255,7 +255,7 @@ rustc_queries! {
255
255
///
256
256
/// This can be conveniently accessed by `tcx.hir_*` methods.
257
257
/// Avoid calling this query directly.
258
- query hir_owner_parent ( key: hir:: OwnerId ) -> hir:: HirId {
258
+ query hir_owner_parent_q ( key: hir:: OwnerId ) -> hir:: HirId {
259
259
desc { |tcx| "getting HIR parent of `{}`" , tcx. def_path_str( key) }
260
260
}
261
261
You can’t perform that action at this time.
0 commit comments