Closed
Description
My code does not compile any more after updating to 1.70.0. The project can be found here
Code
I tried to create a minimal reproducer. It has something to do with glib's clone macro, which I use. Here is the reproducer that compiles fine on 1.69 but not on 1.70.0. I left some comments in the code describing what I observed so far. It needs glib
and futures
dependency):
use futures::Future;
use glib::clone;
fn main() {
let obj = String::new();
do_async(
// just using `compound()` without `async` block works
async { compound().await },
clone!(@strong obj => move |info| if let Ok(info) = info {
// removing this line makes the code compile
println!("{:?}", info.t);
}),
);
}
struct Compound {
t: i32
}
// Just returning a simple type like i32 makes the code compile
async fn compound() -> Result<Compound, ()> {
Err(())
}
async fn do_async<R, Fut, F>(tokio_fut: Fut, glib_closure: F)
where
R: Send + 'static,
Fut: Future<Output = R> + Send + 'static,
F: FnOnce(R) + 'static,
{
glib_closure(tokio_fut.await);
}
Output
error[E0282]: type annotations needed for `Result<_, E>`
--> src/main.rs:9:37
|
9 | clone!(@strong obj => move |info| if let Ok(info) = info {
| ^^^^
10 | // removing this line makes the code compile
11 | println!("{:?}", info.t);
| ---- type must be known at this point
|
help: consider giving this closure parameter an explicit type, where the placeholders `_` are specified
|
9 | clone!(@strong obj => move |info: Result<_, E>| if let Ok(info) = info {
| ++++++++++++++
For more information about this error, try `rustc --explain E0282`.
I expected to see this happen: The type info
is correctly inferred
Instead, this happened: The compiler tells me that it doesn't know the type, although the type can be inferred
Version it worked on
It most recently worked on: 1.69.0
Version with regression
rustc --version --verbose
:
rustc 1.70.0 (90c541806 2023-05-31)
binary: rustc
commit-hash: 90c541806f23a127002de5b4038be731ba1458ca
commit-date: 2023-05-31
host: x86_64-unknown-linux-gnu
release: 1.70.0
LLVM version: 16.0.2