Skip to content

Limited nonzero coercion #143629

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jul 8, 2025

coercing NonZero<T> to T if all the types are available at the cast site.

This is fairly limited, as (as the tests show), this does not allow "reborrowing" &NonZero<T> as &T. It also fails quickly if the types aren't fully clear at the coercion site, but only resolved later.

Also cannot aid in trait selection or similar, even if there is clearly only one option.

Related:

cc @traviscross

@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 8, 2025
@compiler-errors
Copy link
Member

@bors2 try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rust-bors
Copy link

rust-bors bot commented Jul 8, 2025

⌛ Trying commit e341923 with merge 4a4dd8e

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jul 8, 2025
Limited nonzero coercion

coercing `NonZero<T>` to `T` if all the types are available at the cast site.

This is fairly limited, as (as the tests show), this does not allow "reborrowing" `&NonZero<T>` as `&T`. It also fails quickly if the types aren't fully clear at the coercion site, but only resolved later.

Also cannot aid in trait selection or similar, even if there is clearly only one option.

Related:

* #143594
* rust-lang/rfcs#3786

cc `@traviscross`
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-perf Status: Waiting on a perf run to be completed. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. 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.

4 participants