File tree Expand file tree Collapse file tree
compiler/rustc_builtin_macros/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -607,6 +607,8 @@ fn make_format_args(
607607 // If there's a lot of unused arguments,
608608 // let's check if this format arguments looks like another syntax (printf / shell).
609609 let detect_foreign_fmt = unused. len ( ) > args. explicit_args ( ) . len ( ) / 2 ;
610+ let foreign_fmt_str =
611+ if append_newline { fmt_str. strip_suffix ( '\n' ) . unwrap_or ( fmt_str) } else { fmt_str } ;
610612 report_missing_placeholders (
611613 ecx,
612614 unused,
@@ -616,7 +618,7 @@ fn make_format_args(
616618 & invalid_refs,
617619 detect_foreign_fmt,
618620 str_style,
619- fmt_str ,
621+ foreign_fmt_str ,
620622 uncooked_fmt_str. 1 . as_str ( ) ,
621623 fmt_span,
622624 ) ;
Original file line number Diff line number Diff line change @@ -2,15 +2,14 @@ error: argument never used
22 --> $DIR/format-foreign-dollar-without-spec.rs:3:25
33 |
44LL | println!("%65536$", 1);
5- | ^ argument never used
5+ | --------- ^ argument never used
6+ | |
7+ | formatting specifier missing
68 |
7- note: format specifiers use curly braces, and the conversion specifier `
8- ` is unknown or unsupported
9- --> $DIR/format-foreign-dollar-without-spec.rs:3:15
9+ help: format specifiers use curly braces, consider adding a format specifier
1010 |
11- LL | println!("%65536$", 1);
12- | ^^^^^^^^
13- = note: printf formatting is not supported; see the documentation for `std::fmt`
11+ LL | println!("%65536${}", 1);
12+ | ++
1413
1514error: aborting due to 1 previous error
1615
Original file line number Diff line number Diff line change 1+ //@ check-fail
2+
3+ pub fn f ( x : f64 ) {
4+ println ! ( "{x:>8.2}%" , "foo" ) ;
5+ //~^ ERROR argument never used
6+ }
Original file line number Diff line number Diff line change 1+ error: argument never used
2+ --> $DIR/issue-158216.rs:4:27
3+ |
4+ LL | println!("{x:>8.2}%", "foo");
5+ | ----------- ^^^^^ argument never used
6+ | |
7+ | formatting specifier missing
8+ |
9+ help: format specifiers use curly braces, consider adding a format specifier
10+ |
11+ LL | println!("{x:>8.2}%{}", "foo");
12+ | ++
13+
14+ error: aborting due to 1 previous error
Original file line number Diff line number Diff line change @@ -2,15 +2,13 @@ error: argument never used
22 --> $DIR/issue-92267.rs:3:34
33 |
44LL | pub fn main() { println!("🦀%%%", 0) }
5- | ^ argument never used
5+ | -------- ^ argument never used
6+ | |
7+ | formatting specifier missing
68 |
7- note: format specifiers use curly braces, and the conversion specifier `
8- ` is unknown or unsupported
9- --> $DIR/issue-92267.rs:3:30
9+ help: format specifiers use curly braces, consider adding a format specifier
1010 |
11- LL | pub fn main() { println!("🦀%%%", 0) }
12- | ^^
13- = note: printf formatting is not supported; see the documentation for `std::fmt`
11+ LL | pub fn main() { println!("🦀%%%{}", 0) }
12+ | ++
1413
1514error: aborting due to 1 previous error
16-
You can’t perform that action at this time.
0 commit comments