Skip to content

Additional NonZero conversions#129036

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

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

Conversation

@clarfonthey
Copy link
Contributor

@clarfonthey clarfonthey commented Aug 13, 2024

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
Copy link
Collaborator

bors commented Aug 29, 2024

☔ 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 Relevant to the library API team, which will review and decide on the PR/issue. 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
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
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
Copy link
Collaborator

bors commented Mar 7, 2025

☔ 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
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
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.

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

Labels

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-api Relevant to the library API team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

Comments