-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Compiler suggests to add [closure@…] to source code when it can be inferred instead. #103705
Comments
Sorry, the got confused by the closure and not recognized the Would be simpler if error message was minimized by omitting details that are not relevant to the the ambiguity and can continue to be inferred instead. |
Simpler example producing similar message: trait MyTrait<T> {
fn lol<F:FnOnce()>(&self, f:F) -> u16;
}
struct Qqq;
impl MyTrait<u32> for Qqq{
fn lol<F:FnOnce()>(&self, _f:F) -> u16 { 5 }
}
impl MyTrait<u64> for Qqq{
fn lol<F:FnOnce()>(&self, _f:F) -> u16 { 6 }
}
fn main() {
let q = Qqq;
q.lol(||());
}
|
We could create a new type folder that takes any closure type and replaces it with at minimum a |
…imulacrum Add a few known-bug tests The labels of these tests should be changed from `S-bug-has-mcve` to `S-bug-has-test` once this is merged. cc: rust-lang#101518 rust-lang#99492 rust-lang#90950 rust-lang#89196 rust-lang#104034 rust-lang#101350 rust-lang#103705 rust-lang#103899 I couldn't reproduce the failures in rust-lang#101962 and rust-lang#100772 (so either these have started passing, or I didn't repro properly), so leaving those out for now. rust-lang#102065 was a bit more complicated, since it uses `rustc_private` and I didn't want to mess with that.
Unminimized example:
(in vi/websocat@9ef27b9, caused by upgrade from tokio-util
0.6
->0.7
)And I'm not sure how do I explicitly choose the impl I want when it is buried deep in third-party generics.Aren't coherence rules designed to prevent this by the way?The diagnostic is useful, but contains a lot of types that can be inferred instead, including the closure type.
<_ as SinkExt<bytes::Bytes>>::sink_map_err
makes it compile. It would be better if code suggestion preserved as much reliance on the type inference as possible.rustc 1.66.0-nightly (0da281b60 2022-10-27)
.The text was updated successfully, but these errors were encountered: