Skip to content

Commit 890dd58

Browse files
committed
Prevent leaking Feeds into query results
1 parent 5a0c46a commit 890dd58

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

compiler/rustc_middle/src/ty/context.rs

+8
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,10 @@ pub struct TyCtxtFeed<'tcx, KEY: Copy> {
520520
key: KEY,
521521
}
522522

523+
/// Never return a `Feed` from a query. Only queries that create a `DefId` are
524+
/// allowed to feed queries for that `DefId`.
525+
impl<KEY: Copy, CTX> !HashStable<CTX> for TyCtxtFeed<'_, KEY> {}
526+
523527
/// The same as `TyCtxtFeed`, but does not contain a `TyCtxt`.
524528
/// Use this to pass around when you have a `TyCtxt` elsewhere.
525529
/// Just an optimization to save space and not store hundreds of
@@ -531,6 +535,10 @@ pub struct Feed<'tcx, KEY: Copy> {
531535
key: KEY,
532536
}
533537

538+
/// Never return a `Feed` from a query. Only queries that create a `DefId` are
539+
/// allowed to feed queries for that `DefId`.
540+
impl<KEY: Copy, CTX> !HashStable<CTX> for Feed<'_, KEY> {}
541+
534542
impl<T: fmt::Debug + Copy> fmt::Debug for Feed<'_, T> {
535543
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
536544
self.key.fmt(f)

0 commit comments

Comments
 (0)