File tree Expand file tree Collapse file tree 1 file changed +20
-11
lines changed Expand file tree Collapse file tree 1 file changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -1044,17 +1044,26 @@ impl fmt::Debug for Span {
10441044 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
10451045 // Use the global `SourceMap` to print the span. If that's not
10461046 // available, fall back to printing the raw values.
1047- with_session_globals ( |session_globals| {
1048- if let Some ( source_map) = & * session_globals. source_map . borrow ( ) {
1049- write ! ( f, "{} ({:?})" , source_map. span_to_diagnostic_string( * self ) , self . ctxt( ) )
1050- } else {
1051- f. debug_struct ( "Span" )
1052- . field ( "lo" , & self . lo ( ) )
1053- . field ( "hi" , & self . hi ( ) )
1054- . field ( "ctxt" , & self . ctxt ( ) )
1055- . finish ( )
1056- }
1057- } )
1047+
1048+ fn fallback ( span : Span , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
1049+ f. debug_struct ( "Span" )
1050+ . field ( "lo" , & span. lo ( ) )
1051+ . field ( "hi" , & span. hi ( ) )
1052+ . field ( "ctxt" , & span. ctxt ( ) )
1053+ . finish ( )
1054+ }
1055+
1056+ if SESSION_GLOBALS . is_set ( ) {
1057+ with_session_globals ( |session_globals| {
1058+ if let Some ( source_map) = & * session_globals. source_map . borrow ( ) {
1059+ write ! ( f, "{} ({:?})" , source_map. span_to_diagnostic_string( * self ) , self . ctxt( ) )
1060+ } else {
1061+ fallback ( * self , f)
1062+ }
1063+ } )
1064+ } else {
1065+ fallback ( * self , f)
1066+ }
10581067 }
10591068}
10601069
You can’t perform that action at this time.
0 commit comments