Skip to content

Commit 88f475c

Browse files
committed
suggests with whole macro call
1 parent c999b25 commit 88f475c

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/libsyntax_ext/concat.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use syntax::ext::build::AstBuilder;
1414
use syntax::symbol::Symbol;
1515
use syntax_pos;
1616
use syntax::tokenstream;
17-
use syntax::print::pprust;
1817

1918
use std::string::String;
2019

@@ -55,15 +54,7 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
5554
}
5655
_ => {
5756
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-
);
61-
err.span_suggestion(
62-
e.span,
63-
"consider changing this to",
64-
format!("\"{{}}\", {}", msg)
65-
);
66-
err.span_note(
57+
err.span_help(
6758
e.span,
6859
"you might be missing a string literal to format with",
6960
);

src/test/ui/macros/bad_hello.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ error: expected a literal
22
--> $DIR/bad_hello.rs:12:14
33
|
44
LL | println!(3 + 4); //~ ERROR expected a literal
5-
| ^^^^^ help: consider changing this to: `"{}", 3 + 4`
5+
| ^^^^^
6+
|
7+
help: you might be missing a string literal to format with
8+
--> $DIR/bad_hello.rs:12:14
9+
|
10+
LL | println!(3 + 4); //~ ERROR expected a literal
11+
| ^^^^^
612

713
error: aborting due to previous error
814

0 commit comments

Comments
 (0)