File tree 1 file changed +20
-11
lines changed
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 {
1044
1044
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
1045
1045
// Use the global `SourceMap` to print the span. If that's not
1046
1046
// 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
+ }
1058
1067
}
1059
1068
}
1060
1069
You can’t perform that action at this time.
0 commit comments