Skip to content

Commit 89247fb

Browse files
committed
update comment
1 parent 02a49f8 commit 89247fb

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/librustc/traits/project.rs

+18-7
Original file line numberDiff line numberDiff line change
@@ -623,13 +623,24 @@ fn prune_cache_value_obligations<'a, 'gcx, 'tcx>(infcx: &'a InferCtxt<'a, 'gcx,
623623
/// that `T: Trait` (we may also include some other obligations). This
624624
/// may or may not be necessary -- in principle, all the obligations
625625
/// that must be proven to show that `T: Trait` were also returned
626-
/// when the cache was first populated. But there is a vague concern
627-
/// that perhaps someone would not have proven those, but also not
628-
/// have used a snapshot, in which case the cache could remain
629-
/// populated even though `T: Trait` has not been shown. Returning
630-
/// this "paranoid" obligation ensures that, no matter what has come
631-
/// before, if you prove the subobligations, we at least know that `T:
632-
/// Trait` is implemented.
626+
/// when the cache was first populated. But there are some vague concerns,
627+
/// and so we take the precatuionary measure of including `T: Trait` in
628+
/// the result:
629+
///
630+
/// Concern #1. The current setup is fragile. Perhaps someone could
631+
/// have failed to prove the concerns from when the cache was
632+
/// populated, but also not have used a snapshot, in which case the
633+
/// cache could remain populated even though `T: Trait` has not been
634+
/// shown. In this case, the "other code" is at fault -- when you
635+
/// project something, you are supposed to either have a snapshot or
636+
/// else prove all the resulting obligations -- but it's still easy to
637+
/// get wrong.
638+
///
639+
/// Concern #2. Even within the snapshot, if those original
640+
/// obligations are not yet proven, then we are able to do projections
641+
/// that may yet turn out to be wrong. This *may* lead to some sort
642+
/// of trouble, though we don't have a concrete example of how that
643+
/// can occur yet. But it seems risky at best.
633644
fn push_paranoid_cache_value_obligation<'a, 'gcx, 'tcx>(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
634645
param_env: ty::ParamEnv<'tcx>,
635646
projection_ty: ty::ProjectionTy<'tcx>,

0 commit comments

Comments
 (0)