Skip to content

Additional NonZero conversions - #129036

Open
clarfonthey wants to merge 1 commit into
rust-lang:mainfrom
clarfonthey:nonzero-conversions
Open

Additional NonZero conversions#129036
clarfonthey wants to merge 1 commit into
rust-lang:mainfrom
clarfonthey:nonzero-conversions

Conversation

@clarfonthey

@clarfonthey clarfonthey commented Aug 13, 2024

Copy link
Copy Markdown
Contributor

ACP: rust-lang/libs-team#145

Requires FCP due to insta-stable APIs added:

//  can't be done generically; compiler can't infer that ZeroablePrimitive is sealed for coherence reasons
impl From<&NonZero<uN>> for &uN;
impl From<&NonZero<iN>> for &iN;
impl From<&NonZero<usize>> for &usize;
impl From<&NonZero<isize>> for &isize;
impl From<&NonZero<char>> for &char;

// excluded due to typechecking bug, but left commented out in code
// impl<T> From<&[NonZero<T>]> for &[T] where T: ZeroablePrimitive;

// rest are generic
impl<T, const N: usize> From<[NonZero<T>; N]> for [T; N] where T: ZeroablePrimitive;
impl<T> TryFrom<&T> for &NonZero<T> where T: ZeroablePrimitive;
impl<T> TryFrom<&[T]> for &[NonZero<T>] where T: ZeroablePrimitive;
impl<T, const N: usize> TryFrom<[T; N]> for [NonZero<T>; N] where T: ZeroablePrimitive;

Note that the Error for the TryFrom implementations is TryFromIntError to match the similar impls.

r? rust-lang/libs-api

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 13, 2024
@rust-log-analyzer

This comment has been minimized.

@bors

bors commented Aug 29, 2024

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #129750) made this pull request unmergeable. Please resolve the merge conflicts.

@rust-log-analyzer

This comment has been minimized.

@tgross35 tgross35 added needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. T-libs-api [DEPRECATED; DO NOT USE] and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 19, 2024
@Dylan-DPC

Copy link
Copy Markdown
Member

@clarfonthey since this is waiting on a review, do you still want this to be as a draft? or is this ready for review?

@clarfonthey

Copy link
Copy Markdown
Contributor Author

It is ready for review; see the OP.

I should just unmark it as draft and do what I said I was going to do, which is manually implement everything for all the NonZero types. I don't think it's going to be possible to fix the errors unless we actually come up with a way to track sealed traits for coherence, which I don't think is going to happen for a long time.

I'll unmark as draft once I make those changes.

@bors

bors commented Mar 7, 2025

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #138177) made this pull request unmergeable. Please resolve the merge conflicts.

@Dylan-DPC Dylan-DPC added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 23, 2025
@Dylan-DPC

Copy link
Copy Markdown
Member

@clarfonthey any updates on this? thanks

@rust-log-analyzer

This comment has been minimized.

@clarfonthey
clarfonthey force-pushed the nonzero-conversions branch 2 times, most recently from ea6ddb9 to aba3806 Compare February 18, 2026 01:42
@rust-log-analyzer

This comment has been minimized.

@clarfonthey
clarfonthey marked this pull request as ready for review February 18, 2026 03:54
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 18, 2026
@clarfonthey

Copy link
Copy Markdown
Contributor Author

@rustbot ready

One of the implementations was not possible due to inference issues, and one of them has to be done via a macro due to coherence issues, but the rest are working as intended.

@clarfonthey clarfonthey added T-libs Relevant to the library team, which will review and decide on the PR/issue. and removed T-libs-api [DEPRECATED; DO NOT USE] labels Aug 12, 2026
}
}

// FIXME: see library/std/tests/slice-from-array-issue-113238.rs

@ChrisDenton ChrisDenton Aug 20, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did you want to leave in the whole commented out block?

View changes since the review

@ChrisDenton ChrisDenton added the I-libs-nominated Nominated for discussion during a libs team meeting. label Aug 20, 2026
@ChrisDenton

Copy link
Copy Markdown
Member

Requires FCP due to insta-stable APIs added

@clarfonthey I've nominated this for that reason.

@clarfonthey

Copy link
Copy Markdown
Contributor Author

You've found out how to force me to rebase my old PR…!

@clarfonthey

Copy link
Copy Markdown
Contributor Author

@rustbot reroll (since BurntSushi isn't on the review rotation)

@rustbot rustbot assigned nia-e and unassigned BurntSushi Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

I-libs-nominated Nominated for discussion during a libs team meeting. needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants