Skip to content

Commit 53eacfa

Browse files
committed
Prevent leaking Feeds into query results
1 parent e1166b5 commit 53eacfa

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
@@ -523,6 +523,10 @@ pub struct TyCtxtFeed<'tcx, KEY: Copy> {
523523
key: KEY,
524524
}
525525

526+
/// Never return a `Feed` from a query. Only queries that create a `DefId` are
527+
/// allowed to feed queries for that `DefId`.
528+
impl<KEY: Copy, CTX> !HashStable<CTX> for TyCtxtFeed<'_, KEY> {}
529+
526530
/// The same as `TyCtxtFeed`, but does not contain a `TyCtxt`.
527531
/// Use this to pass around when you have a `TyCtxt` elsewhere.
528532
/// Just an optimization to save space and not store hundreds of
@@ -534,6 +538,10 @@ pub struct Feed<'tcx, KEY: Copy> {
534538
key: KEY,
535539
}
536540

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

0 commit comments

Comments
 (0)