Skip to content

Commit 12f5052

Browse files
committed
fix(rustup): workaround rustlang bug
Due to rust-lang/rust#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.
1 parent 0a62d04 commit 12f5052

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/device.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ impl<C> DeviceFlow<C>
192192
.collect::<String>()
193193
.as_ref())]);
194194

195-
match self.client.borrow_mut().post(FlowType::Device.as_ref())
195+
// note: works around bug in rustlang
196+
// https://github.com/rust-lang/rust/issues/22252
197+
let ret = match self.client.borrow_mut().post(FlowType::Device.as_ref())
196198
.header(ContentType("application/x-www-form-urlencoded".parse().unwrap()))
197199
.body(&*req)
198200
.send() {
@@ -237,7 +239,9 @@ impl<C> DeviceFlow<C>
237239
self.id = client_id.to_string();
238240
Ok(pi)
239241
}
240-
}
242+
};
243+
244+
ret
241245
}
242246

243247
/// If the first call is successful, this method may be called.
@@ -394,4 +398,4 @@ pub mod tests {
394398
// As our mock has only 3 items, we would panic on this call
395399
assert_eq!(flow.poll_token().unwrap(), Some(t));
396400
}
397-
}
401+
}

0 commit comments

Comments
 (0)