Skip to content

uutests: Uniformize AtPath interfaces to accept AsRef<Path> - #15288

Open
RenjiSann wants to merge 2 commits into
uutils:mainfrom
RenjiSann:at-write-impl-path
Open

RenjiSann wants to merge 2 commits into
uutils:mainfrom
RenjiSann:at-write-impl-path

Conversation

@RenjiSann

Copy link
Copy Markdown
Collaborator

Closes #15287

@RenjiSann
RenjiSann marked this pull request as draft October 12, 2026 19:58
@RenjiSann
RenjiSann force-pushed the at-write-impl-path branch 10 times, most recently from 4c8b287 to 453b740 Compare October 13, 2026 00:47
@RenjiSann
RenjiSann marked this pull request as ready for review October 13, 2026 00:47
@RenjiSann
RenjiSann requested a review from cakebaker October 13, 2026 00:53
Comment thread tests/uutests/src/lib/macros.rs Outdated
@RenjiSann
RenjiSann force-pushed the at-write-impl-path branch 4 times, most recently from bab7865 to 29263eb Compare October 13, 2026 21:07
@RenjiSann
RenjiSann force-pushed the at-write-impl-path branch 3 times, most recently from eadbd32 to 14cb58a Compare October 21, 2026 13:37
@RenjiSann
RenjiSann marked this pull request as draft October 21, 2026 13:42
@RenjiSann
RenjiSann force-pushed the at-write-impl-path branch 4 times, most recently from 574da85 to 19ef49b Compare October 21, 2026 15:52
@RenjiSann
RenjiSann marked this pull request as ready for review October 21, 2026 16:20
@RenjiSann
RenjiSann requested a review from xtqqczze October 22, 2026 14:00
@xtqqczze

Copy link
Copy Markdown
Collaborator

I noticed that this PR introduces stylistic changes to generic parameters. Could we first agree on which style we prefer before applying these changes?

trait MyTrait {}
fn foo(a: impl MyTrait) {
    // [...]
}

versus

trait MyTrait {}
fn foo<T: MyTrait>(a: T) {
    // [...]
}

Clippy provides a restriction lint, clippy::impl_trait_in_params, for the former style.

@RenjiSann

RenjiSann commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator Author

I noticed that this PR introduces stylistic changes to generic parameters. Could we first agree on which style we prefer before applying these changes?

trait MyTrait {}
fn foo(a: impl MyTrait) {
    // [...]
}

versus

trait MyTrait {}
fn foo<T: MyTrait>(a: T) {
    // [...]
}

Clippy provides a restriction lint, clippy::impl_trait_in_params, for the former style.

I'd say let's use the impl syntax when possible (whenever the trait is not composite T: A + B), or if you explicitely need several parameters to reference the same type

@RenjiSann

Copy link
Copy Markdown
Collaborator Author

@xtqqczze if you prefer, I can use the <T: Trait> syntax everywhere, though I find the other one more readable

@xtqqczze

Copy link
Copy Markdown
Collaborator

I do have a concern that this PR includes a refactoring that converts existing <P: AsRef<Path>> bounds to impl AsRef<Path>. This change might be better handled separately, or at least in a separate commit, to keep the scope of this PR focused.

I don't have a strong preference between the two syntaxes, so I'd be interested to hear what other reviewers think.

@RenjiSann
RenjiSann force-pushed the at-write-impl-path branch 3 times, most recently from ecc235a to 3fe2e24 Compare October 23, 2026 15:45
@RenjiSann

Copy link
Copy Markdown
Collaborator Author

@xtqqczze I changed back to the <P: AsRef<Path>> syntax, so we can address the syntax preference issue elsewhere

}

pub fn append(&self, name: impl AsRef<Path>, contents: &str) {
pub fn append<P: AsRef<Path>>(&self, name: P, contents: &str) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this change would be better handled separately, or at least in a separate commit.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I disagree with this one specifically. This PR is meant to uniformize the interface of AtPath, and I consider uniformizing the syntax of the whole interface to be in scope, whether it is with the impl AsRef<Path> or <T: AsRef<Path>> syntax

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If you consider this in scope, the style change should still be made in a separate commit.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MakeAtPath::write to take an AsRef<Path>

3 participants