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.
This commit is contained in:
parent
f53c145ef1
commit
fbce952193
5 changed files with 34 additions and 14 deletions
18
src/test/ui/macros/bad-concat.rs
Normal file
18
src/test/ui/macros/bad-concat.rs
Normal file
|
|
@ -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
|
||||
}
|
||||
10
src/test/ui/macros/bad-concat.stderr
Normal file
10
src/test/ui/macros/bad-concat.stderr
Normal file
|
|
@ -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
|
||||
|
||||
|
|
@ -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!" ) ) )`
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue