Closed
Description
Code:
#[derive(Default)]
struct Foo;
impl Foo {
fn set_quux(&mut self, v: u32) {
}
}
fn main() {
let mut v: Vec<Foo> = Vec::new();
// this works perfectly: type of msg1 is inferred
let mut msg1 = Default::default();
v.push(msg1);
// type of msg2 is explicitly specified
let mut msg2: Foo = Default::default();
msg2.set_quux(17);
v.push(msg2);
// type of msg3 could be inferred from parameter type of v.push(...)
// although compiler reports:
// error: the type of this value must be known in this context
let mut msg3 = Default::default();
msg3.set_quux(19); // <-- on this line
v.push(msg3);
}