You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rustc panics with the following message when trying to compile this: error: internal compiler error: librustc_mir/transform/generator.rs:495: Broken MIR: generator contains type std::cell::Ref<u32> in MIR, but typeck only knows about for<'r, 's, 't0> {&'r std::cell::RefCell<u32>, &'s std::cell::Ref<'t0, u32>, u32, ()}
#![feature(generators, generator_trait)]
use std::ops::Generator;
use std::cell::RefCell;
fn foo<'a>(y: &'a RefCell<u32>) -> impl Generator + 'a {
return move || {
yield *y.borrow();
return "Done";
};
}
fn main() {
let y = 10;
let y_cell = RefCell::new(y);
foo(&y_cell);
}
My guess is that the code which calculates the generator interior gets the incorrect type for the y.borrow() node due to an adjustment or it doesn't see that the temporary std::cell::Ref value is alive across the yield statement.
Moving the y.borrow() call into a temporary is a workaround:
#![feature(generators, generator_trait)]use std::ops::Generator;use std::cell::RefCell;fnfoo<'a>(y:&'a RefCell<u32>) -> implGenerator + 'a {returnmove || {let a = y.borrow();yield*a;return"Done";};}fnmain(){let y = 10;let y_cell = RefCell::new(y);foo(&y_cell);}
Rustc panics with the following message when trying to compile this:
error: internal compiler error: librustc_mir/transform/generator.rs:495: Broken MIR: generator contains type std::cell::Ref<u32> in MIR, but typeck only knows about for<'r, 's, 't0> {&'r std::cell::RefCell<u32>, &'s std::cell::Ref<'t0, u32>, u32, ()}
Playground link
Backtrace:
Version:
The text was updated successfully, but these errors were encountered: