File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed
compiler/rustc_middle/src/hir Expand file tree Collapse file tree 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> {
10121012 }
10131013
10141014 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 }
10161016 }
10171017
10181018 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) {
121121 providers. hir_attrs =
122122 |tcx, id| tcx. hir_crate ( ( ) ) . owners [ id] . as_owner ( ) . map_or ( AttributeMap :: EMPTY , |o| & o. attrs ) ;
123123 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+ } ;
125129 providers. def_ident_span = |tcx, def_id| {
126130 let def_id = def_id. expect_local ( ) ;
127131 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