Skip to content

Commit

Permalink
Move 'tcx lifetime off of impl and onto methods
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Aug 28, 2024
1 parent 748c548 commit 19296ca
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions compiler/rustc_metadata/src/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ impl CrateRoot {
}
}

impl<'a, 'tcx> CrateMetadataRef<'a> {
impl<'a> CrateMetadataRef<'a> {
fn missing(self, descr: &str, id: DefIndex) -> ! {
bug!("missing `{descr}` for {:?}", self.local_def_id(id))
}
Expand Down Expand Up @@ -1036,7 +1036,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
.decode((self, sess))
}

fn load_proc_macro(self, id: DefIndex, tcx: TyCtxt<'tcx>) -> SyntaxExtension {
fn load_proc_macro<'tcx>(self, id: DefIndex, tcx: TyCtxt<'tcx>) -> SyntaxExtension {
let (name, kind, helper_attrs) = match *self.raw_proc_macro(id) {
ProcMacro::CustomDerive { trait_name, attributes, client } => {
let helper_attrs =
Expand Down Expand Up @@ -1070,7 +1070,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
)
}

fn get_explicit_item_bounds(
fn get_explicit_item_bounds<'tcx>(
self,
index: DefIndex,
tcx: TyCtxt<'tcx>,
Expand All @@ -1084,7 +1084,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
ty::EarlyBinder::bind(&*output)
}

fn get_explicit_item_super_predicates(
fn get_explicit_item_super_predicates<'tcx>(
self,
index: DefIndex,
tcx: TyCtxt<'tcx>,
Expand Down Expand Up @@ -1141,7 +1141,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
)
}

fn get_adt_def(self, item_id: DefIndex, tcx: TyCtxt<'tcx>) -> ty::AdtDef<'tcx> {
fn get_adt_def<'tcx>(self, item_id: DefIndex, tcx: TyCtxt<'tcx>) -> ty::AdtDef<'tcx> {
let kind = self.def_kind(item_id);
let did = self.local_def_id(item_id);

Expand Down Expand Up @@ -1225,12 +1225,12 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
/// Iterates over the stability implications in the given crate (when a `#[unstable]` attribute
/// has an `implied_by` meta item, then the mapping from the implied feature to the actual
/// feature is a stability implication).
fn get_stability_implications(self, tcx: TyCtxt<'tcx>) -> &'tcx [(Symbol, Symbol)] {
fn get_stability_implications<'tcx>(self, tcx: TyCtxt<'tcx>) -> &'tcx [(Symbol, Symbol)] {
tcx.arena.alloc_from_iter(self.root.stability_implications.decode(self))
}

/// Iterates over the lang items in the given crate.
fn get_lang_items(self, tcx: TyCtxt<'tcx>) -> &'tcx [(DefId, LangItem)] {
fn get_lang_items<'tcx>(self, tcx: TyCtxt<'tcx>) -> &'tcx [(DefId, LangItem)] {
tcx.arena.alloc_from_iter(
self.root
.lang_items
Expand All @@ -1239,7 +1239,11 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
)
}

fn get_stripped_cfg_items(self, cnum: CrateNum, tcx: TyCtxt<'tcx>) -> &'tcx [StrippedCfgItem] {
fn get_stripped_cfg_items<'tcx>(
self,
cnum: CrateNum,
tcx: TyCtxt<'tcx>,
) -> &'tcx [StrippedCfgItem] {
let item_names = self
.root
.stripped_cfg_items
Expand Down Expand Up @@ -1412,7 +1416,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
.decode((self, sess))
}

fn get_inherent_implementations_for_type(
fn get_inherent_implementations_for_type<'tcx>(
self,
tcx: TyCtxt<'tcx>,
id: DefIndex,
Expand All @@ -1439,15 +1443,15 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
})
}

fn get_incoherent_impls(self, tcx: TyCtxt<'tcx>, simp: SimplifiedType) -> &'tcx [DefId] {
fn get_incoherent_impls<'tcx>(self, tcx: TyCtxt<'tcx>, simp: SimplifiedType) -> &'tcx [DefId] {
if let Some(impls) = self.cdata.incoherent_impls.get(&simp) {
tcx.arena.alloc_from_iter(impls.decode(self).map(|idx| self.local_def_id(idx)))
} else {
&[]
}
}

fn get_implementations_of_trait(
fn get_implementations_of_trait<'tcx>(
self,
tcx: TyCtxt<'tcx>,
trait_def_id: DefId,
Expand Down Expand Up @@ -1491,7 +1495,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
self.root.foreign_modules.decode((self, sess))
}

fn get_dylib_dependency_formats(
fn get_dylib_dependency_formats<'tcx>(
self,
tcx: TyCtxt<'tcx>,
) -> &'tcx [(CrateNum, LinkagePreference)] {
Expand All @@ -1503,11 +1507,11 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
)
}

fn get_missing_lang_items(self, tcx: TyCtxt<'tcx>) -> &'tcx [LangItem] {
fn get_missing_lang_items<'tcx>(self, tcx: TyCtxt<'tcx>) -> &'tcx [LangItem] {
tcx.arena.alloc_from_iter(self.root.lang_items_missing.decode(self))
}

fn exported_symbols(
fn exported_symbols<'tcx>(
self,
tcx: TyCtxt<'tcx>,
) -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportInfo)] {
Expand Down

0 comments on commit 19296ca

Please sign in to comment.