From 1086fdb9651ca9c350d0d7c0eabc7bd365f2e530 Mon Sep 17 00:00:00 2001 From: Dean Li Date: Sat, 7 Aug 2021 16:31:54 +0800 Subject: [PATCH] fix compiler warning Fix issue [link](https://github.com/rust-lang/rust/issues/79813) which will eventually deny trailing semicolons in expression macro in rust compiler. --- pyo3-build-config/src/errors.rs | 6 +++--- pyo3-build-config/src/impl_.rs | 2 +- pyo3-macros-backend/src/pyclass.rs | 2 +- pyo3-macros-backend/src/pymethod.rs | 4 ++-- pyo3-macros-backend/src/utils.rs | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pyo3-build-config/src/errors.rs b/pyo3-build-config/src/errors.rs index 61e8dc37..2652da5e 100644 --- a/pyo3-build-config/src/errors.rs +++ b/pyo3-build-config/src/errors.rs @@ -2,8 +2,8 @@ #[macro_export] #[doc(hidden)] macro_rules! bail { - ($msg: expr) => { return Err($msg.into()); }; - ($fmt: literal $($args: tt)+) => { return Err(format!($fmt $($args)+).into()); }; + ($msg: expr) => { return Err($msg.into()) }; + ($fmt: literal $($args: tt)+) => { return Err(format!($fmt $($args)+).into()) }; } /// A simple macro for checking a condition. Resembles anyhow::ensure. @@ -18,7 +18,7 @@ macro_rules! ensure { #[doc(hidden)] macro_rules! warn { ($msg: literal) => { - println!(concat!("cargo:warning=", $msg)); + println!(concat!("cargo:warning=", $msg)) }; } diff --git a/pyo3-build-config/src/impl_.rs b/pyo3-build-config/src/impl_.rs index 66c18d53..d9ee19ab 100644 --- a/pyo3-build-config/src/impl_.rs +++ b/pyo3-build-config/src/impl_.rs @@ -75,7 +75,7 @@ impl InterpreterConfig { warn!( "PyPy does not yet support abi3 so the build artifacts will be version-specific. \ See https://foss.heptapod.net/pypy/pypy/-/issues/3397 for more information." - ) + ); } }; diff --git a/pyo3-macros-backend/src/pyclass.rs b/pyo3-macros-backend/src/pyclass.rs index 470e7909..14996df8 100644 --- a/pyo3-macros-backend/src/pyclass.rs +++ b/pyo3-macros-backend/src/pyclass.rs @@ -84,7 +84,7 @@ impl PyClassArgs { expected!($expected, right.span()) }; ($expected: literal, $span: expr) => { - bail_spanned!($span => concat!("expected ", $expected)); + bail_spanned!($span => concat!("expected ", $expected)) }; } diff --git a/pyo3-macros-backend/src/pymethod.rs b/pyo3-macros-backend/src/pymethod.rs index e31d5fc0..82b70fe6 100644 --- a/pyo3-macros-backend/src/pymethod.rs +++ b/pyo3-macros-backend/src/pymethod.rs @@ -81,7 +81,7 @@ pub fn check_generic(sig: &syn::Signature) -> syn::Result<()> { fn ensure_function_options_valid(options: &PyFunctionOptions) -> syn::Result<()> { if let Some(pass_module) = &options.pass_module { - bail_spanned!(pass_module.span() => "`pass_module` cannot be used on Python methods") + bail_spanned!(pass_module.span() => "`pass_module` cannot be used on Python methods"); } Ok(()) } @@ -334,7 +334,7 @@ impl PropertyType<'_> { (Some(name), _) => name.0.to_string(), (None, Some(field_name)) => format!("{}\0", field_name.unraw()), (None, None) => { - bail_spanned!(field.span() => "`get` and `set` with tuple struct fields require `name`") + bail_spanned!(field.span() => "`get` and `set` with tuple struct fields require `name`"); } }; Ok(syn::LitStr::new(&name, field.span())) diff --git a/pyo3-macros-backend/src/utils.rs b/pyo3-macros-backend/src/utils.rs index 9ff259d9..93fc2afa 100644 --- a/pyo3-macros-backend/src/utils.rs +++ b/pyo3-macros-backend/src/utils.rs @@ -14,7 +14,7 @@ macro_rules! err_spanned { /// Macro inspired by `anyhow::bail!` to return a compiler error with the given span. macro_rules! bail_spanned { ($span:expr => $msg:expr) => { - return Err(err_spanned!($span => $msg)); + return Err(err_spanned!($span => $msg)) }; }