You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code wraps the reqwest::ReqwestBuilder::header<K, V> method with a function that has the same signature. Both functions have generic parameters K and V that should be easily and independently inferred from the types passed to each function.
error[E0308]: mismatched types
--> src/lib.rs:16:33
|
1 | fn set_sensitive_header<K, V>(
| - this type parameter
...
16 | builder.header(key, header_value)
| ^^^^^^^^^^^^ expected type parameter `V`, found struct `HeaderValue`
|
= note: expected type parameter `V`
found struct `HeaderValue`
Adding the turbofish, as in the commented-out line, fixes the problem.
The generic types K and V on the header method should be trivially inferred from the supplied parameters. So this seems like a failure in type inference.
I thought this might be related to the where clauses constraining the concrete HeaderValue type, but changes like using TryFrom<V> + From<HeaderValue> did not fix it.
Activity
jongiddy commentedon May 13, 2022
@rustbot label A-inference
lcnr commentedon Aug 1, 2025
We have to eagerly prove
http::header::HeaderName: TryFrom<?value_generic_arg>before we consider the actual arguments type.This then incorrectly prefers the where-bound over the impl due to #24066. Closing as duplicate
ParamEnv) take precedence over freestanding trait impls #24066