reachable computation: clarify comments around consts
This commit is contained in:
parent
aec67e238d
commit
be4cd53536
@ -207,18 +207,21 @@ impl<'tcx> ReachableContext<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hir::ItemKind::Const(_, _, init) => {
|
hir::ItemKind::Const(_, _, init) => {
|
||||||
// Only things actually ending up in the final constant need to be reachable.
|
// Only things actually ending up in the final constant value are reachable
|
||||||
// Everything else is either already available as `mir_for_ctfe`, or can't be used
|
// for codegen. Everything else is only needed during const-eval, so even if
|
||||||
// by codegen anyway.
|
// const-eval happens in a downstream crate, all they need is
|
||||||
|
// `mir_for_ctfe`.
|
||||||
match self.tcx.const_eval_poly_to_alloc(item.owner_id.def_id.into()) {
|
match self.tcx.const_eval_poly_to_alloc(item.owner_id.def_id.into()) {
|
||||||
Ok(alloc) => {
|
Ok(alloc) => {
|
||||||
let alloc = self.tcx.global_alloc(alloc.alloc_id).unwrap_memory();
|
let alloc = self.tcx.global_alloc(alloc.alloc_id).unwrap_memory();
|
||||||
self.propagate_from_alloc(alloc);
|
self.propagate_from_alloc(alloc);
|
||||||
}
|
}
|
||||||
// Reachable generic constants will be inlined into other crates
|
// We can't figure out which value the constant will evaluate to. In
|
||||||
// unconditionally, so we need to make sure that their
|
// lieu of that, we have to consider everything mentioned in the const
|
||||||
// contents are also reachable.
|
// initializer reachable, since it *may* end up in the final value.
|
||||||
Err(ErrorHandled::TooGeneric(_)) => self.visit_nested_body(init),
|
Err(ErrorHandled::TooGeneric(_)) => self.visit_nested_body(init),
|
||||||
|
// If there was an error evaluating the const, nothing can be reachable
|
||||||
|
// via it, and anyway compilation will fail.
|
||||||
Err(ErrorHandled::Reported(..)) => {}
|
Err(ErrorHandled::Reported(..)) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user