Auto merge of #52397 - estebank:println-comma, r=oli-obk
Suggest comma when writing `println!("{}" a);`
Fix #49370.
This commit is contained in:
commit
3f4f18f098
6 changed files with 92 additions and 10 deletions
|
|
@ -7,20 +7,16 @@ LL | format!(); //~ ERROR requires at least a format string argument
|
|||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
error: expected token: `,`
|
||||
--> $DIR/bad-format-args.rs:13:5
|
||||
--> $DIR/bad-format-args.rs:13:16
|
||||
|
|
||||
LL | format!("" 1); //~ ERROR expected token: `,`
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
| ^
|
||||
|
||||
error: expected token: `,`
|
||||
--> $DIR/bad-format-args.rs:14:5
|
||||
--> $DIR/bad-format-args.rs:14:19
|
||||
|
|
||||
LL | format!("", 1 1); //~ ERROR expected token: `,`
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
| ^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
|||
20
src/test/ui/macros/missing-comma.rs
Normal file
20
src/test/ui/macros/missing-comma.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// 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.
|
||||
|
||||
macro_rules! foo {
|
||||
($a:ident, $b:ident) => ()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("{}" a);
|
||||
//~^ ERROR expected token: `,`
|
||||
foo!(a b);
|
||||
//~^ ERROR no rules expected the token `b`
|
||||
}
|
||||
16
src/test/ui/macros/missing-comma.stderr
Normal file
16
src/test/ui/macros/missing-comma.stderr
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
error: expected token: `,`
|
||||
--> $DIR/missing-comma.rs:16:19
|
||||
|
|
||||
LL | println!("{}" a);
|
||||
| ^
|
||||
|
||||
error: no rules expected the token `b`
|
||||
--> $DIR/missing-comma.rs:18:12
|
||||
|
|
||||
LL | foo!(a b);
|
||||
| -^
|
||||
| |
|
||||
| help: missing comma here
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue