Skip to content

Commit c999b25

Browse files
committed
add span note
1 parent b79a83b commit c999b25

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/libsyntax_ext/concat.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,17 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
5555
}
5656
_ => {
5757
let mut err = cx.struct_span_err(e.span, "expected a literal");
58+
let msg = cx.codemap().span_to_snippet(e.span).unwrap_or_else(
59+
|_| pprust::expr_to_string(&e)
60+
);
5861
err.span_suggestion(
5962
e.span,
6063
"consider changing this to",
61-
format!("\"{{}}\", {}", pprust::expr_to_string(&e))
64+
format!("\"{{}}\", {}", msg)
65+
);
66+
err.span_note(
67+
e.span,
68+
"you might be missing a string literal to format with",
6269
);
6370
err.emit();
6471
}

0 commit comments

Comments
 (0)