Skip to content
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

Merged
merged 2 commits into from
Feb 7, 2025

Conversation

davisp
Copy link
Member

@davisp davisp commented Feb 5, 2025

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?

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?

  1. Fix config_namespace! to not require imported symbols being available.
  2. Re-add the inadvertently removed #[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?

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.
@github-actions github-actions bot added the common Related to common crate label Feb 5, 2025
@@ -2093,3 +2094,22 @@ mod tests {
assert_eq!(parsed_metadata.get("key_dupe"), Some(&Some("B".into())));
}
}

#[cfg(test)]
mod tests_isolated {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mod tests_isolated {
mod tests {

I think it may be best to stick to convention here.

// can compile without any surrounding `use` statements. Hence putting
// it into its own test module.
#[test]
fn check_config_namespace_macro() {
Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @davisp and @rkrishn7

// can compile without any surrounding `use` statements. Hence putting
// it into its own test module.
#[test]
fn check_config_namespace_macro() {
Copy link
Contributor

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?

@github-actions github-actions bot added the core Core DataFusion crate label Feb 6, 2025
@davisp
Copy link
Member Author

davisp commented Feb 6, 2025

@alamb Thanks for the tip! I've moved the test to the macro_hygiene module.

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @davisp and @rkrishn7

@alamb alamb merged commit 46bcb03 into apache:main Feb 7, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
common Related to common crate core Core DataFusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The config_namespace! macro requires datafusion::common::Result to be in scope
3 participants