Skip to content

Commit

Permalink
Rollup merge of rust-lang#58906 - Nemo157:generator-state-debug-info,…
Browse files Browse the repository at this point in the history
… r=Zoxc

Monomorphize generator field types for debuginfo

Fixes rust-lang#58888

r? @Zoxc
  • Loading branch information
pietroalbini authored Mar 8, 2019
2 parents 4bff63f + 41e60d1 commit 4083c69
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/librustc_codegen_ssa/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ fn arg_local_refs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
.zip(state_tys)
.enumerate()
.filter_map(move |(i, (decl, ty))| {
let ty = fx.monomorphize(&ty);
decl.name.map(|name| (i + upvar_count + 1, name, false, ty))
})
}).into_iter().flatten();
Expand Down
27 changes: 27 additions & 0 deletions src/test/run-pass/generator/issue-58888.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// run-pass
// compile-flags: -g

#![feature(generators, generator_trait)]

use std::ops::Generator;

struct Database;

impl Database {
fn get_connection(&self) -> impl Iterator<Item = ()> {
Some(()).into_iter()
}

fn check_connection(&self) -> impl Generator<Yield = (), Return = ()> + '_ {
move || {
let iter = self.get_connection();
for i in iter {
yield i
}
}
}
}

fn main() {
Database.check_connection();
}

0 comments on commit 4083c69

Please sign in to comment.