about summary refs log tree commit diff
path: root/src/test/ui/macros
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2018-07-15 11:52:11 -0700
committerEsteban Küber <esteban@commure.com>2018-07-19 23:18:07 -0700
commitfbce952193d38328c39262cf2fb7f7bfbe088a70 (patch)
treed4dbd97694e5310b68149c2d653ece3664fa9edf /src/test/ui/macros
parentf53c145ef18db6543e8e5420e172e04b6054db2e (diff)
downloadrust-fbce952193d38328c39262cf2fb7f7bfbe088a70.tar.gz
rust-fbce952193d38328c39262cf2fb7f7bfbe088a70.zip
review comments: modify note wording and change `println`
- Don't print the newline on its own to avoid the possibility of
  printing it out of order due to `stdout` locking.
- Modify wording of `concat!()` with non-literals to not mislead into
  believing that only `&str` literals are accepted.
- Add test for `concat!()` with non-literals.
Diffstat (limited to 'src/test/ui/macros')
-rw-r--r--src/test/ui/macros/bad-concat.rs18
-rw-r--r--src/test/ui/macros/bad-concat.stderr10
-rw-r--r--src/test/ui/macros/trace-macro.stderr9
3 files changed, 32 insertions, 5 deletions
diff --git a/src/test/ui/macros/bad-concat.rs b/src/test/ui/macros/bad-concat.rs
new file mode 100644
index 00000000000..e7adee8ce85
--- /dev/null
+++ b/src/test/ui/macros/bad-concat.rs
@@ -0,0 +1,18 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    let x: u32 = 42;
+    let y: f64 = 3.14;
+    let z = "foo";
+    let _ = concat!(x, y, z, "bar");
+    //~^ ERROR expected a literal
+    //~| NOTE only literals
+}
diff --git a/src/test/ui/macros/bad-concat.stderr b/src/test/ui/macros/bad-concat.stderr
new file mode 100644
index 00000000000..b97e4f26824
--- /dev/null
+++ b/src/test/ui/macros/bad-concat.stderr
@@ -0,0 +1,10 @@
+error: expected a literal
+  --> $DIR/bad-concat.rs:15:21
+   |
+LL |     let _ = concat!(x, y, z, "bar");
+   |                     ^  ^  ^
+   |
+   = note: only literals (like `"foo"`, `42` and `3.14`) can be passed to `concat!()`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/macros/trace-macro.stderr b/src/test/ui/macros/trace-macro.stderr
index c98e42ea647..6d8a329be80 100644
--- a/src/test/ui/macros/trace-macro.stderr
+++ b/src/test/ui/macros/trace-macro.stderr
@@ -5,9 +5,8 @@ LL |     println!("Hello, World!");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: expanding `println! { "Hello, World!" }`
-   = note: to `{ print ! ( "Hello, World!" ) ; print ! ( "/n" ) ; }`
-   = note: expanding `print! { "Hello, World!" }`
-   = note: to `$crate :: io :: _print ( format_args ! ( "Hello, World!" ) )`
-   = note: expanding `print! { "/n" }`
-   = note: to `$crate :: io :: _print ( format_args ! ( "/n" ) )`
+   = note: to `print ! ( "{}/n" , format_args ! ( "Hello, World!" ) )`
+   = note: expanding `print! { "{}/n" , format_args ! ( "Hello, World!" ) }`
+   = note: to `$crate :: io :: _print (
+           format_args ! ( "{}/n" , format_args ! ( "Hello, World!" ) ) )`