From 41e60d1562738c0295c4344339c6368e9446e936 Mon Sep 17 00:00:00 2001 From: Wim Looman Date: Mon, 4 Mar 2019 11:23:38 +1300 Subject: [PATCH] Monomorphize generator field types for debuginfo --- src/librustc_codegen_ssa/mir/mod.rs | 1 + src/test/run-pass/generator/issue-58888.rs | 27 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 src/test/run-pass/generator/issue-58888.rs diff --git a/src/librustc_codegen_ssa/mir/mod.rs b/src/librustc_codegen_ssa/mir/mod.rs index ce342320af926..fa8a74b2715e1 100644 --- a/src/librustc_codegen_ssa/mir/mod.rs +++ b/src/librustc_codegen_ssa/mir/mod.rs @@ -627,6 +627,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(); diff --git a/src/test/run-pass/generator/issue-58888.rs b/src/test/run-pass/generator/issue-58888.rs new file mode 100644 index 0000000000000..43b37a9afc2cc --- /dev/null +++ b/src/test/run-pass/generator/issue-58888.rs @@ -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 { + Some(()).into_iter() + } + + fn check_connection(&self) -> impl Generator + '_ { + move || { + let iter = self.get_connection(); + for i in iter { + yield i + } + } + } +} + +fn main() { + Database.check_connection(); +}