suggests with whole macro call
This commit is contained in:
parent
c999b253b7
commit
88f475c808
@ -14,7 +14,6 @@ use syntax::ext::build::AstBuilder;
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax_pos;
|
||||
use syntax::tokenstream;
|
||||
use syntax::print::pprust;
|
||||
|
||||
use std::string::String;
|
||||
|
||||
@ -55,15 +54,7 @@ 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!("\"{{}}\", {}", msg)
|
||||
);
|
||||
err.span_note(
|
||||
err.span_help(
|
||||
e.span,
|
||||
"you might be missing a string literal to format with",
|
||||
);
|
||||
|
@ -2,7 +2,13 @@ error: expected a literal
|
||||
--> $DIR/bad_hello.rs:12:14
|
||||
|
|
||||
LL | println!(3 + 4); //~ ERROR expected a literal
|
||||
| ^^^^^ help: consider changing this to: `"{}", 3 + 4`
|
||||
| ^^^^^
|
||||
|
|
||||
help: you might be missing a string literal to format with
|
||||
--> $DIR/bad_hello.rs:12:14
|
||||
|
|
||||
LL | println!(3 + 4); //~ ERROR expected a literal
|
||||
| ^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user