I tried this code:
pub fn wut() -> impl Sized {
struct Foo { x: u32 }
if false {
let foo = wut();
let _closure = move || {
// let foo = foo; // Works if this is uncommented
let Foo { x } = foo;
let _y = x;
};
}
Foo { x: 7 }
}
(Thanks to @theemathas for a minimization not requiring TAIT.)
I expected to see this happen: Compiles successfully.
Instead, this happened:
Compiling playground v0.0.1 (/playground)
error[E0381]: used binding `x` isn't initialized
--> src/lib.rs:9:22
|
8 | let Foo { x } = foo;
| - binding declared here but left uninitialized
9 | let _y = x;
| ^ `x` used here but it isn't initialized
warning: value captured by `foo.x` is never read
--> src/lib.rs:8:29
|
8 | let Foo { x } = foo;
| ^^^
|
= help: did you mean to capture by reference instead?
= note: `#[warn(unused_assignments)]` (part of `#[warn(unused)]`) on by default
For more information about this error, try `rustc --explain E0381`.
warning: `playground` (lib) generated 1 warning
error: could not compile `playground` (lib) due to 1 previous error; 1 warning emitted
Meta
(Tested on playground with stable 1.94.1 and nightly 1.96.)
I tried this code:
(Thanks to @theemathas for a minimization not requiring TAIT.)
I expected to see this happen: Compiles successfully.
Instead, this happened:
Meta
(Tested on playground with stable 1.94.1 and nightly 1.96.)