-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-inferenceArea: Type inferenceArea: Type inferenceC-bugCategory: This is a bug.Category: This is a bug.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.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
I tried this code:
#![feature(associated_type_bounds)]
struct S;
fn fn1<I: IntoIterator<Item: AsRef<S>>>(_iter: I) -> Result<(), ()> {
Ok(())
}
async fn fn2(s: &str) -> Result<(), ()> {
let s = s.parse().map_err(|_| ())?; // <- Spurious type deduced
fn1(std::iter::once(s)).map_err(|e| ())?;
Ok(())
}
I expected to see this happen:
error[E0282]: type annotations needed
, because type of s
cannot be determined.
Instead, this happened:
error[E0277]: the trait bound '(): std::str::FromStr' is not satisfied
As if s
is assigned type ()
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-inferenceArea: Type inferenceArea: Type inferenceC-bugCategory: This is a bug.Category: This is a bug.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.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.