diff options
| author | csmoe <35686186+csmoe@users.noreply.github.com> | 2018-07-04 09:01:11 +0800 |
|---|---|---|
| committer | csmoe <35686186+csmoe@users.noreply.github.com> | 2018-07-04 09:01:11 +0800 |
| commit | c999b253b7587cd647b06582f10d55cbaf65e635 (patch) | |
| tree | d2a7e3e9e0057575c6a0d544184b9e0d1734b999 /src/libsyntax_ext | |
| parent | b79a83b4e41858205e5cf057a9f05d299d66859a (diff) | |
| download | rust-c999b253b7587cd647b06582f10d55cbaf65e635.tar.gz rust-c999b253b7587cd647b06582f10d55cbaf65e635.zip | |
add span note
Diffstat (limited to 'src/libsyntax_ext')
| -rw-r--r-- | src/libsyntax_ext/concat.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libsyntax_ext/concat.rs b/src/libsyntax_ext/concat.rs index 9ebd2e4be71..1f79c1db995 100644 --- a/src/libsyntax_ext/concat.rs +++ b/src/libsyntax_ext/concat.rs @@ -55,10 +55,17 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt, } _ => { let mut err = cx.struct_span_err(e.span, "expected a literal"); + let msg = cx.codemap().span_to_snippet(e.span).unwrap_or_else( + |_| pprust::expr_to_string(&e) + ); err.span_suggestion( e.span, "consider changing this to", - format!("\"{{}}\", {}", pprust::expr_to_string(&e)) + format!("\"{{}}\", {}", msg) + ); + err.span_note( + e.span, + "you might be missing a string literal to format with", ); err.emit(); } |
