parent
6ecad33838
commit
020e1f5b60
3 changed files with 12 additions and 5 deletions
|
@ -159,7 +159,7 @@ fn parse_args<'a>(
|
||||||
};
|
};
|
||||||
let name: &str = &ident.as_str();
|
let name: &str = &ident.as_str();
|
||||||
|
|
||||||
p.expect(&token::Eq).unwrap();
|
p.expect(&token::Eq)?;
|
||||||
let e = p.parse_expr()?;
|
let e = p.parse_expr()?;
|
||||||
if let Some(prev) = names.get(name) {
|
if let Some(prev) = names.get(name) {
|
||||||
ecx.struct_span_err(e.span, &format!("duplicate argument named `{}`", name))
|
ecx.struct_span_err(e.span, &format!("duplicate argument named `{}`", name))
|
||||||
|
|
|
@ -2,6 +2,7 @@ fn main() {
|
||||||
format!(); //~ ERROR requires at least a format string argument
|
format!(); //~ ERROR requires at least a format string argument
|
||||||
format!(struct); //~ ERROR expected expression
|
format!(struct); //~ ERROR expected expression
|
||||||
format!("s", name =); //~ ERROR expected expression
|
format!("s", name =); //~ ERROR expected expression
|
||||||
|
format!("s", foo = foo, bar); //~ ERROR expected `=`
|
||||||
format!("s", foo = struct); //~ ERROR expected expression
|
format!("s", foo = struct); //~ ERROR expected expression
|
||||||
format!("s", struct); //~ ERROR expected expression
|
format!("s", struct); //~ ERROR expected expression
|
||||||
|
|
||||||
|
|
|
@ -18,20 +18,26 @@ error: expected expression, found `<eof>`
|
||||||
LL | format!("s", name =); //~ ERROR expected expression
|
LL | format!("s", name =); //~ ERROR expected expression
|
||||||
| ^ expected expression
|
| ^ expected expression
|
||||||
|
|
||||||
|
error: expected `=`, found `<eof>`
|
||||||
|
--> $DIR/format-parse-errors.rs:5:29
|
||||||
|
|
|
||||||
|
LL | format!("s", foo = foo, bar); //~ ERROR expected `=`
|
||||||
|
| ^^^ expected `=`
|
||||||
|
|
||||||
error: expected expression, found keyword `struct`
|
error: expected expression, found keyword `struct`
|
||||||
--> $DIR/format-parse-errors.rs:5:24
|
--> $DIR/format-parse-errors.rs:6:24
|
||||||
|
|
|
|
||||||
LL | format!("s", foo = struct); //~ ERROR expected expression
|
LL | format!("s", foo = struct); //~ ERROR expected expression
|
||||||
| ^^^^^^ expected expression
|
| ^^^^^^ expected expression
|
||||||
|
|
||||||
error: expected expression, found keyword `struct`
|
error: expected expression, found keyword `struct`
|
||||||
--> $DIR/format-parse-errors.rs:6:18
|
--> $DIR/format-parse-errors.rs:7:18
|
||||||
|
|
|
|
||||||
LL | format!("s", struct); //~ ERROR expected expression
|
LL | format!("s", struct); //~ ERROR expected expression
|
||||||
| ^^^^^^ expected expression
|
| ^^^^^^ expected expression
|
||||||
|
|
||||||
error: format argument must be a string literal
|
error: format argument must be a string literal
|
||||||
--> $DIR/format-parse-errors.rs:9:13
|
--> $DIR/format-parse-errors.rs:10:13
|
||||||
|
|
|
|
||||||
LL | format!(123); //~ ERROR format argument must be a string literal
|
LL | format!(123); //~ ERROR format argument must be a string literal
|
||||||
| ^^^
|
| ^^^
|
||||||
|
@ -40,5 +46,5 @@ help: you might be missing a string literal to format with
|
||||||
LL | format!("{}", 123); //~ ERROR format argument must be a string literal
|
LL | format!("{}", 123); //~ ERROR format argument must be a string literal
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
|
|
||||||
error: aborting due to 6 previous errors
|
error: aborting due to 7 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue