Skip to content

Commit

Permalink
Continue lowering for unsupported async generator instead of returnin…
Browse files Browse the repository at this point in the history
…g an error.

This way the hir is "valid" and we can remove one more call to
`opt_node_id_to_hir_id` but an error is still emitted.

This is another partial fix for rust-lang#71104
  • Loading branch information
marmeladema committed May 16, 2020
1 parent 31add7e commit 4af04cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/librustc_ast_lowering/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
"`async` generators are not yet supported"
)
.emit();
return hir::ExprKind::Err;
}
None => self.generator_kind = Some(hir::GeneratorKind::Gen),
}
Expand Down
17 changes: 7 additions & 10 deletions src/librustc_middle/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1114,16 +1114,13 @@ impl<'tcx> TyCtxt<'tcx> {

let mut trait_map: FxHashMap<_, FxHashMap<_, _>> = FxHashMap::default();
for (k, v) in resolutions.trait_map {
// FIXME(#71104) Should really be using just `node_id_to_hir_id` but
// some `NodeId` do not seem to have a corresponding HirId.
if let Some(hir_id) = definitions.opt_node_id_to_hir_id(k) {
let map = trait_map.entry(hir_id.owner).or_default();
let v = v
.into_iter()
.map(|tc| tc.map_import_ids(|id| definitions.node_id_to_hir_id(id)))
.collect();
map.insert(hir_id.local_id, StableVec::new(v));
}
let hir_id = definitions.node_id_to_hir_id(k);
let map = trait_map.entry(hir_id.owner).or_default();
let v = v
.into_iter()
.map(|tc| tc.map_import_ids(|id| definitions.node_id_to_hir_id(id)))
.collect();
map.insert(hir_id.local_id, StableVec::new(v));
}

GlobalCtxt {
Expand Down

0 comments on commit 4af04cb

Please sign in to comment.