Encode only MIR that can be used by other crates
Only reachable items might participate in the code generation in the downstream crates. Omit redundant optimized MIR of unreachable items from a crate metadata. Additionally, include reachable closures in reachable set, so that unreachable closures can be omitted on the same basis.
This commit is contained in:
parent
01ce2d0ea1
commit
d99333e444
3 changed files with 36 additions and 13 deletions
|
@ -90,6 +90,10 @@ impl<'tcx> Visitor<'tcx> for ReachableContext<'tcx> {
|
|||
.typeck_results()
|
||||
.type_dependent_def(expr.hir_id)
|
||||
.map(|(kind, def_id)| Res::Def(kind, def_id)),
|
||||
hir::ExprKind::Closure(&hir::Closure { def_id, .. }) => {
|
||||
self.reachable_symbols.insert(def_id);
|
||||
None
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue