File tree 2 files changed +6
-2
lines changed
compiler/rustc_middle/src/hir
2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -1012,7 +1012,7 @@ impl<'hir> Map<'hir> {
1012
1012
}
1013
1013
1014
1014
pub fn span_if_local ( self , id : DefId ) -> Option < Span > {
1015
- id. as_local ( ) . and_then ( |id| self . opt_span ( self . local_def_id_to_hir_id ( id) ) )
1015
+ if id. is_local ( ) { Some ( self . tcx . def_span ( id) ) } else { None }
1016
1016
}
1017
1017
1018
1018
pub fn res_span ( self , res : Res ) -> Option < Span > {
Original file line number Diff line number Diff line change @@ -121,7 +121,11 @@ pub fn provide(providers: &mut Providers) {
121
121
providers. hir_attrs =
122
122
|tcx, id| tcx. hir_crate ( ( ) ) . owners [ id] . as_owner ( ) . map_or ( AttributeMap :: EMPTY , |o| & o. attrs ) ;
123
123
providers. source_span = |tcx, def_id| tcx. resolutions ( ( ) ) . definitions . def_span ( def_id) ;
124
- providers. def_span = |tcx, def_id| tcx. hir ( ) . span_if_local ( def_id) . unwrap_or ( DUMMY_SP ) ;
124
+ providers. def_span = |tcx, def_id| {
125
+ let def_id = def_id. expect_local ( ) ;
126
+ let hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( def_id) ;
127
+ tcx. hir ( ) . opt_span ( hir_id) . unwrap_or ( DUMMY_SP )
128
+ } ;
125
129
providers. def_ident_span = |tcx, def_id| {
126
130
let def_id = def_id. expect_local ( ) ;
127
131
let hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( def_id) ;
You can’t perform that action at this time.
0 commit comments