Closed
Description
Consider the following source:
pub struct Foo<A: Default, B: Default>(A, B);
impl<A: Default, B: Default> Foo<A, B> {
fn new(a: A) -> Self { Foo(a, B::default()) }
}
pub type Bar<A, B=usize> = Foo<A, B>;
fn main() {
let bar = Bar::new(42usize);
}
This fails to build with:
error[E0283]: type annotations required: cannot resolve `_: std::default::Default`
--> src/main.rs:10:15
|
10 | let bar = Bar::new(42usize);
| ^^^^^^^^
|
note: required by `<Foo<A, B>>::new`
--> src/main.rs:4:5
|
4 | fn new(a: A) -> Self { Foo(a, B::default()) }
| ^^^^^^^^^^^^^^^^^^^^
IOW, it does want Bar::<usize>::new
instead of Bar::new
.
pub type Bar<A> = Foo<A, usize>
also does Bar::new
work.