From 4d397bc1864e44f3cfdd788c3ef4c1b3e3ef06c0 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 4 Nov 2024 15:15:44 -0500 Subject: [PATCH] Add test of underscore variable in format string --- tests/ui/display-underscore.rs | 7 +++++++ tests/ui/display-underscore.stderr | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 tests/ui/display-underscore.rs create mode 100644 tests/ui/display-underscore.stderr diff --git a/tests/ui/display-underscore.rs b/tests/ui/display-underscore.rs new file mode 100644 index 0000000..335614b --- /dev/null +++ b/tests/ui/display-underscore.rs @@ -0,0 +1,7 @@ +use thiserror::Error; + +#[derive(Error, Debug)] +#[error("{_}")] +pub struct Error; + +fn main() {} diff --git a/tests/ui/display-underscore.stderr b/tests/ui/display-underscore.stderr new file mode 100644 index 0000000..36882b9 --- /dev/null +++ b/tests/ui/display-underscore.stderr @@ -0,0 +1,7 @@ +error: invalid format string: invalid argument name `_` + --> tests/ui/display-underscore.rs:4:11 + | +4 | #[error("{_}")] + | ^ invalid argument name in format string + | + = note: argument name cannot be a single underscore