Function rustc::traits::project::get_paranoid_cache_value_obligation [−][src]
fn get_paranoid_cache_value_obligation<'a, 'gcx, 'tcx>(
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
param_env: ParamEnv<'tcx>,
projection_ty: ProjectionTy<'tcx>,
cause: ObligationCause<'tcx>,
depth: usize
) -> PredicateObligation<'tcx>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Whenever we give back a cache result for a projection like <T as Trait>::Item ==> X
, we always include the obligation to prove
that T: Trait
(we may also include some other obligations). This
may or may not be necessary -- in principle, all the obligations
that must be proven to show that T: Trait
were also returned
when the cache was first populated. But there are some vague concerns,
and so we take the precautionary measure of including T: Trait
in
the result:
Concern #1. The current setup is fragile. Perhaps someone could
have failed to prove the concerns from when the cache was
populated, but also not have used a snapshot, in which case the
cache could remain populated even though T: Trait
has not been
shown. In this case, the "other code" is at fault -- when you
project something, you are supposed to either have a snapshot or
else prove all the resulting obligations -- but it's still easy to
get wrong.
Concern #2. Even within the snapshot, if those original obligations are not yet proven, then we are able to do projections that may yet turn out to be wrong. This may lead to some sort of trouble, though we don't have a concrete example of how that can occur yet. But it seems risky at best.