mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-09 05:23:07 +00:00
Make TyCtxtFeed::def_id private.
This commit is contained in:
parent
a0c38807cf
commit
6477fd8fc3
@ -497,7 +497,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
self.tcx.hir().def_key(self.local_def_id(node_id)),
|
||||
);
|
||||
|
||||
let def_id = self.tcx.create_def(parent, data).def_id;
|
||||
let def_id = self.tcx.create_def(parent, data).def_id();
|
||||
|
||||
debug!("create_def: def_id_to_node_id[{:?}] <-> {:?}", def_id, node_id);
|
||||
self.resolver.node_id_to_def_id.insert(node_id, def_id);
|
||||
|
@ -1010,12 +1010,19 @@ pub struct FreeRegionInfo {
|
||||
pub is_impl_item: bool,
|
||||
}
|
||||
|
||||
/// This struct should only be created by `create_def`.
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct TyCtxtFeed<'tcx> {
|
||||
pub tcx: TyCtxt<'tcx>,
|
||||
pub def_id: LocalDefId,
|
||||
/// This struct should only be created by `create_def`.
|
||||
_priv: (),
|
||||
// Do not allow direct access, as downstream code must not mutate this field.
|
||||
def_id: LocalDefId,
|
||||
}
|
||||
|
||||
impl<'tcx> TyCtxtFeed<'tcx> {
|
||||
#[inline(always)]
|
||||
pub fn def_id(&self) -> LocalDefId {
|
||||
self.def_id
|
||||
}
|
||||
}
|
||||
|
||||
/// The central data structure of the compiler. It stores references
|
||||
@ -1507,7 +1514,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
// - this write will have happened before these queries are called.
|
||||
let def_id = self.definitions.write().create_def(parent, data);
|
||||
|
||||
TyCtxtFeed { tcx: self, def_id, _priv: () }
|
||||
TyCtxtFeed { tcx: self, def_id }
|
||||
}
|
||||
|
||||
pub fn iter_local_def_id(self) -> impl Iterator<Item = LocalDefId> + 'tcx {
|
||||
|
@ -334,7 +334,7 @@ macro_rules! define_feedable {
|
||||
$($(#[$attr])*
|
||||
#[inline(always)]
|
||||
pub fn $name(self, value: $V) -> query_stored::$name<'tcx> {
|
||||
let key = self.def_id.into_query_param();
|
||||
let key = self.def_id().into_query_param();
|
||||
opt_remap_env_constness!([$($modifiers)*][key]);
|
||||
|
||||
let tcx = self.tcx;
|
||||
|
Loading…
Reference in New Issue
Block a user