span: &mut MultiSpan,
children: &mut Vec<SubDiagnostic>,
) {
- for span in iter::once(span).chain(children.iter_mut().map(|child| &mut child.span)) {
+ debug!("fix_multispans_in_extern_macros: before: span={:?} children={:?}", span, children);
+ for span in iter::once(&mut *span).chain(children.iter_mut().map(|child| &mut child.span)) {
self.fix_multispan_in_extern_macros(source_map, span);
}
+ debug!("fix_multispans_in_extern_macros: after: span={:?} children={:?}", span, children);
}
// This "fixes" MultiSpans that contain `Span`s pointing to locations inside of external macros.
fn emit_diagnostic(&mut self, diag: &Diagnostic) {
let mut children = diag.children.clone();
let (mut primary_span, suggestions) = self.primary_span_formatted(&diag);
+ debug!("emit_diagnostic: suggestions={:?}", suggestions);
self.fix_multispans_in_extern_macros_and_render_macro_backtrace(
&self.sm,
// Render the replacements for each suggestion
let suggestions = suggestion.splice_lines(&**sm);
+ debug!("emit_suggestion_default: suggestions={:?}", suggestions);
if suggestions.is_empty() {
// Suggestions coming from macros can have malformed spans. This is a heavy handed
let lines = sm.span_to_lines(bounding_span).ok()?;
assert!(!lines.lines.is_empty());
+ // We can't splice anything if the source is unavailable.
+ if !sm.ensure_source_file_source_present(lines.file.clone()) {
+ return None;
+ }
+
// To build up the result, we do this for each span:
// - push the line segment trailing the previous span
// (at the beginning a "phantom" span pointing at the start of the line)
LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:355:17
+thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:360:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: internal compiler error: unexpected panic