Skip to content

Conversation

taiki-e
Copy link
Contributor

@taiki-e taiki-e commented Sep 23, 2025

It appears type inferences no longer works due to the addition of several PartialEq implementations around CStr.

https://github.com/bytecodealliance/rustix/actions/runs/17935800005/job/51001634461

error[E0283]: type annotations needed
  --> tests/net/addr.rs:34:20
   |
34 |         cstr!("/").into()
   |                    ^^^^ cannot infer type for type parameter `U`
   |
   = note: cannot satisfy `_: From<&CStr>`
   = note: required for `&CStr` to implement `Into<_>`
error[E0283]: type annotations needed
  --> tests/path/arg.rs:19:32
   |
19 |     assert_eq!(cstr!("hello"), Borrow::borrow(&t.as_cow_c_str().unwrap()));
   |                                ^^^^^^^^^^^^^^ -------------------------- type must be known at this point
   |                                |
   |                                cannot infer type of the type parameter `Borrowed` declared on the trait `Borrow`
   |
   = note: multiple `impl`s satisfying `Cow<'_, CStr>: Borrow<_>` found in the following crates: `alloc`, `core`:
           - impl<'a, B> Borrow<B> for Cow<'a, B>
             where B: ToOwned, B: ?Sized;
           - impl<T> Borrow<T> for T
             where T: ?Sized;
help: consider specifying the generic argument
   |
19 |     assert_eq!(cstr!("hello"), Borrow::<Borrowed>::borrow(&t.as_cow_c_str().unwrap()));
   |                                      ++++++++++++

```
error[E0283]: type annotations needed
  --> tests/net/addr.rs:34:20
   |
34 |         cstr!("/").into()
   |                    ^^^^ cannot infer type for type parameter `U`
   |
   = note: cannot satisfy `_: From<&CStr>`
   = note: required for `&CStr` to implement `Into<_>`
```

```
error[E0283]: type annotations needed
  --> tests/path/arg.rs:19:32
   |
19 |     assert_eq!(cstr!("hello"), Borrow::borrow(&t.as_cow_c_str().unwrap()));
   |                                ^^^^^^^^^^^^^^ -------------------------- type must be known at this point
   |                                |
   |                                cannot infer type of the type parameter `Borrowed` declared on the trait `Borrow`
   |
   = note: multiple `impl`s satisfying `Cow<'_, CStr>: Borrow<_>` found in the following crates: `alloc`, `core`:
           - impl<'a, B> Borrow<B> for Cow<'a, B>
             where B: ToOwned, B: ?Sized;
           - impl<T> Borrow<T> for T
             where T: ?Sized;
help: consider specifying the generic argument
   |
19 |     assert_eq!(cstr!("hello"), Borrow::<Borrowed>::borrow(&t.as_cow_c_str().unwrap()));
   |                                      ++++++++++++
```
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.

1 participant