-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-inferenceArea: Type inferenceArea: Type inferenceC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.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
The following code fails to compile:
pub trait Bar {
fn new() -> Self;
}
pub struct Foo {}
impl Bar for Foo {
fn new() -> Self {
Foo {}
}
}
pub struct Qux<B=Foo> where B: Bar {
foo: B,
}
impl<B> Qux<B> where B: Bar {
fn new() -> Self {
Qux { foo: B::new() }
}
}
fn main() {
let q = Qux::new();
}
The error is:
rustc 1.14.0-nightly (6e8f92f11 2016-10-07)
error[E0282]: unable to infer enough type information about `_`
--> <anon>:24:13
|
24 | let q = Qux::new();
| ^^^^^^^^ cannot infer type for `_`
|
= note: type annotations or generic parameter binding required
error: aborting due to previous error
(from playpen ; same with stable)
Strangely, replacing that failing line with:
let q: Qux = Qux::new()
makes it compile.
Metadata
Metadata
Assignees
Labels
A-inferenceArea: Type inferenceArea: Type inferenceC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.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.