Skip to content

Additional NonZero conversions - #129036

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
clarfonthey:nonzero-conversions
Sep 29, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
clarfonthey:nonzero-conversions

Conversation

@clarfonthey

@clarfonthey clarfonthey commented Aug 13, 2024 •

Copy link
Copy Markdown
Contributor

View all comments

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
@rustbot

rustbot commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rust-rfcbot rust-rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Sep 25, 2026
@rust-rfcbot

Copy link
Copy Markdown
Collaborator

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

@clarfonthey

Copy link
Copy Markdown
Contributor Author

@bors try

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Sep 25, 2026
@rust-bors

rust-bors Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 5785136 (5785136349cbc890ac115fd9f79e0637abe7a6a7)
Base parent: 5ceaf66 (5ceaf6608eb354c2f5bbb3b8d974caa367dac81c)

@nia-e

nia-e commented Sep 28, 2026

Copy link
Copy Markdown
Member

@bors r+

@rust-bors

rust-bors Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

📌 Commit b6f9bfc has been approved by nia-e

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 28, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 28, 2026
…=nia-e

Additional NonZero conversions

ACP: rust-lang/libs-team#145

Requires FCP due to insta-stable APIs added:

```rust
// 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
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 28, 2026
…=nia-e

Additional NonZero conversions

ACP: rust-lang/libs-team#145

Requires FCP due to insta-stable APIs added:

```rust
// 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
rust-bors Bot pushed a commit that referenced this pull request Sep 28, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #158936 (Add `std::fs::{Home|Media}Dirs`)
 - #129036 (Additional NonZero conversions)
 - #158997 (Avoid recording unnameable `extern crate` aliases in diagnostic metadata)
 - #161015 (Stabilize `funnel_shifts` (including `const`))
 - #161712 (Stabilize `Result::into_{ok,err}`)
 - #162493 (Add support for -Zsanitizer-cfi-minimal-runtime)
 - #162655 (next solver: prefer to select impl candidates over global where-clause candidates)
 - #162862 (Fix intra doc link resolution when a doc comment is composed of both inner and outer doc comment)
 - #163200 (make `RustaceansAreAwesome` satisfy trait bounds)
 - #163331 (Move `Arc` and `Rc` into `rcs` mod)
 - #163427 (implement #![feature(gca_adts)])
 - #163428 (do not complain about unstable target features on nightly)
 - #163444 (Add `stable_rustc` helper in `run-make-support`)
 - #163447 (Allow using different index types when reading and writing to tables)
 - #163450 (Force the correct type variable to never for method resolution on an adjusted never type)
@rust-bors

This comment has been minimized.

@rust-bors rust-bors Bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 29, 2026
@rust-bors

rust-bors Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

☀️ Test successful - CI
Approved by: nia-e
Duration: 3h 2m 32s
Pushing 5d89371 to main...

@rust-bors
rust-bors Bot merged commit 5d89371 into rust-lang:main Sep 29, 2026
15 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Sep 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor
What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing c1070d6 (parent) -> 5d89371 (this PR)

Test differences

Show 2236 test diffs

2236 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 5d8937173e7c40406c167f4e94737da8925333ad --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. test-x86_64-msvc-ext1: 1h 19m -> 2h 25m (+82.7%)
  2. test-x86_64-gnu-miri: 52m 11s -> 1h 21m (+57.0%)
  3. dist-i686-mingw: 37m 48s -> 53m 39s (+41.9%)
  4. dist-armv7-linux: 1h 8m -> 1h 35m (+39.3%)
  5. dist-arm-linux-gnueabi: 1h 6m -> 1h 32m (+38.1%)
  6. test-x86_64-gnu-distcheck: 2h 26m -> 1h 34m (-35.6%)
  7. test-i686-gnu-1: 1h 41m -> 2h 16m (+34.2%)
  8. test-x86_64-gnu-stdlib-semver-check: 16m 22s -> 11m 5s (-32.3%)
  9. test-i686-gnu-nopt-1: 2h 21m -> 1h 40m (-28.7%)
  10. test-x86_64-gnu-aux: 2h 9m -> 1h 32m (-28.4%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (5d89371): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.4% [0.2%, 0.5%] 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 1.6%, secondary 4.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.6% [1.3%, 2.3%] 4
Regressions ❌
(secondary)
4.6% [2.4%, 7.8%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.6% [1.3%, 2.3%] 4

Cycles

Results (primary 2.4%, secondary 0.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.4% [2.4%, 2.4%] 1
Regressions ❌
(secondary)
1.5% [1.5%, 1.5%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.0% [-1.0%, -1.0%] 1
All ❌✅ (primary) 2.4% [2.4%, 2.4%] 1

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 487.231s -> 489.535s (0.47%)
Artifact size: 406.43 MiB -> 406.43 MiB (0.00%)

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

Labels

disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. merged-by-bors This PR was explicitly merged by bors. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-libs Relevant to the library team, which will review and decide on the PR/issue. to-announce Announce this issue on triage meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.