Skip to content

Commit c1241bf

Browse files
committed
add debuginfo in generator_interior
1 parent 3ed3b8b commit c1241bf

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/librustc/hir/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,6 +1857,22 @@ impl fmt::Display for YieldSource {
18571857
}
18581858
}
18591859

1860+
impl core::convert::From<GeneratorKind> for YieldSource {
1861+
fn from(gen_kind: GeneratorKind) -> Self {
1862+
match gen_kind {
1863+
// Guess based on the kind of the current generator.
1864+
GeneratorKind::Gen => Self::Yield,
1865+
GeneratorKind::Async(_) => Self::Await,
1866+
}
1867+
}
1868+
}
1869+
1870+
#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]
1871+
pub enum CaptureClause {
1872+
CaptureByValue,
1873+
CaptureByRef,
1874+
}
1875+
18601876
// N.B., if you change this, you'll probably want to change the corresponding
18611877
// type structure in middle/ty.rs as well.
18621878
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]

src/librustc_typeck/check/generator_interior.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> {
3232
debug!("generator_interior: attempting to record type {:?} {:?} {:?} {:?}",
3333
ty, scope, expr, source_span);
3434

35-
3635
let live_across_yield = scope.map(|s| {
3736
self.region_scope_tree.yield_in_scope(s).and_then(|yield_data| {
3837
// If we are recording an expression that is the last yield
@@ -54,15 +53,11 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> {
5453
}).unwrap_or_else(|| Some(YieldData {
5554
span: DUMMY_SP,
5655
expr_and_pat_count: 0,
57-
source: match self.kind { // Guess based on the kind of the current generator.
58-
hir::GeneratorKind::Gen => hir::YieldSource::Yield,
59-
hir::GeneratorKind::Async(_) => hir::YieldSource::Await,
60-
},
56+
source: self.kind.into(),
6157
}));
6258

6359
if let Some(yield_data) = live_across_yield {
6460
let ty = self.fcx.resolve_vars_if_possible(&ty);
65-
6661
debug!("type in expr = {:?}, scope = {:?}, type = {:?}, count = {}, yield_span = {:?}",
6762
expr, scope, ty, self.expr_count, yield_data.span);
6863

@@ -94,6 +89,11 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> {
9489
} else {
9590
debug!("no type in expr = {:?}, count = {:?}, span = {:?}",
9691
expr, self.expr_count, expr.map(|e| e.span));
92+
let ty = self.fcx.resolve_vars_if_possible(&ty);
93+
if let Some((unresolved_type, unresolved_type_span)) = self.fcx.unresolved_type_vars(&ty) {
94+
debug!("remained unresolved_type = {:?}, unresolved_type_span: {:?}",
95+
unresolved_type, unresolved_type_span);
96+
}
9797
}
9898
}
9999
}

0 commit comments

Comments
 (0)