Skip to content
This repository was archived by the owner on Feb 11, 2026. It is now read-only.

Make 'complete' available to procmacro's output by conversion to module#135

Merged
tertsdiepraam merged 1 commit intouutils:mainfrom
BenWiederhake:dev-complete-visibility
Apr 16, 2025
Merged

Make 'complete' available to procmacro's output by conversion to module#135
tertsdiepraam merged 1 commit intouutils:mainfrom
BenWiederhake:dev-complete-visibility

Conversation

@BenWiederhake
Copy link
Copy Markdown
Contributor

This PR converts complete from a separate crate to a module, and makes it available via pub mod complete. This way, callers can use e.g. uutils_args::complete::Value without having to declare an additional dependency on the (former) uutils_args_complete crate.

Background: Using a proc-macro like #[derive(Arguments)] injects code that is evaluated in the context of the destination crate. In some cases, the proc-macros in derive inject a direct access to something in the (former) crate uutils_args_complete. This doesn't work if the destination crate doesn't add it as an explicit dependency, leading to compilation errors:

error[E0433]: failed to resolve: could not find `uutils_args_complete` in the list of imported crates
  --> src/uu/du/src/du.rs:81:10
   |
81 | #[derive(Arguments)]
   |          ^^^^^^^^^ could not find `uutils_args_complete` in the list of imported crates
   |
   = note: this error originates in the derive macro `Arguments` (in Nightly builds, run with -Z macro-backtrace for more info)

There are multiple ways to resolve this issue:

  • Option 1: Shrug, and tell all users that they must always add a dependency to uutils-args and also uutils-args-complete, leading to weird duplication.
  • Option 2: Make complete somehow available through uutils-args itself, e.g. at the path uutils_args::complete::*, and use that path when injecting code in our derive macro.

There are two ways to make it available:

  • Option 2a: pub extern crate uutils_args_complete as complete; or some abomination like that.
  • Option 2b: Stop trying to keep complete a separate crate, and merge it as a module. This gets rid of some redundant metadata, and simplifies the structure, in my eyes.

This PR uses Option 2b. In fact, since #131 makes complete a non-optional dependency anyway, I don't see a point in keeping it a separate crate.

Most changes are very boring: s/::uutils_args_complete/::uutils_args::complete/g and within the (former) crate complete, the string crate:: becomes crate::complete::. The rest is just formatting. That's it.

Copy link
Copy Markdown
Collaborator

@tertsdiepraam tertsdiepraam left a comment

Choose a reason for hiding this comment

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

Good call!

@tertsdiepraam tertsdiepraam merged commit 985af4a into uutils:main Apr 16, 2025
4 checks passed
@BenWiederhake BenWiederhake deleted the dev-complete-visibility branch April 18, 2025 14:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants