Unify all uses of 'gcx and 'tcx.

This commit is contained in:
Eduard-Mihai Burtescu 2019-06-14 00:48:52 +03:00
parent 0e4a56b4b0
commit f3f9d6dfd9
341 changed files with 3109 additions and 3327 deletions

View file

@ -39,7 +39,7 @@ pub struct DecodeContext<'a, 'tcx: 'a> {
opaque: opaque::Decoder<'a>,
cdata: Option<&'a CrateMetadata>,
sess: Option<&'a Session>,
tcx: Option<TyCtxt<'tcx, 'tcx>>,
tcx: Option<TyCtxt<'tcx>>,
// Cache the last used source_file for translating spans as an optimization.
last_source_file_index: usize,
@ -55,7 +55,7 @@ pub trait Metadata<'a, 'tcx>: Copy {
fn raw_bytes(self) -> &'a [u8];
fn cdata(self) -> Option<&'a CrateMetadata> { None }
fn sess(self) -> Option<&'a Session> { None }
fn tcx(self) -> Option<TyCtxt<'tcx, 'tcx>> {
fn tcx(self) -> Option<TyCtxt<'tcx>> {
None
}
@ -116,14 +116,14 @@ impl<'a, 'tcx> Metadata<'a, 'tcx> for (&'a CrateMetadata, &'a Session) {
}
}
impl<'a, 'tcx> Metadata<'a, 'tcx> for (&'a CrateMetadata, TyCtxt<'tcx, 'tcx>) {
impl<'a, 'tcx> Metadata<'a, 'tcx> for (&'a CrateMetadata, TyCtxt<'tcx>) {
fn raw_bytes(self) -> &'a [u8] {
self.0.raw_bytes()
}
fn cdata(self) -> Option<&'a CrateMetadata> {
Some(self.0)
}
fn tcx(self) -> Option<TyCtxt<'tcx, 'tcx>> {
fn tcx(self) -> Option<TyCtxt<'tcx>> {
Some(self.1)
}
}
@ -148,7 +148,7 @@ impl<'a, 'tcx: 'a, T: Decodable> LazySeq<T> {
}
impl<'a, 'tcx> DecodeContext<'a, 'tcx> {
pub fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
pub fn tcx(&self) -> TyCtxt<'tcx> {
self.tcx.expect("missing TyCtxt in DecodeContext")
}
@ -173,7 +173,7 @@ impl<'a, 'tcx> DecodeContext<'a, 'tcx> {
impl<'a, 'tcx> TyDecoder<'tcx> for DecodeContext<'a, 'tcx> {
#[inline]
fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
fn tcx(&self) -> TyCtxt<'tcx> {
self.tcx.expect("missing TyCtxt in DecodeContext")
}
@ -548,7 +548,7 @@ impl<'a, 'tcx> CrateMetadata {
fn get_variant(
&self,
tcx: TyCtxt<'tcx, 'tcx>,
tcx: TyCtxt<'tcx>,
item: &Entry<'_>,
index: DefIndex,
parent_did: DefId,
@ -589,7 +589,7 @@ impl<'a, 'tcx> CrateMetadata {
)
}
pub fn get_adt_def(&self, item_id: DefIndex, tcx: TyCtxt<'tcx, 'tcx>) -> &'tcx ty::AdtDef {
pub fn get_adt_def(&self, item_id: DefIndex, tcx: TyCtxt<'tcx>) -> &'tcx ty::AdtDef {
let item = self.entry(item_id);
let did = self.local_def_id(item_id);
@ -617,7 +617,7 @@ impl<'a, 'tcx> CrateMetadata {
pub fn get_predicates(
&self,
item_id: DefIndex,
tcx: TyCtxt<'tcx, 'tcx>,
tcx: TyCtxt<'tcx>,
) -> ty::GenericPredicates<'tcx> {
self.entry(item_id).predicates.unwrap().decode((self, tcx))
}
@ -625,7 +625,7 @@ impl<'a, 'tcx> CrateMetadata {
pub fn get_predicates_defined_on(
&self,
item_id: DefIndex,
tcx: TyCtxt<'tcx, 'tcx>,
tcx: TyCtxt<'tcx>,
) -> ty::GenericPredicates<'tcx> {
self.entry(item_id).predicates_defined_on.unwrap().decode((self, tcx))
}
@ -633,7 +633,7 @@ impl<'a, 'tcx> CrateMetadata {
pub fn get_super_predicates(
&self,
item_id: DefIndex,
tcx: TyCtxt<'tcx, 'tcx>,
tcx: TyCtxt<'tcx>,
) -> ty::GenericPredicates<'tcx> {
let super_predicates = match self.entry(item_id).kind {
EntryKind::Trait(data) => data.decode(self).super_predicates,
@ -651,7 +651,7 @@ impl<'a, 'tcx> CrateMetadata {
self.entry(item_id).generics.unwrap().decode((self, sess))
}
pub fn get_type(&self, id: DefIndex, tcx: TyCtxt<'tcx, 'tcx>) -> Ty<'tcx> {
pub fn get_type(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
self.entry(id).ty.unwrap().decode((self, tcx))
}
@ -704,7 +704,7 @@ impl<'a, 'tcx> CrateMetadata {
pub fn get_impl_trait(
&self,
id: DefIndex,
tcx: TyCtxt<'tcx, 'tcx>,
tcx: TyCtxt<'tcx>,
) -> Option<ty::TraitRef<'tcx>> {
self.get_impl_data(id).trait_ref.map(|tr| tr.decode((self, tcx)))
}
@ -712,7 +712,7 @@ impl<'a, 'tcx> CrateMetadata {
/// Iterates over all the stability attributes in the given crate.
pub fn get_lib_features(
&self,
tcx: TyCtxt<'tcx, '_>,
tcx: TyCtxt<'tcx>,
) -> &'tcx [(ast::Name, Option<ast::Name>)] {
// FIXME: For a proc macro crate, not sure whether we should return the "host"
// features or an empty Vec. Both don't cause ICEs.
@ -722,7 +722,7 @@ impl<'a, 'tcx> CrateMetadata {
}
/// Iterates over the language items in the given crate.
pub fn get_lang_items(&self, tcx: TyCtxt<'tcx, '_>) -> &'tcx [(DefId, usize)] {
pub fn get_lang_items(&self, tcx: TyCtxt<'tcx>) -> &'tcx [(DefId, usize)] {
if self.proc_macros.is_some() {
// Proc macro crates do not export any lang-items to the target.
&[]
@ -885,7 +885,7 @@ impl<'a, 'tcx> CrateMetadata {
pub fn maybe_get_optimized_mir(
&self,
tcx: TyCtxt<'tcx, 'tcx>,
tcx: TyCtxt<'tcx>,
id: DefIndex,
) -> Option<Body<'tcx>> {
match self.is_proc_macro(id) {
@ -1019,7 +1019,7 @@ impl<'a, 'tcx> CrateMetadata {
pub fn get_inherent_implementations_for_type(
&self,
tcx: TyCtxt<'tcx, '_>,
tcx: TyCtxt<'tcx>,
id: DefIndex,
) -> &'tcx [DefId] {
tcx.arena.alloc_from_iter(self.entry(id)
@ -1030,7 +1030,7 @@ impl<'a, 'tcx> CrateMetadata {
pub fn get_implementations_for_trait(
&self,
tcx: TyCtxt<'tcx, '_>,
tcx: TyCtxt<'tcx>,
filter: Option<DefId>,
) -> &'tcx [DefId] {
if self.proc_macros.is_some() {
@ -1085,7 +1085,7 @@ impl<'a, 'tcx> CrateMetadata {
}
}
pub fn get_foreign_modules(&self, tcx: TyCtxt<'tcx, '_>) -> &'tcx [ForeignModule] {
pub fn get_foreign_modules(&self, tcx: TyCtxt<'tcx>) -> &'tcx [ForeignModule] {
if self.proc_macros.is_some() {
// Proc macro crates do not have any *target* foreign modules.
&[]
@ -1096,7 +1096,7 @@ impl<'a, 'tcx> CrateMetadata {
pub fn get_dylib_dependency_formats(
&self,
tcx: TyCtxt<'tcx, '_>,
tcx: TyCtxt<'tcx>,
) -> &'tcx [(CrateNum, LinkagePreference)] {
tcx.arena.alloc_from_iter(self.root
.dylib_dependency_formats
@ -1108,7 +1108,7 @@ impl<'a, 'tcx> CrateMetadata {
}))
}
pub fn get_missing_lang_items(&self, tcx: TyCtxt<'tcx, '_>) -> &'tcx [lang_items::LangItem] {
pub fn get_missing_lang_items(&self, tcx: TyCtxt<'tcx>) -> &'tcx [lang_items::LangItem] {
if self.proc_macros.is_some() {
// Proc macro crates do not depend on any target weak lang-items.
&[]
@ -1131,7 +1131,7 @@ impl<'a, 'tcx> CrateMetadata {
pub fn exported_symbols(
&self,
tcx: TyCtxt<'tcx, 'tcx>,
tcx: TyCtxt<'tcx>,
) -> Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)> {
if self.proc_macros.is_some() {
// If this crate is a custom derive crate, then we're not even going to
@ -1187,7 +1187,7 @@ impl<'a, 'tcx> CrateMetadata {
}
}
pub fn fn_sig(&self, id: DefIndex, tcx: TyCtxt<'tcx, 'tcx>) -> ty::PolyFnSig<'tcx> {
pub fn fn_sig(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> ty::PolyFnSig<'tcx> {
let sig = match self.entry(id).kind {
EntryKind::Fn(data) |
EntryKind::ForeignFn(data) => data.decode(self).sig,