File tree Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -828,7 +828,7 @@ impl<'hir> Map<'hir> {
828
828
}
829
829
830
830
pub fn span ( & self , hir_id : HirId ) -> Span {
831
- self . tcx . index_hir ( LOCAL_CRATE ) . map [ hir_id. owner ] . spans [ hir_id. local_id ] . unwrap ( )
831
+ self . tcx . hir_owner_spans ( hir_id. owner ) [ hir_id. local_id ] . unwrap ( )
832
832
}
833
833
834
834
pub fn span_if_local ( & self , id : DefId ) -> Option < Span > {
Original file line number Diff line number Diff line change @@ -79,5 +79,6 @@ pub fn provide(providers: &mut Providers<'_>) {
79
79
} ;
80
80
providers. hir_owner = |tcx, id| tcx. index_hir ( LOCAL_CRATE ) . map [ id] . signature ;
81
81
providers. hir_owner_nodes = |tcx, id| tcx. index_hir ( LOCAL_CRATE ) . map [ id] . with_bodies . as_deref ( ) ;
82
+ providers. hir_owner_spans = |tcx, id| & tcx. index_hir ( LOCAL_CRATE ) . map [ id] . spans ;
82
83
map:: provide ( providers) ;
83
84
}
Original file line number Diff line number Diff line change @@ -89,6 +89,15 @@ rustc_queries! {
89
89
desc { |tcx| "HIR owner items in `{}`" , tcx. def_path_str( key. to_def_id( ) ) }
90
90
}
91
91
92
+ // Gives access to the HIR spans inside the HIR owner `key`.
93
+ //
94
+ // This can be conveniently accessed by methods on `tcx.hir()`.
95
+ // Avoid calling this query directly.
96
+ query hir_owner_spans( key: LocalDefId ) -> & ' tcx IndexVec <ItemLocalId , Option <Span >> {
97
+ eval_always
98
+ desc { |tcx| "HIR owner spans in `{}`" , tcx. def_path_str( key. to_def_id( ) ) }
99
+ }
100
+
92
101
/// Records the type of every item.
93
102
query type_of( key: DefId ) -> Ty <' tcx> {
94
103
desc { |tcx| "computing type of `{}`" , tcx. def_path_str( key) }
You can’t perform that action at this time.
0 commit comments