@@ -181,14 +181,18 @@ pub fn provide(providers: &mut Providers) {
181
181
providers. hir_crate_items = map:: hir_crate_items;
182
182
providers. crate_hash = map:: crate_hash;
183
183
providers. hir_module_items = map:: hir_module_items;
184
- providers. hir_owner =
185
- |tcx, def_id| tcx. hir_crate ( ( ) ) . owners . get ( def_id) . copied ( ) . unwrap_or ( MaybeOwner :: Phantom ) ;
186
- providers. local_def_id_to_hir_id = |tcx, def_id| match tcx. hir_owner ( def_id) {
187
- MaybeOwner :: Owner ( _) => HirId :: make_owner ( def_id) ,
188
- MaybeOwner :: NonOwner ( hir_id) => hir_id,
189
- MaybeOwner :: Phantom => bug ! ( "No HirId for {:?}" , def_id) ,
184
+ providers. local_def_id_to_hir_id = |tcx, def_id| {
185
+ tcx. ensure_ok ( ) . hir_crate ( ( ) ) ;
186
+ match tcx. hir_owner ( def_id) {
187
+ MaybeOwner :: Owner ( _) => HirId :: make_owner ( def_id) ,
188
+ MaybeOwner :: NonOwner ( hir_id) => hir_id,
189
+ MaybeOwner :: Phantom => bug ! ( "No HirId for {:?}" , def_id) ,
190
+ }
191
+ } ;
192
+ providers. opt_hir_owner_nodes = |tcx, id| {
193
+ tcx. ensure_ok ( ) . hir_crate ( ( ) ) ;
194
+ tcx. hir_owner ( id) . as_owner ( ) . map ( |i| & i. nodes )
190
195
} ;
191
- providers. opt_hir_owner_nodes = |tcx, id| tcx. hir_owner ( id) . as_owner ( ) . map ( |i| & i. nodes ) ;
192
196
providers. hir_owner_parent = |tcx, owner_id| {
193
197
tcx. opt_local_parent ( owner_id. def_id ) . map_or ( CRATE_HIR_ID , |parent_def_id| {
194
198
let parent_owner_id = tcx. local_def_id_to_hir_id ( parent_def_id) . owner ;
@@ -204,8 +208,10 @@ pub fn provide(providers: &mut Providers) {
204
208
}
205
209
} )
206
210
} ;
207
- providers. hir_attr_map =
208
- |tcx, id| tcx. hir_owner ( id. def_id ) . as_owner ( ) . map_or ( AttributeMap :: EMPTY , |o| & o. attrs ) ;
211
+ providers. hir_attr_map = |tcx, id| {
212
+ tcx. ensure_ok ( ) . hir_crate ( ( ) ) ;
213
+ tcx. hir_owner ( id. def_id ) . as_owner ( ) . map_or ( AttributeMap :: EMPTY , |o| & o. attrs )
214
+ } ;
209
215
providers. def_span = |tcx, def_id| tcx. hir_span ( tcx. local_def_id_to_hir_id ( def_id) ) ;
210
216
providers. def_ident_span = |tcx, def_id| {
211
217
let hir_id = tcx. local_def_id_to_hir_id ( def_id) ;
0 commit comments