Skip to content
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

Implement NonZero traits generically. #121241

Merged
merged 1 commit into from
Feb 20, 2024

Conversation

reitermarkus
Copy link
Contributor

Tracking issue: #120257

r? @dtolnay

@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 Feb 17, 2024
@rust-log-analyzer

This comment has been minimized.

@dtolnay
Copy link
Member

dtolnay commented Feb 17, 2024

Strange that this would affect the diagnostic in this way, but I don't think it blocks this PR. echo 'type F = Fn() -> (u8)::Output;' | rustc --crate-type lib -

Before:

error[E0223]: ambiguous associated type
 --> <anon>:1:10
  |
1 | type F = Fn() -> (u8)::Output;
  |          ^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(dyn Fn() -> u8 + 'static) as IntoFuture>::Output`

After:

error[E0223]: ambiguous associated type
 --> <anon>:1:10
  |
1 | type F = Fn() -> (u8)::Output;
  |          ^^^^^^^^^^^^^^^^^^^^
  |
help: use fully-qualified syntax
  |
1 | type F = <(dyn Fn() -> u8 + 'static) as BitOr>::Output;
  |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 | type F = <(dyn Fn() -> u8 + 'static) as IntoFuture>::Output;
  |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thank you!

LGTM as soon as ui tests are blessed. x.py test tests/ui --bless

I reviewed the changes locally, there are 3 other changes which are insignificant.

--- a/tests/ui/fmt/ifmt-unimpl.stderr
+++ b/tests/ui/fmt/ifmt-unimpl.stderr
@@ -15,7 +15,7 @@ LL |     format!("{:X}", "3");
              i128
              usize
              u8
-           and 20 others
+           and 9 others
    = note: required for `&str` to implement `UpperHex`
 note: required by a bound in `core::fmt::rt::Argument::<'a>::new_upper_hex`
   --> $SRC_DIR/core/src/fmt/rt.rs:LL:COL
--- a/tests/ui/traits/issue-77982.stderr
+++ b/tests/ui/traits/issue-77982.stderr
@@ -46,7 +46,6 @@ LL |     let ips: Vec<_> = (0..100_000).map(|_| u32::from(0u32.into())).collect(
    = note: multiple `impl`s satisfying `u32: From<_>` found in the `core` crate:
            - impl From<Char> for u32;
            - impl From<Ipv4Addr> for u32;
-           - impl From<NonZero<u32>> for u32;
            - impl From<bool> for u32;
            - impl From<char> for u32;
            - impl From<u16> for u32;
--- a/tests/ui/try-trait/bad-interconversion.stderr
+++ b/tests/ui/try-trait/bad-interconversion.stderr
@@ -11,7 +11,6 @@ LL |     Ok(Err(123_i32)?)
    = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
    = help: the following other types implement trait `From<T>`:
              <u8 as From<bool>>
-             <u8 as From<NonZero<u8>>>
              <u8 as From<Char>>
    = note: required for `Result<u64, u8>` to implement `FromResidual<Result<Infallible, i32>>`

@dtolnay
Copy link
Member

dtolnay commented Feb 17, 2024

@bors delegate+

@bors
Copy link
Contributor

bors commented Feb 17, 2024

✌️ @reitermarkus, you can now approve this pull request!

If @dtolnay told you to "r=me" after making some further change, please make that change, then do @bors r=@dtolnay

@reitermarkus reitermarkus force-pushed the generic-nonzero-traits branch from 331f8c2 to f12d248 Compare February 17, 2024 20:59
@reitermarkus
Copy link
Contributor Author

@bors r=dtolnay

@bors
Copy link
Contributor

bors commented Feb 18, 2024

📌 Commit f12d248 has been approved by dtolnay

It is now in the queue for this repository.

@bors bors 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 Feb 18, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Feb 18, 2024
…s, r=dtolnay

Implement `NonZero` traits generically.

Tracking issue: rust-lang#120257

r? `@dtolnay`
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 18, 2024
…llaumeGomez

Rollup of 5 pull requests

Successful merges:

 - rust-lang#121067 (make "invalid fragment specifier" translatable)
 - rust-lang#121079 (distribute tool documentations and avoid file conflicts on `x install`)
 - rust-lang#121230 (Extend Level API)
 - rust-lang#121241 (Implement `NonZero` traits generically.)
 - rust-lang#121247 (Add help to `hir_analysis_unrecognized_intrinsic_function`)

r? `@ghost`
`@rustbot` modify labels: rollup
Noratrieb added a commit to Noratrieb/rust that referenced this pull request Feb 20, 2024
…s, r=dtolnay

Implement `NonZero` traits generically.

Tracking issue: rust-lang#120257

r? ``@dtolnay``
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 20, 2024
Rollup of 8 pull requests

Successful merges:

 - rust-lang#121167 (resolve: Scale back unloading of speculatively loaded crates)
 - rust-lang#121196 (Always inline check in `assert_unsafe_precondition` with cfg(debug_assertions))
 - rust-lang#121206 (Top level error handling)
 - rust-lang#121223 (intrinsics::simd: add missing functions)
 - rust-lang#121241 (Implement `NonZero` traits generically.)
 - rust-lang#121242 (Generate `getelementptr` instead of `inttoptr` for `ptr::invalid`)
 - rust-lang#121278 (Remove the "codegen" profile from bootstrap)
 - rust-lang#121286 (Rename `ConstPropLint` to `KnownPanicsLint`)

r? `@ghost`
`@rustbot` modify labels: rollup
Noratrieb added a commit to Noratrieb/rust that referenced this pull request Feb 20, 2024
…s, r=dtolnay

Implement `NonZero` traits generically.

Tracking issue: rust-lang#120257

r? ```@dtolnay```
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 20, 2024
Rollup of 8 pull requests

Successful merges:

 - rust-lang#121167 (resolve: Scale back unloading of speculatively loaded crates)
 - rust-lang#121196 (Always inline check in `assert_unsafe_precondition` with cfg(debug_assertions))
 - rust-lang#121241 (Implement `NonZero` traits generically.)
 - rust-lang#121278 (Remove the "codegen" profile from bootstrap)
 - rust-lang#121286 (Rename `ConstPropLint` to `KnownPanicsLint`)
 - rust-lang#121291 (target: Revert default to the medium code model on LoongArch targets)
 - rust-lang#121302 (Remove `RefMutL` hack in `proc_macro::bridge`)
 - rust-lang#121318 (Trigger `unsafe_code` lint on invocations of `global_asm`)

Failed merges:

 - rust-lang#121206 (Top level error handling)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit f6b4080 into rust-lang:master Feb 20, 2024
11 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Feb 20, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 20, 2024
Rollup merge of rust-lang#121241 - reitermarkus:generic-nonzero-traits, r=dtolnay

Implement `NonZero` traits generically.

Tracking issue: rust-lang#120257

r? ````@dtolnay````
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

5 participants