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(lex): Deprecate unsound OsStrExt::split_at #4802

Merged
merged 2 commits into from Mar 28, 2023
Merged

Conversation

epage
Copy link
Member

@epage epage commented Mar 28, 2023

This also clarifies safety requirements throughout the code

  • Technically OsStr is not transparent yet but effectively it is
  • OsStr does have invariants to uphold, similar to str

Fixes #4800

@epage epage merged commit 4b180f8 into clap-rs:master Mar 28, 2023
20 of 21 checks passed
@epage epage deleted the osstr branch March 28, 2023 15:00
Copy link
Contributor

@blyxxyz blyxxyz left a comment

Choose a reason for hiding this comment

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

Thank you for the quick fix!

@@ -193,6 +193,7 @@ pub trait OsStrExt: private::Sealed {
/// assert_eq!("Per", first);
/// assert_eq!(" Martin-Löf", last);
/// ```
#[deprecated(since = "4.1.0", note = "This is not sound for all `index`")]
fn split_at(&self, index: usize) -> (&OsStr, &OsStr);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this one also be marked unsafe? Technically a BC break, but that's ok given the time scale and circumstances.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd rather just soon release a v0.5 with it removed. This is an intermediate release so it will work with clap v4.1.x (as master is already prepped for v4.2.x)

clap_lex/src/ext.rs Show resolved Hide resolved
clap_lex/src/ext.rs Show resolved Hide resolved
epage added a commit to epage/clap that referenced this pull request Mar 28, 2023
This is a followup to comments on clap-rs#4802
@epage
Copy link
Member Author

epage commented Mar 28, 2023

Addressed the comments in #4803

Thanks for looking!

epage added a commit to epage/clap that referenced this pull request Mar 28, 2023
This is a followup to comments on clap-rs#4802
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.

clap_lex::OsStrExt is unsound
2 participants