rustc/middle: improve allocations
This commit is contained in:
parent
a256a66305
commit
96736f215f
src/librustc/middle
@ -474,13 +474,15 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
// construction site.
|
||||
let mut call_caps = Vec::new();
|
||||
ir.tcx.with_freevars(expr.id, |freevars| {
|
||||
for fv in freevars {
|
||||
call_caps.extend(freevars.iter().filter_map(|fv| {
|
||||
if let Def::Local(rv) = fv.def {
|
||||
let fv_ln = ir.add_live_node(FreeVarNode(fv.span));
|
||||
let var_hid = ir.tcx.hir.node_to_hir_id(rv);
|
||||
call_caps.push(CaptureInfo { ln: fv_ln, var_hid });
|
||||
Some(CaptureInfo { ln: fv_ln, var_hid })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}));
|
||||
});
|
||||
ir.set_captures(expr.id, call_caps);
|
||||
|
||||
|
@ -371,7 +371,9 @@ impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a,
|
||||
return
|
||||
}
|
||||
|
||||
for default_method in self.tcx.provided_trait_methods(trait_def_id) {
|
||||
let provided_trait_methods = self.tcx.provided_trait_methods(trait_def_id);
|
||||
self.worklist.reserve(provided_trait_methods.len());
|
||||
for default_method in provided_trait_methods {
|
||||
let node_id = self.tcx
|
||||
.hir
|
||||
.as_local_node_id(default_method.def_id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user