Prevent leaking Feeds into query results

This commit is contained in:
Oli Scherer 2024-02-19 12:02:10 +00:00
parent 5a0c46a22c
commit 890dd58650

View File

@ -520,6 +520,10 @@ pub struct TyCtxtFeed<'tcx, KEY: Copy> {
key: KEY,
}
/// Never return a `Feed` from a query. Only queries that create a `DefId` are
/// allowed to feed queries for that `DefId`.
impl<KEY: Copy, CTX> !HashStable<CTX> for TyCtxtFeed<'_, KEY> {}
/// The same as `TyCtxtFeed`, but does not contain a `TyCtxt`.
/// Use this to pass around when you have a `TyCtxt` elsewhere.
/// Just an optimization to save space and not store hundreds of
@ -531,6 +535,10 @@ pub struct Feed<'tcx, KEY: Copy> {
key: KEY,
}
/// Never return a `Feed` from a query. Only queries that create a `DefId` are
/// allowed to feed queries for that `DefId`.
impl<KEY: Copy, CTX> !HashStable<CTX> for Feed<'_, KEY> {}
impl<T: fmt::Debug + Copy> fmt::Debug for Feed<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.key.fmt(f)