From f0ebd66eaa9e9742e872eb8044d93aec8081d3cf Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 21 Apr 2026 21:08:19 +1000 Subject: [PATCH] Remove unused `tcx` params. They are unused because of the previous commit. --- compiler/rustc_metadata/src/rmeta/decoder.rs | 22 +++++++++---------- .../src/rmeta/decoder/cstore_impl.rs | 10 ++++----- .../rustc_resolve/src/build_reduced_graph.rs | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index 847a6428b30e..181dbfa126d7 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -1036,7 +1036,7 @@ pub(super) fn map_encoded_cnum_to_current(self, cnum: CrateNum) -> CrateNum { if cnum == LOCAL_CRATE { self.cnum } else { self.cnum_map[cnum] } } - fn def_kind(self, _tcx: TyCtxt<'_>, item_id: DefIndex) -> DefKind { + fn def_kind(self, item_id: DefIndex) -> DefKind { self.root .tables .def_kind @@ -1119,7 +1119,7 @@ fn get_variant( did, name: self.item_name(did.index), vis: self.get_visibility(tcx, did.index), - safety: self.get_safety(tcx, did.index), + safety: self.get_safety(did.index), value: self.get_default_field(tcx, did.index), }) .collect(), @@ -1131,7 +1131,7 @@ fn get_variant( } fn get_adt_def<'tcx>(self, tcx: TyCtxt<'tcx>, item_id: DefIndex) -> ty::AdtDef<'tcx> { - let kind = self.def_kind(tcx, item_id); + let kind = self.def_kind(item_id); let did = self.local_def_id(item_id); let adt_kind = match kind { @@ -1151,7 +1151,7 @@ fn get_adt_def<'tcx>(self, tcx: TyCtxt<'tcx>, item_id: DefIndex) -> ty::AdtDef<' .expect("variants are not encoded for an enum") .decode((self, tcx)) .filter_map(|index| { - let kind = self.def_kind(tcx, index); + let kind = self.def_kind(index); match kind { DefKind::Ctor(..) => None, _ => Some(self.get_variant(tcx, kind, index, did)), @@ -1182,7 +1182,7 @@ fn get_visibility(self, tcx: TyCtxt<'_>, id: DefIndex) -> Visibility { .map_id(|index| self.local_def_id(index)) } - fn get_safety(self, _tcx: TyCtxt<'_>, id: DefIndex) -> Safety { + fn get_safety(self, id: DefIndex) -> Safety { self.root.tables.safety.get(self.cdata, id) } @@ -1263,7 +1263,7 @@ fn get_diagnostic_items(self, tcx: TyCtxt<'_>) -> DiagnosticItems { fn get_mod_child(self, tcx: TyCtxt<'_>, id: DefIndex) -> ModChild { let ident = self.item_ident(tcx, id); - let res = Res::Def(self.def_kind(tcx, id), self.local_def_id(id)); + let res = Res::Def(self.def_kind(id), self.local_def_id(id)); let vis = self.get_visibility(tcx, id); ModChild { ident, res, vis, reexport_chain: Default::default() } @@ -1316,7 +1316,7 @@ fn get_ambig_module_children( } } - fn is_item_mir_available(self, _tcx: TyCtxt<'_>, id: DefIndex) -> bool { + fn is_item_mir_available(self, id: DefIndex) -> bool { self.root.tables.optimized_mir.get(self.cdata, id).is_some() } @@ -1346,7 +1346,7 @@ fn get_associated_item_or_field_def_ids( } fn get_associated_item(self, tcx: TyCtxt<'_>, id: DefIndex) -> ty::AssocItem { - let kind = match self.def_kind(tcx, id) { + let kind = match self.def_kind(id) { DefKind::AssocConst { is_type_const } => { ty::AssocKind::Const { name: self.item_name(id), is_type_const } } @@ -1373,7 +1373,7 @@ fn get_associated_item(self, tcx: TyCtxt<'_>, id: DefIndex) -> ty::AssocItem { } fn get_ctor(self, tcx: TyCtxt<'_>, node_id: DefIndex) -> Option<(CtorKind, DefId)> { - match self.def_kind(tcx, node_id) { + match self.def_kind(node_id) { DefKind::Struct | DefKind::Variant => { let vdata = self .root @@ -1542,7 +1542,7 @@ fn exported_generic_symbols<'tcx>( } fn get_macro(self, tcx: TyCtxt<'_>, id: DefIndex) -> ast::MacroDef { - match self.def_kind(tcx, id) { + match self.def_kind(id) { DefKind::Macro(_) => { let macro_rules = self.root.tables.is_macro_rules.get(self.cdata, id); let body = self @@ -1855,7 +1855,7 @@ fn filter<'a>( .clone() } - fn get_attr_flags(self, _tcx: TyCtxt<'_>, index: DefIndex) -> AttrFlags { + fn get_attr_flags(self, index: DefIndex) -> AttrFlags { self.root.tables.attr_flags.get(self.cdata, index) } diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index 125c92efc8a8..c82bed7761aa 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -253,7 +253,7 @@ fn into_args(self) -> (DefId, SimplifiedType) { lookup_default_body_stability => { table } lookup_deprecation_entry => { table } params_in_repr => { table } - def_kind => { cdata.def_kind(tcx, def_id.index) } + def_kind => { cdata.def_kind(def_id.index) } impl_parent => { table } defaultness => { table_direct } constness => { table_direct } @@ -323,7 +323,7 @@ fn into_args(self) -> (DefId, SimplifiedType) { associated_item => { cdata.get_associated_item(tcx, def_id.index) } inherent_impls => { cdata.get_inherent_implementations_for_type(tcx, def_id.index) } attrs_for_def => { tcx.arena.alloc_from_iter(cdata.get_item_attrs(tcx, def_id.index)) } - is_mir_available => { cdata.is_item_mir_available(tcx, def_id.index) } + is_mir_available => { cdata.is_item_mir_available(def_id.index) } cross_crate_inlinable => { table_direct } dylib_dependency_formats => { cdata.get_dylib_dependency_formats(tcx) } @@ -411,7 +411,7 @@ fn into_args(self) -> (DefId, SimplifiedType) { crate_extern_paths => { cdata.source().paths().cloned().collect() } expn_that_defined => { cdata.get_expn_that_defined(tcx, def_id.index) } default_field => { cdata.get_default_field(tcx, def_id.index) } - is_doc_hidden => { cdata.get_attr_flags(tcx,def_id.index).contains(AttrFlags::IS_DOC_HIDDEN) } + is_doc_hidden => { cdata.get_attr_flags(def_id.index).contains(AttrFlags::IS_DOC_HIDDEN) } doc_link_resolutions => { tcx.arena.alloc(cdata.get_doc_link_resolutions(tcx, def_id.index)) } doc_link_traits_in_scope => { tcx.arena.alloc_from_iter(cdata.get_doc_link_traits_in_scope(tcx, def_id.index)) @@ -613,8 +613,8 @@ pub fn def_span_untracked(&self, tcx: TyCtxt<'_>, def_id: DefId) -> Span { self.get_crate_data(def_id.krate).get_span(tcx, def_id.index) } - pub fn def_kind_untracked(&self, tcx: TyCtxt<'_>, def: DefId) -> DefKind { - self.get_crate_data(def.krate).def_kind(tcx, def.index) + pub fn def_kind_untracked(&self, def: DefId) -> DefKind { + self.get_crate_data(def.krate).def_kind(def.index) } pub fn expn_that_defined_untracked(&self, tcx: TyCtxt<'_>, def_id: DefId) -> ExpnId { diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index a2231d8d3b0f..26e80b6fc5de 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -157,7 +157,7 @@ pub(crate) fn get_module(&self, def_id: DefId) -> Option> { } // Query `def_kind` is not used because query system overhead is too expensive here. - let def_kind = self.cstore().def_kind_untracked(self.tcx, def_id); + let def_kind = self.cstore().def_kind_untracked(def_id); if def_kind.is_module_like() { let parent = self.tcx.opt_parent(def_id).map(|parent_id| { self.get_nearest_non_block_module(parent_id).expect_extern()