You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#[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);
}
The text was updated successfully, but these errors were encountered:
I think this might be the same as (or at least related to) #25165, which is also an instance of type inference breaking when you use a member function.
Code:
The text was updated successfully, but these errors were encountered: