-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix config_namespace macro symbol usage #14520
Fix config_namespace macro symbol usage #14520
Conversation
The `config_namespace` macro was relying on a few symbols being properly imported before its used. This removes that need by referring to the symbols directly with the `$crate` prefix.
datafusion/common/src/config.rs
Outdated
@@ -2093,3 +2094,22 @@ mod tests { | |||
assert_eq!(parsed_metadata.get("key_dupe"), Some(&Some("B".into()))); | |||
} | |||
} | |||
|
|||
#[cfg(test)] | |||
mod tests_isolated { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mod tests_isolated { | |
mod tests { |
I think it may be best to stick to convention here.
datafusion/common/src/config.rs
Outdated
// can compile without any surrounding `use` statements. Hence putting | ||
// it into its own test module. | ||
#[test] | ||
fn check_config_namespace_macro() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it may be better to add this test/module in lib.rs
🤔 ?
Since the subtle addition of a use super::*
in the future would effectively hide any regression here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this location / test is exactly for ensuring macro's don't import things unnecessarily: https://github.com/apache/datafusion/tree/main/datafusion/core/tests/macro_hygiene
How about we put this test there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
datafusion/common/src/config.rs
Outdated
// can compile without any surrounding `use` statements. Hence putting | ||
// it into its own test module. | ||
#[test] | ||
fn check_config_namespace_macro() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this location / test is exactly for ensuring macro's don't import things unnecessarily: https://github.com/apache/datafusion/tree/main/datafusion/core/tests/macro_hygiene
How about we put this test there?
@alamb Thanks for the tip! I've moved the test to the macro_hygiene module. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
config_namespace
macro was relying on a few symbols being properly imported before its used. This removes that need by referring to the symbols directly with the$crate
prefix.Which issue does this PR close?
config_namespace!
macro requiresdatafusion::common::Result
to be in scope #14518.Rationale for this change
The
config_namespace!
macro relied on symbols being properly imported. This fixes that issue.What changes are included in this PR?
config_namespace!
to not require imported symbols being available.#[macro_export]
attribute.Are these changes tested?
Yes. There's an isolated test to show that the macro now works without any
use
statements.Are there any user-facing changes?
Some folks might get "unused import" diagnostics/warnings after this change, maybe?