-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Tracking Issue for generic NonZero
#120257
Comments
…=dtolnay Remove `raw_os_nonzero` feature. This feature is superseded by a generic `NonZero` type: rust-lang#120257 Closes rust-lang#82363.
Rollup merge of rust-lang#120295 - reitermarkus:remove-ffi-nonzero, r=dtolnay Remove `raw_os_nonzero` feature. This feature is superseded by a generic `NonZero` type: rust-lang#120257 Closes rust-lang#82363.
…ructors, r=dtolnay,oli-obk Make `NonZero` constructors generic. This makes `NonZero` constructors generic, so that `NonZero::new` can be used without turbofish syntax. Tracking issue: rust-lang#120257 ~~I cannot figure out how to make this work with `const` traits. Not sure if I'm using it wrong or whether there's a bug:~~ ```rust 101 | if n == T::ZERO { | ^^^^^^^^^^^^ expected `host`, found `true` | = note: expected constant `host` found constant `true` ``` r? `@dtolnay`
…ructors, r=dtolnay,oli-obk Make `NonZero` constructors generic. This makes `NonZero` constructors generic, so that `NonZero::new` can be used without turbofish syntax. Tracking issue: rust-lang#120257 ~~I cannot figure out how to make this work with `const` traits. Not sure if I'm using it wrong or whether there's a bug:~~ ```rust 101 | if n == T::ZERO { | ^^^^^^^^^^^^ expected `host`, found `true` | = note: expected constant `host` found constant `true` ``` r? ``@dtolnay``
…ructors, r=dtolnay,oli-obk Make `NonZero` constructors generic. This makes `NonZero` constructors generic, so that `NonZero::new` can be used without turbofish syntax. Tracking issue: rust-lang#120257 ~~I cannot figure out how to make this work with `const` traits. Not sure if I'm using it wrong or whether there's a bug:~~ ```rust 101 | if n == T::ZERO { | ^^^^^^^^^^^^ expected `host`, found `true` | = note: expected constant `host` found constant `true` ``` r? ```@dtolnay```
…ructors, r=dtolnay,oli-obk Make `NonZero` constructors generic. This makes `NonZero` constructors generic, so that `NonZero::new` can be used without turbofish syntax. Tracking issue: rust-lang#120257 ~~I cannot figure out how to make this work with `const` traits. Not sure if I'm using it wrong or whether there's a bug:~~ ```rust 101 | if n == T::ZERO { | ^^^^^^^^^^^^ expected `host`, found `true` | = note: expected constant `host` found constant `true` ``` r? ````@dtolnay````
…ructors, r=dtolnay,oli-obk Make `NonZero` constructors generic. This makes `NonZero` constructors generic, so that `NonZero::new` can be used without turbofish syntax. Tracking issue: rust-lang#120257 ~~I cannot figure out how to make this work with `const` traits. Not sure if I'm using it wrong or whether there's a bug:~~ ```rust 101 | if n == T::ZERO { | ^^^^^^^^^^^^ expected `host`, found `true` | = note: expected constant `host` found constant `true` ``` r? `````@dtolnay`````
…ructors, r=dtolnay,oli-obk Make `NonZero` constructors generic. This makes `NonZero` constructors generic, so that `NonZero::new` can be used without turbofish syntax. Tracking issue: rust-lang#120257 ~~I cannot figure out how to make this work with `const` traits. Not sure if I'm using it wrong or whether there's a bug:~~ ```rust 101 | if n == T::ZERO { | ^^^^^^^^^^^^ expected `host`, found `true` | = note: expected constant `host` found constant `true` ``` r? `@dtolnay`
…ructors, r=dtolnay,oli-obk Make `NonZero` constructors generic. This makes `NonZero` constructors generic, so that `NonZero::new` can be used without turbofish syntax. Tracking issue: rust-lang#120257 ~~I cannot figure out how to make this work with `const` traits. Not sure if I'm using it wrong or whether there's a bug:~~ ```rust 101 | if n == T::ZERO { | ^^^^^^^^^^^^ expected `host`, found `true` | = note: expected constant `host` found constant `true` ``` r? ``@dtolnay``
…ctors, r=dtolnay,oli-obk Make `NonZero` constructors generic. This makes `NonZero` constructors generic, so that `NonZero::new` can be used without turbofish syntax. Tracking issue: rust-lang#120257 ~~I cannot figure out how to make this work with `const` traits. Not sure if I'm using it wrong or whether there's a bug:~~ ```rust 101 | if n == T::ZERO { | ^^^^^^^^^^^^ expected `host`, found `true` | = note: expected constant `host` found constant `true` ``` r? `@dtolnay`
…ctors, r=dtolnay Make `NonZero` constructors generic. This makes `NonZero` constructors generic, so that `NonZero::new` can be used without turbofish syntax. Tracking issue: rust-lang#120257 ~~I cannot figure out how to make this work with `const` traits. Not sure if I'm using it wrong or whether there's a bug:~~ ```rust 101 | if n == T::ZERO { | ^^^^^^^^^^^^ expected `host`, found `true` | = note: expected constant `host` found constant `true` ``` r? `@dtolnay`
…ructors, r=Nilstrieb Use `transmute_unchecked` in `NonZero::new`. Tracking issue: rust-lang#120257 See rust-lang#120521 (comment).
…ructors, r=Nilstrieb Use `transmute_unchecked` in `NonZero::new`. Tracking issue: rust-lang#120257 See rust-lang#120521 (comment).
…ructors, r=Nilstrieb Use `transmute_unchecked` in `NonZero::new`. Tracking issue: rust-lang#120257 See rust-lang#120521 (comment).
…ructors, r=Nilstrieb Use `transmute_unchecked` in `NonZero::new`. Tracking issue: rust-lang#120257 See rust-lang#120521 (comment).
Rollup merge of rust-lang#120809 - reitermarkus:generic-nonzero-constructors, r=Nilstrieb Use `transmute_unchecked` in `NonZero::new`. Tracking issue: rust-lang#120257 See rust-lang#120521 (comment).
…r=Nilstrieb Use `transmute_unchecked` in `NonZero::new`. Tracking issue: rust-lang/rust#120257 See rust-lang/rust#120521 (comment).
…r=dtolnay Use generic `NonZero` internally. Tracking issue: rust-lang#120257
…r=dtolnay Make `NonZero::get` generic. Tracking issue: rust-lang#120257 Depends on rust-lang#120521. r? `@dtolnay`
Could we instead have it just be an unsafe marker auto trait (without the associated const), and later on have a Bikeshed: use core::mem::MaybeUninit;
unsafe auto trait InvalidZeroed: WithNiche {}
unsafe trait WithNiche {
const NICHE: Self;
}
unsafe impl<T: InvalidZeroed> WithNiche for T {
const NICHE: T = unsafe { MaybeUninit::zeroed().assume_init() };
} |
The problem is not creating the bit pattern, it's ensuring that pattern is used as a niche, which currently can only be done with
Creating a user-implementable |
Indeed, any discussion of having user-defined NonZero types is off-topic in this tracking issue. |
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. This will be merged soon. |
I probably should have been more clear, but the reason I brought it up is I'm not sure if it is merged as is, if it would be possible to change it to allow user-defined NonZero types in the future in a backwards compatible way. |
Yes, the |
…e, r=dtolnay Stabilize generic `NonZero`. Tracking issue: rust-lang#120257 r? `@dtolnay`
Rollup merge of rust-lang#124230 - reitermarkus:generic-nonzero-stable, r=dtolnay Stabilize generic `NonZero`. Tracking issue: rust-lang#120257 r? `@dtolnay`
Stabilize generic `NonZero`. Tracking issue: rust-lang/rust#120257 r? `@dtolnay`
Use generic `NonZero` internally. Tracking issue: rust-lang/rust#120257
Make `NonZero::get` generic. Tracking issue: rust-lang/rust#120257 Depends on rust-lang/rust#120521. r? `@dtolnay`
Use generic `NonZero` in tests. Tracking issue: rust-lang/rust#120257 r? `@dtolnay`
…,wesleywiser Move generic `NonZero` `rustc_layout_scalar_valid_range_start` attribute to inner type. Tracking issue: rust-lang/rust#120257 r? `@dtolnay`
…r=dtolnay Generic `NonZero` post-stabilization changes. Tracking issue: rust-lang#120257 r? `@dtolnay`
…r=dtolnay Generic `NonZero` post-stabilization changes. Tracking issue: rust-lang#120257 r? ``@dtolnay``
Rollup merge of rust-lang#124587 - reitermarkus:use-generic-nonzero, r=dtolnay Generic `NonZero` post-stabilization changes. Tracking issue: rust-lang#120257 r? ``@dtolnay``
Generic `NonZero` post-stabilization changes. Tracking issue: rust-lang/rust#120257 r? ``@dtolnay``
Generic `NonZero` post-stabilization changes. Tracking issue: rust-lang/rust#120257 r? ``@dtolnay``
Generic `NonZero` post-stabilization changes. Tracking issue: rust-lang/rust#120257 r? ``@dtolnay``
Create `Atomic<T>` type alias and use it in core/alloc/std where possible, ignoring test files for now. This is step one, creating the alias from `Atomic<T>` to `AtomicT`. The next step of flipping this and aliasing `AtomicT` to `Atomic<T>` will have a bigger impact, since `AtomicT` imports can be dropped once `Atomic::new` is a usable name. First commit is the true change. Second commit is mostly mechanical replacement of `AtomicT` type names with `Atomic<T>`. See [how this was done for `NonZero`](rust-lang#120257) for the rough blueprint I'm following. - ACP: rust-lang/libs-team#443 (comment) - Tracking issue: rust-lang#130539
Feature gate:
#![feature(generic_nonzero)]
This is a tracking issue for replacing the distinct
NonZero*
types with a genericNonZero<T>
type. This allows usingNonZero
with FFI type aliases instead of having weird type names likeNonZero_c_ulonglong
.This replaces the following tracking issues:
NonZero
trait #95157Public API
Steps / History
NonZero
type. #100428NonZero<T>
type alias. #119990NonZero
traits. #120160NonZero
alias direction. #120165Self
inNonZero*
implementations. #120244NonZero
constructors generic. #120521transmute_unchecked
inNonZero::new
. #120809NonZero::get
generic. #120563NonZero
internally. #120486NonZero
traits generically. #121241core::convert::num
. #121277NonZero
everywhere inlibrary
. #121454NonZero
in tests. #121461ZeroablePrimitive
trait unsafe. #121850NonZero
rustc_layout_scalar_valid_range_start
attribute to inner type. #121885NonZero
. #124230NonZero
post-stabilization changes. #124587Unresolved Questions
Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩
The text was updated successfully, but these errors were encountered: