about summary refs log tree commit diff
diff options
context:
space:
mode:
authorcsmoe <35686186+csmoe@users.noreply.github.com>2018-07-04 11:48:56 +0800
committercsmoe <35686186+csmoe@users.noreply.github.com>2018-07-06 22:31:55 +0800
commit88f475c8083f668218f93afa88eab4410769cdcd (patch)
treef4a82b0f30d6ad45c980f2357d420e33b95b294d
parentc999b253b7587cd647b06582f10d55cbaf65e635 (diff)
downloadrust-88f475c8083f668218f93afa88eab4410769cdcd.tar.gz
rust-88f475c8083f668218f93afa88eab4410769cdcd.zip
suggests with whole macro call
-rw-r--r--src/libsyntax_ext/concat.rs11
-rw-r--r--src/test/ui/macros/bad_hello.stderr8
2 files changed, 8 insertions, 11 deletions
diff --git a/src/libsyntax_ext/concat.rs b/src/libsyntax_ext/concat.rs
index 1f79c1db995..2325bcbd657 100644
--- a/src/libsyntax_ext/concat.rs
+++ b/src/libsyntax_ext/concat.rs
@@ -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",
                 );
diff --git a/src/test/ui/macros/bad_hello.stderr b/src/test/ui/macros/bad_hello.stderr
index 23486e3cd1c..34bc589b5c5 100644
--- a/src/test/ui/macros/bad_hello.stderr
+++ b/src/test/ui/macros/bad_hello.stderr
@@ -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