Skip to content

Commit f271988

Browse files
authored
Merge pull request #426 from dtolnay/clippyfmt
Mark macros with clippy::format_args
2 parents da5fd9d + 52f2115 commit f271988

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

build.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ fn main() {
7070
if rustc >= 80 {
7171
println!("cargo:rustc-check-cfg=cfg(anyhow_build_probe)");
7272
println!("cargo:rustc-check-cfg=cfg(anyhow_nightly_testing)");
73+
println!("cargo:rustc-check-cfg=cfg(anyhow_no_clippy_format_args)");
7374
println!("cargo:rustc-check-cfg=cfg(anyhow_no_core_error)");
7475
println!("cargo:rustc-check-cfg=cfg(anyhow_no_core_unwind_safe)");
7576
println!("cargo:rustc-check-cfg=cfg(anyhow_no_fmt_arguments_as_str)");
@@ -112,6 +113,12 @@ fn main() {
112113
// https://blog.rust-lang.org/2024/09/05/Rust-1.81.0.html#coreerrorerror
113114
println!("cargo:rustc-cfg=anyhow_no_core_error");
114115
}
116+
117+
if rustc < 85 {
118+
// #[clippy::format_args]
119+
// https://doc.rust-lang.org/1.85.1/clippy/attribs.html#clippyformat_args
120+
println!("cargo:rustc-cfg=anyhow_no_clippy_format_args");
121+
}
115122
}
116123

117124
fn compile_probe(rustc_bootstrap: bool) -> bool {

src/macros.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
/// # }
5555
/// ```
5656
#[macro_export]
57+
#[cfg_attr(not(anyhow_no_clippy_format_args), clippy::format_args)]
5758
macro_rules! bail {
5859
($msg:literal $(,)?) => {
5960
return $crate::__private::Err($crate::__anyhow!($msg))
@@ -154,6 +155,7 @@ __ensure![
154155
#[cfg(not(doc))]
155156
__ensure![
156157
#[macro_export]
158+
#[cfg_attr(not(anyhow_no_clippy_format_args), clippy::format_args)]
157159
macro_rules! ensure {
158160
($($tt:tt)*) => {
159161
$crate::__parse_ensure!(
@@ -198,6 +200,7 @@ __ensure![
198200
/// }
199201
/// ```
200202
#[macro_export]
203+
#[cfg_attr(not(anyhow_no_clippy_format_args), clippy::format_args)]
201204
macro_rules! anyhow {
202205
($msg:literal $(,)?) => {
203206
$crate::__private::must_use({

0 commit comments

Comments
 (0)