Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f84d35f

Browse files
authoredJan 13, 2022
Rollup merge of #92277 - petrochenkov:cmrval2, r=jackh726
rustc_metadata: Stop passing `CrateMetadataRef` by reference (step 1) It's already a (fat) reference. Double referencing it creates lifetime issues for its methods that want to return iterators. --- Extracted from #92245 for a perf run. The PR changes a lot of symbol names due to function signature changes, so it's hard to do differential profiling, let's spend some machine time instead.
2 parents 5e04f51 + c4471b0 commit f84d35f

File tree

1 file changed

+98
-98
lines changed

1 file changed

+98
-98
lines changed
 

‎compiler/rustc_metadata/src/rmeta/decoder.rs

Lines changed: 98 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -218,40 +218,40 @@ impl<'a, 'tcx> Metadata<'a, 'tcx> for (&'a MetadataBlob, &'tcx Session) {
218218
}
219219
}
220220

221-
impl<'a, 'tcx> Metadata<'a, 'tcx> for &'a CrateMetadataRef<'a> {
221+
impl<'a, 'tcx> Metadata<'a, 'tcx> for CrateMetadataRef<'a> {
222222
#[inline]
223223
fn blob(self) -> &'a MetadataBlob {
224-
&self.blob
224+
&self.cdata.blob
225225
}
226226
#[inline]
227227
fn cdata(self) -> Option<CrateMetadataRef<'a>> {
228-
Some(*self)
228+
Some(self)
229229
}
230230
}
231231

232-
impl<'a, 'tcx> Metadata<'a, 'tcx> for (&'a CrateMetadataRef<'a>, &'tcx Session) {
232+
impl<'a, 'tcx> Metadata<'a, 'tcx> for (CrateMetadataRef<'a>, &'tcx Session) {
233233
#[inline]
234234
fn blob(self) -> &'a MetadataBlob {
235-
&self.0.blob
235+
&self.0.cdata.blob
236236
}
237237
#[inline]
238238
fn cdata(self) -> Option<CrateMetadataRef<'a>> {
239-
Some(*self.0)
239+
Some(self.0)
240240
}
241241
#[inline]
242242
fn sess(self) -> Option<&'tcx Session> {
243-
Some(&self.1)
243+
Some(self.1)
244244
}
245245
}
246246

247-
impl<'a, 'tcx> Metadata<'a, 'tcx> for (&'a CrateMetadataRef<'a>, TyCtxt<'tcx>) {
247+
impl<'a, 'tcx> Metadata<'a, 'tcx> for (CrateMetadataRef<'a>, TyCtxt<'tcx>) {
248248
#[inline]
249249
fn blob(self) -> &'a MetadataBlob {
250-
&self.0.blob
250+
&self.0.cdata.blob
251251
}
252252
#[inline]
253253
fn cdata(self) -> Option<CrateMetadataRef<'a>> {
254-
Some(*self.0)
254+
Some(self.0)
255255
}
256256
#[inline]
257257
fn tcx(self) -> Option<TyCtxt<'tcx>> {
@@ -414,9 +414,9 @@ impl<'a, 'tcx> Decodable<DecodeContext<'a, 'tcx>> for SyntaxContext {
414414
Ok(cdata
415415
.root
416416
.syntax_contexts
417-
.get(&cdata, id)
417+
.get(cdata, id)
418418
.unwrap_or_else(|| panic!("Missing SyntaxContext {:?} for crate {:?}", id, cname))
419-
.decode((&cdata, sess)))
419+
.decode((cdata, sess)))
420420
})
421421
}
422422
}
@@ -442,15 +442,15 @@ impl<'a, 'tcx> Decodable<DecodeContext<'a, 'tcx>> for ExpnId {
442442
let expn_data = crate_data
443443
.root
444444
.expn_data
445-
.get(&crate_data, index)
445+
.get(crate_data, index)
446446
.unwrap()
447-
.decode((&crate_data, sess));
447+
.decode((crate_data, sess));
448448
let expn_hash = crate_data
449449
.root
450450
.expn_hashes
451-
.get(&crate_data, index)
451+
.get(crate_data, index)
452452
.unwrap()
453-
.decode((&crate_data, sess));
453+
.decode((crate_data, sess));
454454
(expn_data, expn_hash)
455455
});
456456
Ok(expn_id)
@@ -706,7 +706,7 @@ impl CrateRoot<'_> {
706706
}
707707

708708
impl<'a, 'tcx> CrateMetadataRef<'a> {
709-
fn raw_proc_macro(&self, id: DefIndex) -> &ProcMacro {
709+
fn raw_proc_macro(self, id: DefIndex) -> &'a ProcMacro {
710710
// DefIndex's in root.proc_macro_data have a one-to-one correspondence
711711
// with items in 'raw_proc_macros'.
712712
let pos = self
@@ -721,7 +721,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
721721
&self.raw_proc_macros.unwrap()[pos]
722722
}
723723

724-
fn opt_item_ident(&self, item_index: DefIndex, sess: &Session) -> Option<Ident> {
724+
fn opt_item_ident(self, item_index: DefIndex, sess: &Session) -> Option<Ident> {
725725
let name = self.def_key(item_index).disambiguated_data.data.get_opt_name()?;
726726
let span = match self.root.tables.ident_span.get(self, item_index) {
727727
Some(lazy_span) => lazy_span.decode((self, sess)),
@@ -737,15 +737,15 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
737737
Some(Ident::new(name, span))
738738
}
739739

740-
fn item_ident(&self, item_index: DefIndex, sess: &Session) -> Ident {
740+
fn item_ident(self, item_index: DefIndex, sess: &Session) -> Ident {
741741
self.opt_item_ident(item_index, sess).expect("no encoded ident for item")
742742
}
743743

744-
fn maybe_kind(&self, item_id: DefIndex) -> Option<EntryKind> {
744+
fn maybe_kind(self, item_id: DefIndex) -> Option<EntryKind> {
745745
self.root.tables.kind.get(self, item_id).map(|k| k.decode(self))
746746
}
747747

748-
fn kind(&self, item_id: DefIndex) -> EntryKind {
748+
fn kind(self, item_id: DefIndex) -> EntryKind {
749749
self.maybe_kind(item_id).unwrap_or_else(|| {
750750
bug!(
751751
"CrateMetadata::kind({:?}): id not found, in crate {:?} with number {}",
@@ -756,7 +756,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
756756
})
757757
}
758758

759-
fn def_kind(&self, item_id: DefIndex) -> DefKind {
759+
fn def_kind(self, item_id: DefIndex) -> DefKind {
760760
self.root.tables.def_kind.get(self, item_id).map(|k| k.decode(self)).unwrap_or_else(|| {
761761
bug!(
762762
"CrateMetadata::def_kind({:?}): id not found, in crate {:?} with number {}",
@@ -767,7 +767,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
767767
})
768768
}
769769

770-
fn get_span(&self, index: DefIndex, sess: &Session) -> Span {
770+
fn get_span(self, index: DefIndex, sess: &Session) -> Span {
771771
self.root
772772
.tables
773773
.span
@@ -776,7 +776,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
776776
.decode((self, sess))
777777
}
778778

779-
fn load_proc_macro(&self, id: DefIndex, sess: &Session) -> SyntaxExtension {
779+
fn load_proc_macro(self, id: DefIndex, sess: &Session) -> SyntaxExtension {
780780
let (name, kind, helper_attrs) = match *self.raw_proc_macro(id) {
781781
ProcMacro::CustomDerive { trait_name, attributes, client } => {
782782
let helper_attrs =
@@ -807,7 +807,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
807807
)
808808
}
809809

810-
fn get_trait_def(&self, item_id: DefIndex, sess: &Session) -> ty::TraitDef {
810+
fn get_trait_def(self, item_id: DefIndex, sess: &Session) -> ty::TraitDef {
811811
match self.kind(item_id) {
812812
EntryKind::Trait(data) => {
813813
let data = data.decode((self, sess));
@@ -837,7 +837,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
837837
}
838838

839839
fn get_variant(
840-
&self,
840+
self,
841841
kind: &EntryKind,
842842
index: DefIndex,
843843
parent_did: DefId,
@@ -886,7 +886,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
886886
)
887887
}
888888

889-
fn get_adt_def(&self, item_id: DefIndex, tcx: TyCtxt<'tcx>) -> &'tcx ty::AdtDef {
889+
fn get_adt_def(self, item_id: DefIndex, tcx: TyCtxt<'tcx>) -> &'tcx ty::AdtDef {
890890
let kind = self.kind(item_id);
891891
let did = self.local_def_id(item_id);
892892

@@ -914,15 +914,15 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
914914
}
915915

916916
fn get_explicit_predicates(
917-
&self,
917+
self,
918918
item_id: DefIndex,
919919
tcx: TyCtxt<'tcx>,
920920
) -> ty::GenericPredicates<'tcx> {
921921
self.root.tables.explicit_predicates.get(self, item_id).unwrap().decode((self, tcx))
922922
}
923923

924924
fn get_inferred_outlives(
925-
&self,
925+
self,
926926
item_id: DefIndex,
927927
tcx: TyCtxt<'tcx>,
928928
) -> &'tcx [(ty::Predicate<'tcx>, Span)] {
@@ -935,15 +935,15 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
935935
}
936936

937937
fn get_super_predicates(
938-
&self,
938+
self,
939939
item_id: DefIndex,
940940
tcx: TyCtxt<'tcx>,
941941
) -> ty::GenericPredicates<'tcx> {
942942
self.root.tables.super_predicates.get(self, item_id).unwrap().decode((self, tcx))
943943
}
944944

945945
fn get_explicit_item_bounds(
946-
&self,
946+
self,
947947
item_id: DefIndex,
948948
tcx: TyCtxt<'tcx>,
949949
) -> &'tcx [(ty::Predicate<'tcx>, Span)] {
@@ -955,11 +955,11 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
955955
.unwrap_or_default()
956956
}
957957

958-
fn get_generics(&self, item_id: DefIndex, sess: &Session) -> ty::Generics {
958+
fn get_generics(self, item_id: DefIndex, sess: &Session) -> ty::Generics {
959959
self.root.tables.generics.get(self, item_id).unwrap().decode((self, sess))
960960
}
961961

962-
fn get_type(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
962+
fn get_type(self, id: DefIndex, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
963963
self.root
964964
.tables
965965
.ty
@@ -968,78 +968,78 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
968968
.decode((self, tcx))
969969
}
970970

971-
fn get_stability(&self, id: DefIndex) -> Option<attr::Stability> {
971+
fn get_stability(self, id: DefIndex) -> Option<attr::Stability> {
972972
self.root.tables.stability.get(self, id).map(|stab| stab.decode(self))
973973
}
974974

975-
fn get_const_stability(&self, id: DefIndex) -> Option<attr::ConstStability> {
975+
fn get_const_stability(self, id: DefIndex) -> Option<attr::ConstStability> {
976976
self.root.tables.const_stability.get(self, id).map(|stab| stab.decode(self))
977977
}
978978

979-
fn get_deprecation(&self, id: DefIndex) -> Option<attr::Deprecation> {
979+
fn get_deprecation(self, id: DefIndex) -> Option<attr::Deprecation> {
980980
self.root.tables.deprecation.get(self, id).map(|depr| depr.decode(self))
981981
}
982982

983-
fn get_visibility(&self, id: DefIndex) -> ty::Visibility {
983+
fn get_visibility(self, id: DefIndex) -> ty::Visibility {
984984
self.root.tables.visibility.get(self, id).unwrap().decode(self)
985985
}
986986

987-
fn get_impl_data(&self, id: DefIndex) -> ImplData {
987+
fn get_impl_data(self, id: DefIndex) -> ImplData {
988988
match self.kind(id) {
989989
EntryKind::Impl(data) => data.decode(self),
990990
_ => bug!(),
991991
}
992992
}
993993

994-
fn get_parent_impl(&self, id: DefIndex) -> Option<DefId> {
994+
fn get_parent_impl(self, id: DefIndex) -> Option<DefId> {
995995
self.get_impl_data(id).parent_impl
996996
}
997997

998-
fn get_impl_polarity(&self, id: DefIndex) -> ty::ImplPolarity {
998+
fn get_impl_polarity(self, id: DefIndex) -> ty::ImplPolarity {
999999
self.get_impl_data(id).polarity
10001000
}
10011001

1002-
fn get_impl_defaultness(&self, id: DefIndex) -> hir::Defaultness {
1002+
fn get_impl_defaultness(self, id: DefIndex) -> hir::Defaultness {
10031003
self.get_impl_data(id).defaultness
10041004
}
10051005

1006-
fn get_impl_constness(&self, id: DefIndex) -> hir::Constness {
1006+
fn get_impl_constness(self, id: DefIndex) -> hir::Constness {
10071007
self.get_impl_data(id).constness
10081008
}
10091009

1010-
fn get_trait_item_def_id(&self, id: DefIndex) -> Option<DefId> {
1010+
fn get_trait_item_def_id(self, id: DefIndex) -> Option<DefId> {
10111011
self.root.tables.trait_item_def_id.get(self, id).map(|d| d.decode(self))
10121012
}
10131013

1014-
fn get_coerce_unsized_info(&self, id: DefIndex) -> Option<ty::adjustment::CoerceUnsizedInfo> {
1014+
fn get_coerce_unsized_info(self, id: DefIndex) -> Option<ty::adjustment::CoerceUnsizedInfo> {
10151015
self.get_impl_data(id).coerce_unsized_info
10161016
}
10171017

1018-
fn get_impl_trait(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> Option<ty::TraitRef<'tcx>> {
1018+
fn get_impl_trait(self, id: DefIndex, tcx: TyCtxt<'tcx>) -> Option<ty::TraitRef<'tcx>> {
10191019
self.root.tables.impl_trait_ref.get(self, id).map(|tr| tr.decode((self, tcx)))
10201020
}
10211021

1022-
fn get_expn_that_defined(&self, id: DefIndex, sess: &Session) -> ExpnId {
1022+
fn get_expn_that_defined(self, id: DefIndex, sess: &Session) -> ExpnId {
10231023
self.root.tables.expn_that_defined.get(self, id).unwrap().decode((self, sess))
10241024
}
10251025

10261026
fn get_const_param_default(
1027-
&self,
1027+
self,
10281028
tcx: TyCtxt<'tcx>,
10291029
id: DefIndex,
10301030
) -> rustc_middle::ty::Const<'tcx> {
10311031
self.root.tables.const_defaults.get(self, id).unwrap().decode((self, tcx))
10321032
}
10331033

10341034
/// Iterates over all the stability attributes in the given crate.
1035-
fn get_lib_features(&self, tcx: TyCtxt<'tcx>) -> &'tcx [(Symbol, Option<Symbol>)] {
1035+
fn get_lib_features(self, tcx: TyCtxt<'tcx>) -> &'tcx [(Symbol, Option<Symbol>)] {
10361036
// FIXME: For a proc macro crate, not sure whether we should return the "host"
10371037
// features or an empty Vec. Both don't cause ICEs.
10381038
tcx.arena.alloc_from_iter(self.root.lib_features.decode(self))
10391039
}
10401040

10411041
/// Iterates over the language items in the given crate.
1042-
fn get_lang_items(&self, tcx: TyCtxt<'tcx>) -> &'tcx [(DefId, usize)] {
1042+
fn get_lang_items(self, tcx: TyCtxt<'tcx>) -> &'tcx [(DefId, usize)] {
10431043
if self.root.is_proc_macro_crate() {
10441044
// Proc macro crates do not export any lang-items to the target.
10451045
&[]
@@ -1054,7 +1054,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
10541054
}
10551055

10561056
/// Iterates over the diagnostic items in the given crate.
1057-
fn get_diagnostic_items(&self) -> DiagnosticItems {
1057+
fn get_diagnostic_items(self) -> DiagnosticItems {
10581058
if self.root.is_proc_macro_crate() {
10591059
// Proc macro crates do not export any diagnostic-items to the target.
10601060
Default::default()
@@ -1079,7 +1079,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
10791079
/// Module here is understood in name resolution sense - it can be a `mod` item,
10801080
/// or a crate root, or an enum, or a trait.
10811081
fn for_each_module_child(
1082-
&self,
1082+
self,
10831083
id: DefIndex,
10841084
mut callback: impl FnMut(ModChild),
10851085
sess: &Session,
@@ -1177,15 +1177,15 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
11771177
}
11781178
}
11791179

1180-
fn is_ctfe_mir_available(&self, id: DefIndex) -> bool {
1180+
fn is_ctfe_mir_available(self, id: DefIndex) -> bool {
11811181
self.root.tables.mir_for_ctfe.get(self, id).is_some()
11821182
}
11831183

1184-
fn is_item_mir_available(&self, id: DefIndex) -> bool {
1184+
fn is_item_mir_available(self, id: DefIndex) -> bool {
11851185
self.root.tables.mir.get(self, id).is_some()
11861186
}
11871187

1188-
fn module_expansion(&self, id: DefIndex, sess: &Session) -> ExpnId {
1188+
fn module_expansion(self, id: DefIndex, sess: &Session) -> ExpnId {
11891189
match self.kind(id) {
11901190
EntryKind::Mod(_) | EntryKind::Enum(_) | EntryKind::Trait(_) => {
11911191
self.get_expn_that_defined(id, sess)
@@ -1194,7 +1194,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
11941194
}
11951195
}
11961196

1197-
fn get_optimized_mir(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> Body<'tcx> {
1197+
fn get_optimized_mir(self, tcx: TyCtxt<'tcx>, id: DefIndex) -> Body<'tcx> {
11981198
self.root
11991199
.tables
12001200
.mir
@@ -1205,7 +1205,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
12051205
.decode((self, tcx))
12061206
}
12071207

1208-
fn get_mir_for_ctfe(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> Body<'tcx> {
1208+
fn get_mir_for_ctfe(self, tcx: TyCtxt<'tcx>, id: DefIndex) -> Body<'tcx> {
12091209
self.root
12101210
.tables
12111211
.mir_for_ctfe
@@ -1217,7 +1217,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
12171217
}
12181218

12191219
fn get_thir_abstract_const(
1220-
&self,
1220+
self,
12211221
tcx: TyCtxt<'tcx>,
12221222
id: DefIndex,
12231223
) -> Result<Option<&'tcx [thir::abstract_const::Node<'tcx>]>, ErrorReported> {
@@ -1228,7 +1228,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
12281228
.map_or(Ok(None), |v| Ok(Some(v.decode((self, tcx)))))
12291229
}
12301230

1231-
fn get_unused_generic_params(&self, id: DefIndex) -> FiniteBitSet<u32> {
1231+
fn get_unused_generic_params(self, id: DefIndex) -> FiniteBitSet<u32> {
12321232
self.root
12331233
.tables
12341234
.unused_generic_params
@@ -1237,7 +1237,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
12371237
.unwrap_or_default()
12381238
}
12391239

1240-
fn get_promoted_mir(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> IndexVec<Promoted, Body<'tcx>> {
1240+
fn get_promoted_mir(self, tcx: TyCtxt<'tcx>, id: DefIndex) -> IndexVec<Promoted, Body<'tcx>> {
12411241
self.root
12421242
.tables
12431243
.promoted_mir
@@ -1248,7 +1248,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
12481248
.decode((self, tcx))
12491249
}
12501250

1251-
fn mir_const_qualif(&self, id: DefIndex) -> mir::ConstQualifs {
1251+
fn mir_const_qualif(self, id: DefIndex) -> mir::ConstQualifs {
12521252
match self.kind(id) {
12531253
EntryKind::AnonConst(qualif, _)
12541254
| EntryKind::Const(qualif, _)
@@ -1263,14 +1263,14 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
12631263
}
12641264
}
12651265

1266-
fn get_fn_has_self_parameter(&self, id: DefIndex) -> bool {
1266+
fn get_fn_has_self_parameter(self, id: DefIndex) -> bool {
12671267
match self.kind(id) {
12681268
EntryKind::AssocFn(data) => data.decode(self).has_self,
12691269
_ => false,
12701270
}
12711271
}
12721272

1273-
fn get_associated_item_def_ids(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> &'tcx [DefId] {
1273+
fn get_associated_item_def_ids(self, tcx: TyCtxt<'tcx>, id: DefIndex) -> &'tcx [DefId] {
12741274
if let Some(children) = self.root.tables.children.get(self, id) {
12751275
tcx.arena.alloc_from_iter(
12761276
children.decode((self, tcx.sess)).map(|child_index| self.local_def_id(child_index)),
@@ -1280,7 +1280,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
12801280
}
12811281
}
12821282

1283-
fn get_associated_item(&self, id: DefIndex, sess: &Session) -> ty::AssocItem {
1283+
fn get_associated_item(self, id: DefIndex, sess: &Session) -> ty::AssocItem {
12841284
let def_key = self.def_key(id);
12851285
let parent = self.local_def_id(def_key.parent.unwrap());
12861286
let ident = self.item_ident(id, sess);
@@ -1307,11 +1307,11 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
13071307
}
13081308
}
13091309

1310-
fn get_item_variances(&'a self, id: DefIndex) -> impl Iterator<Item = ty::Variance> + 'a {
1310+
fn get_item_variances(self, id: DefIndex) -> impl Iterator<Item = ty::Variance> + 'a {
13111311
self.root.tables.variances.get(self, id).unwrap_or_else(Lazy::empty).decode(self)
13121312
}
13131313

1314-
fn get_ctor_def_id_and_kind(&self, node_id: DefIndex) -> Option<(DefId, CtorKind)> {
1314+
fn get_ctor_def_id_and_kind(self, node_id: DefIndex) -> Option<(DefId, CtorKind)> {
13151315
match self.kind(node_id) {
13161316
EntryKind::Struct(data, _) | EntryKind::Variant(data) => {
13171317
let vdata = data.decode(self);
@@ -1322,7 +1322,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
13221322
}
13231323

13241324
fn get_item_attrs(
1325-
&'a self,
1325+
self,
13261326
id: DefIndex,
13271327
sess: &'a Session,
13281328
) -> impl Iterator<Item = ast::Attribute> + 'a {
@@ -1346,7 +1346,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
13461346
.decode((self, sess))
13471347
}
13481348

1349-
fn get_struct_field_names(&self, id: DefIndex, sess: &Session) -> Vec<Spanned<Symbol>> {
1349+
fn get_struct_field_names(self, id: DefIndex, sess: &Session) -> Vec<Spanned<Symbol>> {
13501350
self.root
13511351
.tables
13521352
.children
@@ -1357,7 +1357,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
13571357
.collect()
13581358
}
13591359

1360-
fn get_struct_field_visibilities(&self, id: DefIndex) -> Vec<Visibility> {
1360+
fn get_struct_field_visibilities(self, id: DefIndex) -> Vec<Visibility> {
13611361
self.root
13621362
.tables
13631363
.children
@@ -1369,7 +1369,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
13691369
}
13701370

13711371
fn get_inherent_implementations_for_type(
1372-
&self,
1372+
self,
13731373
tcx: TyCtxt<'tcx>,
13741374
id: DefIndex,
13751375
) -> &'tcx [DefId] {
@@ -1384,20 +1384,20 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
13841384
)
13851385
}
13861386

1387-
fn get_traits(&'a self) -> impl Iterator<Item = DefId> + 'a {
1388-
self.root.traits.decode(self).map(|index| self.local_def_id(index))
1387+
fn get_traits(self) -> impl Iterator<Item = DefId> + 'a {
1388+
self.root.traits.decode(self).map(move |index| self.local_def_id(index))
13891389
}
13901390

1391-
fn get_trait_impls(&'a self) -> impl Iterator<Item = (DefId, Option<SimplifiedType>)> + 'a {
1392-
self.trait_impls.values().flat_map(move |impls| {
1391+
fn get_trait_impls(self) -> impl Iterator<Item = (DefId, Option<SimplifiedType>)> + 'a {
1392+
self.cdata.trait_impls.values().flat_map(move |impls| {
13931393
impls
13941394
.decode(self)
1395-
.map(|(idx, simplified_self_ty)| (self.local_def_id(idx), simplified_self_ty))
1395+
.map(move |(idx, simplified_self_ty)| (self.local_def_id(idx), simplified_self_ty))
13961396
})
13971397
}
13981398

13991399
fn get_implementations_of_trait(
1400-
&self,
1400+
self,
14011401
tcx: TyCtxt<'tcx>,
14021402
trait_def_id: DefId,
14031403
) -> &'tcx [(DefId, Option<SimplifiedType>)] {
@@ -1424,7 +1424,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
14241424
}
14251425
}
14261426

1427-
fn get_trait_of_item(&self, id: DefIndex) -> Option<DefId> {
1427+
fn get_trait_of_item(self, id: DefIndex) -> Option<DefId> {
14281428
let def_key = self.def_key(id);
14291429
match def_key.disambiguated_data.data {
14301430
DefPathData::TypeNs(..) | DefPathData::ValueNs(..) => (),
@@ -1437,7 +1437,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
14371437
})
14381438
}
14391439

1440-
fn get_native_libraries(&self, sess: &Session) -> Vec<NativeLib> {
1440+
fn get_native_libraries(self, sess: &Session) -> Vec<NativeLib> {
14411441
if self.root.is_proc_macro_crate() {
14421442
// Proc macro crates do not have any *target* native libraries.
14431443
vec![]
@@ -1446,7 +1446,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
14461446
}
14471447
}
14481448

1449-
fn get_proc_macro_quoted_span(&self, index: usize, sess: &Session) -> Span {
1449+
fn get_proc_macro_quoted_span(self, index: usize, sess: &Session) -> Span {
14501450
self.root
14511451
.tables
14521452
.proc_macro_quoted_spans
@@ -1455,7 +1455,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
14551455
.decode((self, sess))
14561456
}
14571457

1458-
fn get_foreign_modules(&self, tcx: TyCtxt<'tcx>) -> Lrc<FxHashMap<DefId, ForeignModule>> {
1458+
fn get_foreign_modules(self, tcx: TyCtxt<'tcx>) -> Lrc<FxHashMap<DefId, ForeignModule>> {
14591459
if self.root.is_proc_macro_crate() {
14601460
// Proc macro crates do not have any *target* foreign modules.
14611461
Lrc::new(FxHashMap::default())
@@ -1467,7 +1467,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
14671467
}
14681468

14691469
fn get_dylib_dependency_formats(
1470-
&self,
1470+
self,
14711471
tcx: TyCtxt<'tcx>,
14721472
) -> &'tcx [(CrateNum, LinkagePreference)] {
14731473
tcx.arena.alloc_from_iter(
@@ -1478,7 +1478,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
14781478
)
14791479
}
14801480

1481-
fn get_missing_lang_items(&self, tcx: TyCtxt<'tcx>) -> &'tcx [lang_items::LangItem] {
1481+
fn get_missing_lang_items(self, tcx: TyCtxt<'tcx>) -> &'tcx [lang_items::LangItem] {
14821482
if self.root.is_proc_macro_crate() {
14831483
// Proc macro crates do not depend on any target weak lang-items.
14841484
&[]
@@ -1487,7 +1487,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
14871487
}
14881488
}
14891489

1490-
fn get_fn_param_names(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> &'tcx [Ident] {
1490+
fn get_fn_param_names(self, tcx: TyCtxt<'tcx>, id: DefIndex) -> &'tcx [Ident] {
14911491
let param_names = match self.kind(id) {
14921492
EntryKind::Fn(data) | EntryKind::ForeignFn(data) => data.decode(self).param_names,
14931493
EntryKind::AssocFn(data) => data.decode(self).fn_data.param_names,
@@ -1497,7 +1497,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
14971497
}
14981498

14991499
fn exported_symbols(
1500-
&self,
1500+
self,
15011501
tcx: TyCtxt<'tcx>,
15021502
) -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportLevel)] {
15031503
if self.root.is_proc_macro_crate() {
@@ -1509,7 +1509,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
15091509
}
15101510
}
15111511

1512-
fn get_rendered_const(&self, id: DefIndex) -> String {
1512+
fn get_rendered_const(self, id: DefIndex) -> String {
15131513
match self.kind(id) {
15141514
EntryKind::AnonConst(_, data)
15151515
| EntryKind::Const(_, data)
@@ -1518,7 +1518,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
15181518
}
15191519
}
15201520

1521-
fn get_macro(&self, id: DefIndex, sess: &Session) -> MacroDef {
1521+
fn get_macro(self, id: DefIndex, sess: &Session) -> MacroDef {
15221522
match self.kind(id) {
15231523
EntryKind::MacroDef(macro_def) => macro_def.decode((self, sess)),
15241524
_ => bug!(),
@@ -1527,7 +1527,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
15271527

15281528
// This replicates some of the logic of the crate-local `is_const_fn_raw` query, because we
15291529
// don't serialize constness for tuple variant and tuple struct constructors.
1530-
fn is_const_fn_raw(&self, id: DefIndex) -> bool {
1530+
fn is_const_fn_raw(self, id: DefIndex) -> bool {
15311531
let constness = match self.kind(id) {
15321532
EntryKind::AssocFn(data) => data.decode(self).fn_data.constness,
15331533
EntryKind::Fn(data) => data.decode(self).constness,
@@ -1538,7 +1538,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
15381538
constness == hir::Constness::Const
15391539
}
15401540

1541-
fn asyncness(&self, id: DefIndex) -> hir::IsAsync {
1541+
fn asyncness(self, id: DefIndex) -> hir::IsAsync {
15421542
match self.kind(id) {
15431543
EntryKind::Fn(data) => data.decode(self).asyncness,
15441544
EntryKind::AssocFn(data) => data.decode(self).fn_data.asyncness,
@@ -1547,7 +1547,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
15471547
}
15481548
}
15491549

1550-
fn is_foreign_item(&self, id: DefIndex) -> bool {
1550+
fn is_foreign_item(self, id: DefIndex) -> bool {
15511551
match self.kind(id) {
15521552
EntryKind::ForeignImmStatic | EntryKind::ForeignMutStatic | EntryKind::ForeignFn(_) => {
15531553
true
@@ -1556,27 +1556,27 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
15561556
}
15571557
}
15581558

1559-
fn static_mutability(&self, id: DefIndex) -> Option<hir::Mutability> {
1559+
fn static_mutability(self, id: DefIndex) -> Option<hir::Mutability> {
15601560
match self.kind(id) {
15611561
EntryKind::ImmStatic | EntryKind::ForeignImmStatic => Some(hir::Mutability::Not),
15621562
EntryKind::MutStatic | EntryKind::ForeignMutStatic => Some(hir::Mutability::Mut),
15631563
_ => None,
15641564
}
15651565
}
15661566

1567-
fn generator_kind(&self, id: DefIndex) -> Option<hir::GeneratorKind> {
1567+
fn generator_kind(self, id: DefIndex) -> Option<hir::GeneratorKind> {
15681568
match self.kind(id) {
15691569
EntryKind::Generator(data) => Some(data),
15701570
_ => None,
15711571
}
15721572
}
15731573

1574-
fn fn_sig(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> ty::PolyFnSig<'tcx> {
1574+
fn fn_sig(self, id: DefIndex, tcx: TyCtxt<'tcx>) -> ty::PolyFnSig<'tcx> {
15751575
self.root.tables.fn_sig.get(self, id).unwrap().decode((self, tcx))
15761576
}
15771577

15781578
#[inline]
1579-
fn def_key(&self, index: DefIndex) -> DefKey {
1579+
fn def_key(self, index: DefIndex) -> DefKey {
15801580
*self
15811581
.def_key_cache
15821582
.lock()
@@ -1585,13 +1585,13 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
15851585
}
15861586

15871587
// Returns the path leading to the thing with this `id`.
1588-
fn def_path(&self, id: DefIndex) -> DefPath {
1588+
fn def_path(self, id: DefIndex) -> DefPath {
15891589
debug!("def_path(cnum={:?}, id={:?})", self.cnum, id);
15901590
DefPath::make(self.cnum, id, |parent| self.def_key(parent))
15911591
}
15921592

15931593
fn def_path_hash_unlocked(
1594-
&self,
1594+
self,
15951595
index: DefIndex,
15961596
def_path_hashes: &mut FxHashMap<DefIndex, DefPathHash>,
15971597
) -> DefPathHash {
@@ -1601,17 +1601,17 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
16011601
}
16021602

16031603
#[inline]
1604-
fn def_path_hash(&self, index: DefIndex) -> DefPathHash {
1604+
fn def_path_hash(self, index: DefIndex) -> DefPathHash {
16051605
let mut def_path_hashes = self.def_path_hash_cache.lock();
16061606
self.def_path_hash_unlocked(index, &mut def_path_hashes)
16071607
}
16081608

16091609
#[inline]
1610-
fn def_path_hash_to_def_index(&self, hash: DefPathHash) -> DefIndex {
1610+
fn def_path_hash_to_def_index(self, hash: DefPathHash) -> DefIndex {
16111611
self.def_path_hash_map.def_path_hash_to_def_index(&hash)
16121612
}
16131613

1614-
fn expn_hash_to_expn_id(&self, sess: &Session, index_guess: u32, hash: ExpnHash) -> ExpnId {
1614+
fn expn_hash_to_expn_id(self, sess: &Session, index_guess: u32, hash: ExpnHash) -> ExpnId {
16151615
debug_assert_eq!(ExpnId::from_hash(hash), None);
16161616
let index_guess = ExpnIndex::from_u32(index_guess);
16171617
let old_hash = self.root.expn_hashes.get(self, index_guess).map(|lazy| lazy.decode(self));
@@ -1669,7 +1669,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
16691669
///
16701670
/// Proc macro crates don't currently export spans, so this function does not have
16711671
/// to work for them.
1672-
fn imported_source_files(&self, sess: &Session) -> &'a [ImportedSourceFile] {
1672+
fn imported_source_files(self, sess: &Session) -> &'a [ImportedSourceFile] {
16731673
// Translate the virtual `/rustc/$hash` prefix back to a real directory
16741674
// that should hold actual sources, where possible.
16751675
//

0 commit comments

Comments
 (0)
Please sign in to comment.