fix(rustup): workaround rustlang bug

Due to https://github.com/rust-lang/rust/issues/22252, r-value
temporaries outlive the lifetimes of variables bound with let
statements in a function body. Because of this, device.rs fails to
compile against newer rustc nightlies.

This implements a simple workaround that binds the result of the match
in `request_code` to a local variable before returning it. This allows
it to have the same lifetime as `req` in one of the previous let
bindings.
This commit is contained in:
William Orr
2015-05-10 18:04:22 -07:00
parent 0a62d04476
commit 47b68cf401

View File

@@ -192,7 +192,9 @@ impl<C> DeviceFlow<C>
.collect::<String>()
.as_ref())]);
match self.client.borrow_mut().post(FlowType::Device.as_ref())
// note: works around bug in rustlang
// https://github.com/rust-lang/rust/issues/22252
let ret = match self.client.borrow_mut().post(FlowType::Device.as_ref())
.header(ContentType("application/x-www-form-urlencoded".parse().unwrap()))
.body(&*req)
.send() {
@@ -237,7 +239,9 @@ impl<C> DeviceFlow<C>
self.id = client_id.to_string();
Ok(pi)
}
}
};
ret
}
/// If the first call is successful, this method may be called.
@@ -394,4 +398,4 @@ pub mod tests {
// As our mock has only 3 items, we would panic on this call
assert_eq!(flow.poll_token().unwrap(), Some(t));
}
}
}