Skip to content

Commit

Permalink
add debuginfo in generator_interior
Browse files Browse the repository at this point in the history
  • Loading branch information
csmoe committed Dec 18, 2019
1 parent 3ed3b8b commit c1241bf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
16 changes: 16 additions & 0 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1857,6 +1857,22 @@ impl fmt::Display for YieldSource {
}
}

impl core::convert::From<GeneratorKind> for YieldSource {
fn from(gen_kind: GeneratorKind) -> Self {
match gen_kind {
// Guess based on the kind of the current generator.
GeneratorKind::Gen => Self::Yield,
GeneratorKind::Async(_) => Self::Await,
}
}
}

#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]
pub enum CaptureClause {
CaptureByValue,
CaptureByRef,
}

// N.B., if you change this, you'll probably want to change the corresponding
// type structure in middle/ty.rs as well.
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
Expand Down
12 changes: 6 additions & 6 deletions src/librustc_typeck/check/generator_interior.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> {
debug!("generator_interior: attempting to record type {:?} {:?} {:?} {:?}",
ty, scope, expr, source_span);


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

if let Some(yield_data) = live_across_yield {
let ty = self.fcx.resolve_vars_if_possible(&ty);

debug!("type in expr = {:?}, scope = {:?}, type = {:?}, count = {}, yield_span = {:?}",
expr, scope, ty, self.expr_count, yield_data.span);

Expand Down Expand Up @@ -94,6 +89,11 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> {
} else {
debug!("no type in expr = {:?}, count = {:?}, span = {:?}",
expr, self.expr_count, expr.map(|e| e.span));
let ty = self.fcx.resolve_vars_if_possible(&ty);
if let Some((unresolved_type, unresolved_type_span)) = self.fcx.unresolved_type_vars(&ty) {
debug!("remained unresolved_type = {:?}, unresolved_type_span: {:?}",
unresolved_type, unresolved_type_span);
}
}
}
}
Expand Down

0 comments on commit c1241bf

Please sign in to comment.