-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ICE with generators: Broken MIR: generator contains type ... in MIR, but typeck only knows about ...
#44184
Comments
cc @Zoxc |
So this the annoying The problem is that bindings in match command {
Command::A(_name) => {}
Command::B => {}
} is lowered into this (pre-drop-elaboration): switch command {
Command::A => {
storagelive(_name);
_name = (command as Command::A).0;
}
Command::B = {}
}
drop(_name);
storagedead(_name); Here It does not cause unsoundness because drop elaboration inserts a drop flag, but it does cause liveness to leak across the loop and make I think there's a way to solve the |
If we don't want to do that, another way would be to take a trick from LLVM, and use |
@arielb1 By that do you mean adding |
Adding a But what I meant was that |
I'm running into this issue while playing with |
I'm also running into this playing with FWIW, because this is caused by drop logic for variables bound in match arms, it can be worked around (ownership needs of your code permitting) by adding "ref" to variable bindings in match patterns. |
And if you do want to move the binding and thus can't use Command::A(_name) => {
return;
} to Command::A(_name) => {
let _name = _name;
return;
} |
Analyse storage liveness and preserve it during generator transformation This uses a dataflow analysis on `StorageLive` and `StorageDead` statements to infer where the storage of locals are live. The result of this analysis is intersected with the regular liveness analysis such that a local is can only be live when its storage is. This fixes #44184. If the storage of a local is live across a suspension point, we'll insert a `StorageLive` statement for it after the suspension point so storage liveness is preserved. This fixes #44179. r? @arielb1
This seems to be some sort of interaction with the
String
inside theCommand
enum in the following code as removing either variant stops the ICE from occuring.Example:
https://play.rust-lang.org/?gist=1d2672fd04e7df3dccbaf140f99fa7f6&version=nightly
Gives an ICE
internal compiler error: /checkout/src/librustc_mir/transform/generator.rs:340: Broken MIR: generator contains type std::string::String in MIR, but typeck only knows about ((), std::option::Option<Command>, Command)
Meta
rustc --version --verbose
:Backtrace:
The text was updated successfully, but these errors were encountered: