Closed
Description
Sometimes the lifetime of an expression is considered too short when it's an rvalue, but the equivalent code using match
works just fine:
use std::hashmap::HashMap;
struct A(int, int);
fn main() {
let m: HashMap<int, A> = HashMap::new();
let A(ref _a, ref _b) = *m.get(&1); // compiler error!
let (a, b) = match *m.get(&1) { A(ref _a, ref _b) => (_a, _b) }; // ok
}
This may be related to #3511, but this seems like it may just be a bug in lifetimes somewhere?
ping @nikomatsakis