-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.Status: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Unminimized example:
error[E0283]: type annotations needed
--> crates/websocat-ioless/src/lib.rs:346:27
|
346 | let w = w.sink_map_err(|e : std::io::Error |e.into());
| ^^^^^^^^^^^^
|
= note: multiple `impl`s satisfying `BytesCodec: Encoder<_>` found in the `tokio_util` crate:
- impl Encoder<BytesMut> for BytesCodec;
- impl Encoder<websocat_api::bytes::Bytes> for BytesCodec;
= note: required for `FramedWrite<Pin<Box<dyn tokio::io::AsyncWrite + std::marker::Send>>, BytesCodec>` to implement `websocat_api::futures::Sink<_>`
help: try using a fully qualified path to specify the expected types
|
346 | let w = <FramedWrite<Pin<Box<dyn tokio::io::AsyncWrite + std::marker::Send>>, BytesCodec> as SinkExt<Item>>::sink_map_err::<websocat_api::anyhow::Error, [closure@crates/websocat-ioless/src/lib.rs:346:40: 346:61]>(w, |e : std::io::Error |e.into());
| +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ~
(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)
.
Metadata
Metadata
Assignees
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.Status: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.