Skip to content

Commit c6a7c6f

Browse files
committed
improve comments on dropck_outlives
1 parent 1be4fff commit c6a7c6f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/librustc/traits/query/type_op/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ pub trait QueryTypeOp<'gcx: 'tcx, 'tcx>: fmt::Debug + Sized {
4949

5050
fn param_env(key: &Self::QueryKey) -> ParamEnv<'tcx>;
5151

52+
/// Performs the actual query with the canonicalized key -- the
53+
/// real work happens here. This method is not given an `infcx`
54+
/// because it shouldn't need one -- and if it had access to one,
55+
/// it might do things like invoke `sub_regions`, which would be
56+
/// bad, because it would create subregion relationships that are
57+
/// not captured in the return value.
5258
fn perform_query(
5359
tcx: TyCtxt<'_, 'gcx, 'tcx>,
5460
canonicalized: Canonicalized<'gcx, Self::QueryKey>,

src/librustc/traits/query/type_op/outlives.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ where
5252
tcx: TyCtxt<'_, 'gcx, 'tcx>,
5353
canonicalized: Canonicalized<'gcx, Self::QueryKey>,
5454
) -> Fallible<CanonicalizedQueryResult<'gcx, Self::QueryResult>> {
55+
// Subtle: note that we are not invoking
56+
// `infcx.at(...).dropck_outlives(...)` here, but rather the
57+
// underlying `dropck_outlives` query. This same underlying
58+
// query is also used by the
59+
// `infcx.at(...).dropck_outlives(...)` fn. Avoiding the
60+
// wrapper means we don't need an infcx in this code, which is
61+
// good because the interface doesn't give us one (so that we
62+
// know we are not registering any subregion relations or
63+
// other things).
5564
tcx.dropck_outlives(canonicalized)
5665
}
5766

0 commit comments

Comments
 (0)