-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.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.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)The Rustc Trait System Refactor Initiative (-Znext-solver)
Description
fn foo() -> impl Sized {
foo()
}
results in
error[E0282]: type annotations needed
--> src/main.rs:2:5
|
2 | foo()
| ^^^^^ cannot infer type
error: aborting due to 1 previous error
we should mention that this ambiguity is in the hidden type of an opaque
rust/compiler/rustc_hir_typeck/src/opaque_types.rs
Lines 120 to 134 in ad85bc5
let infer_var = hidden_type | |
.ty | |
.walk() | |
.filter_map(ty::GenericArg::as_term) | |
.find(|term| term.is_infer()) | |
.unwrap_or_else(|| hidden_type.ty.into()); | |
self.err_ctxt() | |
.emit_inference_failure_err( | |
self.body_id, | |
hidden_type.span, | |
infer_var, | |
TypeAnnotationNeeded::E0282, | |
false, | |
) | |
.emit() |
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.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.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)The Rustc Trait System Refactor Initiative (-Znext-solver)