diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index b1927e190f03..03b7adfd3eab 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -10,7 +10,7 @@ use std::env::VarError; use std::ffi::OsStr; use std::hash::{Hash, Hasher}; -use std::marker::{PhantomData, PointeeSized}; +use std::marker::PointeeSized; use std::ops::{Bound, Deref}; use std::sync::{Arc, OnceLock}; use std::{fmt, iter, mem}; @@ -539,36 +539,14 @@ pub struct FreeRegionInfo { /// This struct should only be created by `create_def`. #[derive(Copy, Clone)] -pub struct TyCtxtFeed<'tcx, KEY: Copy> { +pub struct TyCtxtFeed<'tcx, K: Copy> { pub tcx: TyCtxt<'tcx>, // Do not allow direct access, as downstream code must not mutate this field. - key: KEY, + key: K, } -/// Never return a `Feed` from a query. Only queries that create a `DefId` are -/// allowed to feed queries for that `DefId`. -impl !HashStable 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 -/// `TyCtxtFeed` in the resolver. -#[derive(Copy, Clone)] -pub struct Feed<'tcx, KEY: Copy> { - _tcx: PhantomData>, - // Do not allow direct access, as downstream code must not mutate this field. - key: KEY, -} - -/// Never return a `Feed` from a query. Only queries that create a `DefId` are -/// allowed to feed queries for that `DefId`. -impl !HashStable for Feed<'_, KEY> {} - -impl fmt::Debug for Feed<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.key.fmt(f) - } -} +/// Only queries that create a `DefId` are allowed to feed queries for that `DefId`. +impl !HashStable for TyCtxtFeed<'_, K> {} /// Some workarounds to use cases that cannot use `create_def`. /// Do not add new ways to create `TyCtxtFeed` without consulting @@ -622,28 +600,11 @@ pub fn feed_visibility_for_trait_impl_item(self, key: LocalDefId, vis: ty::Visib } } -impl<'tcx, KEY: Copy> TyCtxtFeed<'tcx, KEY> { +impl<'tcx, K: Copy> TyCtxtFeed<'tcx, K> { #[inline(always)] - pub fn key(&self) -> KEY { + pub fn key(&self) -> K { self.key } - - #[inline(always)] - pub fn downgrade(self) -> Feed<'tcx, KEY> { - Feed { _tcx: PhantomData, key: self.key } - } -} - -impl<'tcx, KEY: Copy> Feed<'tcx, KEY> { - #[inline(always)] - pub fn key(&self) -> KEY { - self.key - } - - #[inline(always)] - pub fn upgrade(self, tcx: TyCtxt<'tcx>) -> TyCtxtFeed<'tcx, KEY> { - TyCtxtFeed { tcx, key: self.key } - } } impl<'tcx> TyCtxtFeed<'tcx, LocalDefId> { diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 914fb4314715..74cad5acfc6f 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -83,7 +83,7 @@ const_lit_matches_ty, }; pub use self::context::{ - CtxtInterners, CurrentGcx, Feed, FreeRegionInfo, GlobalCtxt, Lift, TyCtxt, TyCtxtFeed, tls, + CtxtInterners, CurrentGcx, FreeRegionInfo, GlobalCtxt, Lift, TyCtxt, TyCtxtFeed, tls, }; pub use self::fold::*; pub use self::instance::{Instance, InstanceKind, ReifyReason};