Repository: rust-lang/rust
File: compiler/rustc_builtin_macros/src/format.rs (Rust)

Code before:
                        captured: captured_arg_span,
                        len: args.unnamed_args().len().to_string(),
                        span: span.shrink_to_hi(),
                        arg,
                    });
                }
            }
            parse::Suggestion::RemoveRawIdent(span) => {
                if is_source_literal {
                    let span = fmt_span.from_inner(InnerSpan::new(span.start, span.end));
                    e.sugg_ = Some(errors::InvalidFormatStringSuggestion::RemoveRawIdent { span })
                }
            }
            parse::Suggestion::ReorderFormatParameter(span, replacement) => {
                let span = fmt_span.from_inner(InnerSpan::new(span.start, span.end));
                e.sugg_ = Some(errors::InvalidFormatStringSuggestion::ReorderFormatParameter {
                    span,
                    replacement,
                });
            }
            parse::Suggestion::AddMissingColon(span) => {
                let span = fmt_span.from_inner(InnerSpan::new(span.start, span.end));
                e.sugg_ = Some(errors::InvalidFormatStringSuggestion::AddMissingColon { span });
            }
            parse::Suggestion::UseRustDebugPrintingMacro() => {
                // This only target println!("{=}", x); and println!("{0=}", x);
                if let [arg] = args.all_args() {
                    let expr_span = arg.expr.span;
                    if let Ok(expr_snippet) = ecx.source_map().span_to_snippet(expr_span) {
                        let replacement = format!("{}!({})", "dbg", expr_snippet);

                        let call_span = macro_span.source_callsite();
                        e.sugg_ = Some(
                            errors::InvalidFormatStringSuggestion::UseRustDebugPrintingMacro {
                                macro_span: call_span,
                                replacement,
                            },
                        );
                    }
                }
            }
        }
        let guar = ecx.dcx().emit_err(e);
        return ExpandResult::Ready(Err(guar));
    }

    let to_span = |inner_span: Range<usize>| {
        is_source_literal.then(|| {
            fmt_span.from_inner(InnerSpan { start: inner_span.start, end: inner_span.end })
        })
    };

Review comment (bug):
```suggestion
            parse::Suggestion::UseRustDebugPrintingMacro => {
                // This targets `println!("{=}", x);` and `println!("{0=}", x);`
```

Code after:
                        captured: captured_arg_span,
                        len: args.unnamed_args().len().to_string(),
                        span: span.shrink_to_hi(),
                        arg,
                    });
                }
            }
            parse::Suggestion::RemoveRawIdent(span) => {
                if is_source_literal {
                    let span = fmt_span.from_inner(InnerSpan::new(span.start, span.end));
                    e.sugg_ = Some(errors::InvalidFormatStringSuggestion::RemoveRawIdent { span })
                }
            }
            parse::Suggestion::ReorderFormatParameter(span, replacement) => {
                let span = fmt_span.from_inner(InnerSpan::new(span.start, span.end));
                e.sugg_ = Some(errors::InvalidFormatStringSuggestion::ReorderFormatParameter {
                    span,
                    replacement,
                });
            }
            parse::Suggestion::AddMissingColon(span) => {
                let span = fmt_span.from_inner(InnerSpan::new(span.start, span.end));
                e.sugg_ = Some(errors::InvalidFormatStringSuggestion::AddMissingColon { span });
            }
            parse::Suggestion::UseRustDebugPrintingMacro => {
                // This targets `println!("{=}", x);` and `println!("{0=}", x);`
                if let [arg] = args.all_args() {
                    let expr_span = arg.expr.span;
                    if let Ok(expr_snippet) = ecx.source_map().span_to_snippet(expr_span) {
                        let replacement = format!("{}!({})", "dbg", expr_snippet);

                        let call_span = macro_span.source_callsite();
                        e.sugg_ = Some(
                            errors::InvalidFormatStringSuggestion::UseRustDebugPrintingMacro {
                                macro_span: call_span,
                                replacement,
                            },
                        );
                    }
                }
            }
        }
        let guar = ecx.dcx().emit_err(e);
        return ExpandResult::Ready(Err(guar));
    }

    let to_span = |inner_span: Range<usize>| {
        is_source_literal.then(|| {
            fmt_span.from_inner(InnerSpan { start: inner_span.start, end: inner_span.end })
        })
    };