mirror of
https://github.com/OMGeeky/yup-oauth2.git
synced 2026-02-02 06:51:23 +01:00
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:
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user