diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-02-13 06:44:18 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-13 06:44:18 +0100 |
| commit | dff7d51fcc8e5bb69d45db4f177fb15fab48b781 (patch) | |
| tree | 4bf49d6c49fa144db5a6fb8138773882ed426876 /compiler/rustc_span/src | |
| parent | 2b7f3ee89de5ca407da4526a4438bdf453cf34e6 (diff) | |
| parent | f45ba82370f580fba0f1486f745607d7d30ef330 (diff) | |
| download | rust-dff7d51fcc8e5bb69d45db4f177fb15fab48b781.tar.gz rust-dff7d51fcc8e5bb69d45db4f177fb15fab48b781.zip | |
Rollup merge of #93936 - bjorn3:simplifications2, r=cjgillot
Couple of driver cleanups * Remove the `RustcDefaultCalls` struct, which hasn't been necessary since the introduction of `rustc_interface`. * Move the `setup_callbacks` call around for a tiny code deduplication. * Remove the `SPAN_DEBUG` global as it isn't actually necessary.
Diffstat (limited to 'compiler/rustc_span/src')
| -rw-r--r-- | compiler/rustc_span/src/lib.rs | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 823a927fd8c..3ce9f852c3d 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -1013,37 +1013,25 @@ pub fn with_source_map<T, F: FnOnce() -> T>(source_map: Lrc<SourceMap>, f: F) -> f() } -pub fn debug_with_source_map( - span: Span, - f: &mut fmt::Formatter<'_>, - source_map: &SourceMap, -) -> fmt::Result { - write!(f, "{} ({:?})", source_map.span_to_diagnostic_string(span), span.ctxt()) -} - -pub fn default_span_debug(span: Span, f: &mut fmt::Formatter<'_>) -> fmt::Result { - with_session_globals(|session_globals| { - if let Some(source_map) = &*session_globals.source_map.borrow() { - debug_with_source_map(span, f, source_map) - } else { - f.debug_struct("Span") - .field("lo", &span.lo()) - .field("hi", &span.hi()) - .field("ctxt", &span.ctxt()) - .finish() - } - }) -} - impl fmt::Debug for Span { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - (*SPAN_DEBUG)(*self, f) + with_session_globals(|session_globals| { + if let Some(source_map) = &*session_globals.source_map.borrow() { + write!(f, "{} ({:?})", source_map.span_to_diagnostic_string(*self), self.ctxt()) + } else { + f.debug_struct("Span") + .field("lo", &self.lo()) + .field("hi", &self.hi()) + .field("ctxt", &self.ctxt()) + .finish() + } + }) } } impl fmt::Debug for SpanData { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - (*SPAN_DEBUG)(Span::new(self.lo, self.hi, self.ctxt, self.parent), f) + fmt::Debug::fmt(&Span::new(self.lo, self.hi, self.ctxt, self.parent), f) } } @@ -2003,8 +1991,6 @@ pub struct FileLines { pub lines: Vec<LineInfo>, } -pub static SPAN_DEBUG: AtomicRef<fn(Span, &mut fmt::Formatter<'_>) -> fmt::Result> = - AtomicRef::new(&(default_span_debug as fn(_, &mut fmt::Formatter<'_>) -> _)); pub static SPAN_TRACK: AtomicRef<fn(LocalDefId)> = AtomicRef::new(&((|_| {}) as fn(_))); // _____________________________________________________________________________ |
