summaryrefslogtreecommitdiffstats
path: root/tests/ui/fmt
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/fmt')
-rw-r--r--tests/ui/fmt/format-string-wrong-order.rs15
-rw-r--r--tests/ui/fmt/format-string-wrong-order.stderr54
-rw-r--r--tests/ui/fmt/ifmt-bad-arg.stderr4
-rw-r--r--tests/ui/fmt/ifmt-unimpl.stderr2
-rw-r--r--tests/ui/fmt/issue-75307.rs3
-rw-r--r--tests/ui/fmt/issue-75307.stderr8
-rw-r--r--tests/ui/fmt/respanned-literal-issue-106191.rs2
-rw-r--r--tests/ui/fmt/send-sync.stderr4
8 files changed, 86 insertions, 6 deletions
diff --git a/tests/ui/fmt/format-string-wrong-order.rs b/tests/ui/fmt/format-string-wrong-order.rs
new file mode 100644
index 000000000..0bad54023
--- /dev/null
+++ b/tests/ui/fmt/format-string-wrong-order.rs
@@ -0,0 +1,15 @@
+fn main() {
+ let bar = 3;
+ format!("{?:}", bar);
+ //~^ ERROR invalid format string: expected format parameter to occur after `:`
+ format!("{?:bar}");
+ //~^ ERROR invalid format string: expected format parameter to occur after `:`
+ format!("{?:?}", bar);
+ //~^ ERROR invalid format string: expected format parameter to occur after `:`
+ format!("{??}", bar);
+ //~^ ERROR invalid format string: expected `'}'`, found `'?'`
+ format!("{?;bar}");
+ //~^ ERROR invalid format string: expected `'}'`, found `'?'`
+ format!("{?:#?}", bar);
+ //~^ ERROR invalid format string: expected format parameter to occur after `:`
+}
diff --git a/tests/ui/fmt/format-string-wrong-order.stderr b/tests/ui/fmt/format-string-wrong-order.stderr
new file mode 100644
index 000000000..461af354a
--- /dev/null
+++ b/tests/ui/fmt/format-string-wrong-order.stderr
@@ -0,0 +1,54 @@
+error: invalid format string: expected format parameter to occur after `:`
+ --> $DIR/format-string-wrong-order.rs:3:15
+ |
+LL | format!("{?:}", bar);
+ | ^ expected `?` to occur after `:` in format string
+ |
+ = note: `?` comes after `:`, try `:?` instead
+
+error: invalid format string: expected format parameter to occur after `:`
+ --> $DIR/format-string-wrong-order.rs:5:15
+ |
+LL | format!("{?:bar}");
+ | ^ expected `?` to occur after `:` in format string
+ |
+ = note: `?` comes after `:`, try `bar:?` instead
+
+error: invalid format string: expected format parameter to occur after `:`
+ --> $DIR/format-string-wrong-order.rs:7:15
+ |
+LL | format!("{?:?}", bar);
+ | ^ expected `?` to occur after `:` in format string
+ |
+ = note: `?` comes after `:`, try `:?` instead
+
+error: invalid format string: expected `'}'`, found `'?'`
+ --> $DIR/format-string-wrong-order.rs:9:15
+ |
+LL | format!("{??}", bar);
+ | -^ expected `}` in format string
+ | |
+ | because of this opening brace
+ |
+ = note: if you intended to print `{`, you can escape it using `{{`
+
+error: invalid format string: expected `'}'`, found `'?'`
+ --> $DIR/format-string-wrong-order.rs:11:15
+ |
+LL | format!("{?;bar}");
+ | -^ expected `}` in format string
+ | |
+ | because of this opening brace
+ |
+ = note: if you intended to print `{`, you can escape it using `{{`
+
+error: invalid format string: expected format parameter to occur after `:`
+ --> $DIR/format-string-wrong-order.rs:13:15
+ |
+LL | format!("{?:#?}", bar);
+ | ^ expected `?` to occur after `:` in format string
+ |
+ = note: `?` comes after `:`, try `:?` instead
+
+error: aborting due to 6 previous errors
+
diff --git a/tests/ui/fmt/ifmt-bad-arg.stderr b/tests/ui/fmt/ifmt-bad-arg.stderr
index c2619d6df..d716bbe51 100644
--- a/tests/ui/fmt/ifmt-bad-arg.stderr
+++ b/tests/ui/fmt/ifmt-bad-arg.stderr
@@ -302,7 +302,7 @@ error[E0308]: mismatched types
LL | println!("{} {:.*} {}", 1, 3.2, 4);
| ^^^
| |
- | expected `usize`, found floating-point number
+ | expected `&usize`, found `&{float}`
| arguments to this function are incorrect
|
= note: expected reference `&usize`
@@ -317,7 +317,7 @@ error[E0308]: mismatched types
LL | println!("{} {:07$.*} {}", 1, 3.2, 4);
| ^^^
| |
- | expected `usize`, found floating-point number
+ | expected `&usize`, found `&{float}`
| arguments to this function are incorrect
|
= note: expected reference `&usize`
diff --git a/tests/ui/fmt/ifmt-unimpl.stderr b/tests/ui/fmt/ifmt-unimpl.stderr
index be321c3c5..3480a2ec8 100644
--- a/tests/ui/fmt/ifmt-unimpl.stderr
+++ b/tests/ui/fmt/ifmt-unimpl.stderr
@@ -15,7 +15,7 @@ LL | format!("{:X}", "3");
NonZeroIsize
and 21 others
= note: required for `&str` to implement `UpperHex`
-note: required by a bound in `ArgumentV1::<'a>::new_upper_hex`
+note: required by a bound in `core::fmt::ArgumentV1::<'a>::new_upper_hex`
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
= note: this error originates in the macro `$crate::__export::format_args` which comes from the expansion of the macro `arg_new` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/ui/fmt/issue-75307.rs b/tests/ui/fmt/issue-75307.rs
new file mode 100644
index 000000000..cffa6bea8
--- /dev/null
+++ b/tests/ui/fmt/issue-75307.rs
@@ -0,0 +1,3 @@
+fn main() {
+ format!(r"{}{}{}", named_arg=1); //~ ERROR 3 positional arguments in format string, but there is 1 argument
+}
diff --git a/tests/ui/fmt/issue-75307.stderr b/tests/ui/fmt/issue-75307.stderr
new file mode 100644
index 000000000..c5b0b11e7
--- /dev/null
+++ b/tests/ui/fmt/issue-75307.stderr
@@ -0,0 +1,8 @@
+error: 3 positional arguments in format string, but there is 1 argument
+ --> $DIR/issue-75307.rs:2:15
+ |
+LL | format!(r"{}{}{}", named_arg=1);
+ | ^^^^^^ -
+
+error: aborting due to previous error
+
diff --git a/tests/ui/fmt/respanned-literal-issue-106191.rs b/tests/ui/fmt/respanned-literal-issue-106191.rs
index bb741c0ef..5a18983a3 100644
--- a/tests/ui/fmt/respanned-literal-issue-106191.rs
+++ b/tests/ui/fmt/respanned-literal-issue-106191.rs
@@ -3,7 +3,7 @@
// known-bug: #106191
// unset-rustc-env:RUST_BACKTRACE
// had to be reverted
-// error-pattern:internal compiler error
+// error-pattern:unexpectedly panicked
// failure-status:101
// dont-check-compiler-stderr
diff --git a/tests/ui/fmt/send-sync.stderr b/tests/ui/fmt/send-sync.stderr
index 3ed040c3a..d43f4f0d9 100644
--- a/tests/ui/fmt/send-sync.stderr
+++ b/tests/ui/fmt/send-sync.stderr
@@ -6,11 +6,11 @@ LL | send(format_args!("{:?}", c));
| |
| required by a bound introduced by this call
|
- = help: within `[ArgumentV1<'_>]`, the trait `Sync` is not implemented for `core::fmt::Opaque`
+ = help: within `[core::fmt::ArgumentV1<'_>]`, the trait `Sync` is not implemented for `core::fmt::Opaque`
= note: required because it appears within the type `&core::fmt::Opaque`
= note: required because it appears within the type `ArgumentV1<'_>`
= note: required because it appears within the type `[ArgumentV1<'_>]`
- = note: required for `&[ArgumentV1<'_>]` to implement `Send`
+ = note: required for `&[core::fmt::ArgumentV1<'_>]` to implement `Send`
= note: required because it appears within the type `Arguments<'_>`
note: required by a bound in `send`
--> $DIR/send-sync.rs:1:12