itsjunetime commented on code in PR #11958:
URL: https://github.com/apache/datafusion/pull/11958#discussion_r1714421722
##########
datafusion/common/src/error.rs:
##########
@@ -501,37 +494,37 @@ macro_rules! with_dollar_sign {
/// `NAME_DF_ERR` - macro name for wrapping DataFusionError::*. Needed to
keep backtrace opportunity
/// in construction where DataFusionError::* used directly, like `map_err`,
`ok_or_else`, etc
macro_rules! make_error {
- ($NAME_ERR:ident, $NAME_DF_ERR: ident, $ERR:ident) => {
- with_dollar_sign! {
- ($d:tt) => {
- /// Macro wraps `$ERR` to add backtrace feature
- #[macro_export]
- macro_rules! $NAME_DF_ERR {
- ($d($d args:expr),*) => {
- $crate::DataFusionError::$ERR(
- format!(
- "{}{}",
- format!($d($d args),*),
- $crate::DataFusionError::get_back_trace(),
- ).into()
- )
- }
+ ($NAME_ERR:ident, $NAME_DF_ERR: ident, $ERR:ident) => { make_error!(@inner
($), $NAME_ERR, $NAME_DF_ERR, $ERR); };
+ (@inner ($d:tt), $NAME_ERR:ident, $NAME_DF_ERR:ident, $ERR:ident) => {
+ ::paste::paste!{
+ /// Macro wraps `$ERR` to add backtrace feature
+ #[macro_export]
+ macro_rules! $NAME_DF_ERR {
+ ($d($d args:expr),*) => {
+ $crate::DataFusionError::$ERR(
+ ::std::format!(
+ "{}{}",
+ ::std::format!($d($d args),*),
+ $crate::DataFusionError::get_back_trace(),
+ ).into()
+ )
}
+ }
- /// Macro wraps Err(`$ERR`) to add backtrace feature
- #[macro_export]
- macro_rules! $NAME_ERR {
- ($d($d args:expr),*) => {
- Err($crate::DataFusionError::$ERR(
- format!(
- "{}{}",
- format!($d($d args),*),
- $crate::DataFusionError::get_back_trace(),
- ).into()
- ))
- }
+ /// Macro wraps Err(`$ERR`) to add backtrace feature
+ #[macro_export]
+ macro_rules! $NAME_ERR {
+ ($d($d args:expr),*) => {
+ Err($crate::[<_ $NAME_DF_ERR>]!($d($d args),*))
}
}
+
+ #[doc(hidden)]
+ #[allow(unused)]
Review Comment:
rust-analyzer still analyzes macro output and will complain if they generate
unused typealiases. Previously we got around that by explicitly adding
something like `pub use err as _err` only where needed, but this makes those
identifiers for all errors, (to make it easier to use in the future), but some
of them aren't currently used in the codebase. So those typealiases are
technically unused, but that's fine because they're just there for if we need
them inside the crate.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]