Skip to content

Commit c1dddce

Browse files
committedSep 7, 2017
update comment
1 parent ffd21b1 commit c1dddce

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

0 commit comments

Comments
 (0)
Please sign in to comment.