Skip to content

Fix deranged-related TryFrom ambiguity#515

Merged
tikue merged 1 commit intogoogle:masterfrom
dtolnay-contrib:deranged
Mar 26, 2025
Merged

Fix deranged-related TryFrom ambiguity#515
tikue merged 1 commit intogoogle:masterfrom
dtolnay-contrib:deranged

Conversation

@dtolnay
Copy link
Copy Markdown
Contributor

@dtolnay dtolnay commented Mar 26, 2025

When building tarpc in a build graph that also contains deranged, it fails to build. See upstream's related issue jhpratt/deranged#18.

error[E0283]: type annotations needed
   --> tarpc/src/server/limits/channels_per_key.rs:200:26
    |
200 |                 if count >= TryFrom::try_from(*self_.channels_per_key).unwrap() {
    |                          ^^ cannot infer type
    |
    = note: multiple `impl`s satisfying `usize: PartialOrd<_>` found in the following crates: `core`, `deranged`:
            - impl PartialOrd for usize;
            - impl<MIN, MAX> PartialOrd<RangedUsize<MIN, MAX>> for usize
              where the constant `MIN` has type `usize`, the constant `MAX` has type `usize`;

@dtolnay dtolnay changed the title Fix deranged-related .into() ambiguity Fix deranged-related TryFrom ambiguity Mar 26, 2025
Copy link
Copy Markdown
Collaborator

@tikue tikue left a comment

Choose a reason for hiding this comment

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

Appreciate it!

@dtolnay
Copy link
Copy Markdown
Contributor Author

dtolnay commented Mar 26, 2025

Rustfmt job failure and clippy job failure are both unrelated to this PR.

Diff in /home/runner/work/tarpc/tarpc/tarpc/src/server/request_hook/before.rs:157:
 impl<Req, First: BeforeRequest<Req>, Rest: BeforeRequestList<Req>> BeforeRequestList<Req>
     for BeforeRequestCons<First, Rest>
 {
-    type Then<Next> = BeforeRequestCons<First, Rest::Then<Next>> where Next: BeforeRequest<Req>;
+    type Then<Next>
+        = BeforeRequestCons<First, Rest::Then<Next>>
+    where
+        Next: BeforeRequest<Req>;
 
     fn then<Next: BeforeRequest<Req>>(self, next: Next) -> Self::Then<Next> {
         let BeforeRequestCons(first, rest) = self;
Diff in /home/runner/work/tarpc/tarpc/tarpc/src/server/request_hook/before.rs:172:
 }
 
 impl<Req> BeforeRequestList<Req> for BeforeRequestNil {
-    type Then<Next> = BeforeRequestCons<Next, BeforeRequestNil> where Next: BeforeRequest<Req>;
+    type Then<Next>
+        = BeforeRequestCons<Next, BeforeRequestNil>
+    where
+        Next: BeforeRequest<Req>;
 
     fn then<Next: BeforeRequest<Req>>(self, next: Next) -> Self::Then<Next> {
         BeforeRequestCons(next, BeforeRequestNil)
error: the following explicit lifetimes could be elided: 'a
   --> plugins/src/lib.rs:535:6
    |
535 | impl<'a> ServiceGenerator<'a> {
    |      ^^                   ^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
    = note: `-D clippy::needless-lifetimes` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::needless_lifetimes)]`
help: elide the lifetimes
    |
535 - impl<'a> ServiceGenerator<'a> {
535 + impl ServiceGenerator<'_> {
    |

    Checking http v1.3.1
error: the following explicit lifetimes could be elided: 'a
   --> plugins/src/lib.rs:811:6
    |
811 | impl<'a> ToTokens for ServiceGenerator<'a> {
    |      ^^                                ^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
help: elide the lifetimes
    |
811 - impl<'a> ToTokens for ServiceGenerator<'a> {
811 + impl ToTokens for ServiceGenerator<'_> {
    |

auto-merge was automatically disabled March 26, 2025 21:24

Head branch was pushed to by a user without write access

@dtolnay
Copy link
Copy Markdown
Contributor Author

dtolnay commented Mar 26, 2025

Rebased over #516 and #517.

@tikue tikue enabled auto-merge March 26, 2025 21:29
@tikue tikue added this pull request to the merge queue Mar 26, 2025
Merged via the queue into google:master with commit fa537fc Mar 26, 2025
32 checks passed
@dtolnay dtolnay deleted the deranged branch March 26, 2025 21:36
@dtolnay
Copy link
Copy Markdown
Contributor Author

dtolnay commented Mar 26, 2025

Would it be possible to get this in a crates.io release relatively soon? I expect a nontrivial fraction of tarpc users depend on the troublesome deranged dependency and are currently broken, because it's a dependency of the widely used time crate and pulled in by rustls, tracing, zip, etc.

facebook-github-bot pushed a commit to facebookexperimental/rust-shed that referenced this pull request Mar 26, 2025
Summary:
Upstream PR: google/tarpc#515

This is required in order to unblock {D71914596}

Reviewed By: JakobDegen

Differential Revision: D71914594

fbshipit-source-id: 345f5680770de172dac3da5ae2fd40e6cafabc65
facebook-github-bot pushed a commit to facebook/sapling that referenced this pull request Mar 26, 2025
Summary:
Upstream PR: google/tarpc#515

This is required in order to unblock {D71914596}

Reviewed By: JakobDegen

Differential Revision: D71914594

fbshipit-source-id: 345f5680770de172dac3da5ae2fd40e6cafabc65
@tikue
Copy link
Copy Markdown
Collaborator

tikue commented Mar 27, 2025

Would it be possible to get this in a crates.io release relatively soon? I expect a nontrivial fraction of tarpc users depend on the troublesome deranged dependency and are currently broken, because it's a dependency of the widely used time crate and pulled in by rustls, tracing, zip, etc.

Done, let me know if you have any issues. Thanks!

facebook-github-bot pushed a commit to facebook/sapling that referenced this pull request Mar 27, 2025
Summary: PR google/tarpc#515 has been published in tarpc version 0.36.0, so the patch from {D71914594} is no longer needed.

Differential Revision: D71943918

fbshipit-source-id: 5bf610258cb86521666536d673a2c751f494f5c9
facebook-github-bot pushed a commit to facebookexperimental/rust-shed that referenced this pull request Mar 27, 2025
Summary: PR google/tarpc#515 has been published in tarpc version 0.36.0, so the patch from {D71914594} is no longer needed.

Differential Revision: D71943918

fbshipit-source-id: 5bf610258cb86521666536d673a2c751f494f5c9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants