1
Fork 0

rustc: remove some unnecessary lifetimes in -> TyCtxt methods.

This commit is contained in:
Eduard-Mihai Burtescu 2019-06-05 17:03:08 +03:00
parent 17cdd356da
commit 21ac960334
14 changed files with 28 additions and 41 deletions

View file

@ -793,7 +793,7 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
type DynExistential = (); type DynExistential = ();
type Const = (); type Const = ();
fn tcx<'a>(&'a self) -> TyCtxt<'tcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
self.tcx self.tcx
} }

View file

@ -144,7 +144,7 @@ pub struct AllocDecodingSession<'s> {
impl<'s> AllocDecodingSession<'s> { impl<'s> AllocDecodingSession<'s> {
// Decodes an AllocId in a thread-safe way. // Decodes an AllocId in a thread-safe way.
pub fn decode_alloc_id<'tcx, D>(&self, pub fn decode_alloc_id<D>(&self,
decoder: &mut D) decoder: &mut D)
-> Result<AllocId, D::Error> -> Result<AllocId, D::Error>
where D: TyDecoder<'tcx>, where D: TyDecoder<'tcx>,

View file

@ -68,7 +68,7 @@ struct NormalizeAfterErasingRegionsFolder<'tcx> {
} }
impl TypeFolder<'tcx, 'tcx> for NormalizeAfterErasingRegionsFolder<'tcx> { impl TypeFolder<'tcx, 'tcx> for NormalizeAfterErasingRegionsFolder<'tcx> {
fn tcx<'a>(&'a self) -> TyCtxt<'tcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
self.tcx self.tcx
} }

View file

@ -131,38 +131,34 @@ pub trait TyDecoder<'tcx>: Decoder {
} }
#[inline] #[inline]
pub fn decode_arena_allocable<'a, 'tcx, D, T: ArenaAllocatable + Decodable>( pub fn decode_arena_allocable<D, T: ArenaAllocatable + Decodable>(
decoder: &mut D decoder: &mut D
) -> Result<&'tcx T, D::Error> ) -> Result<&'tcx T, D::Error>
where D: TyDecoder<'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a,
{ {
Ok(decoder.tcx().arena.alloc(Decodable::decode(decoder)?)) Ok(decoder.tcx().arena.alloc(Decodable::decode(decoder)?))
} }
#[inline] #[inline]
pub fn decode_arena_allocable_slice<'a, 'tcx, D, T: ArenaAllocatable + Decodable>( pub fn decode_arena_allocable_slice<D, T: ArenaAllocatable + Decodable>(
decoder: &mut D decoder: &mut D
) -> Result<&'tcx [T], D::Error> ) -> Result<&'tcx [T], D::Error>
where D: TyDecoder<'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a,
{ {
Ok(decoder.tcx().arena.alloc_from_iter(<Vec<T> as Decodable>::decode(decoder)?)) Ok(decoder.tcx().arena.alloc_from_iter(<Vec<T> as Decodable>::decode(decoder)?))
} }
#[inline] #[inline]
pub fn decode_cnum<'a, 'tcx, D>(decoder: &mut D) -> Result<CrateNum, D::Error> pub fn decode_cnum<D>(decoder: &mut D) -> Result<CrateNum, D::Error>
where D: TyDecoder<'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a,
{ {
let cnum = CrateNum::from_u32(u32::decode(decoder)?); let cnum = CrateNum::from_u32(u32::decode(decoder)?);
Ok(decoder.map_encoded_cnum_to_current(cnum)) Ok(decoder.map_encoded_cnum_to_current(cnum))
} }
#[inline] #[inline]
pub fn decode_ty<'a, 'tcx, D>(decoder: &mut D) -> Result<Ty<'tcx>, D::Error> pub fn decode_ty<D>(decoder: &mut D) -> Result<Ty<'tcx>, D::Error>
where D: TyDecoder<'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a,
{ {
// Handle shorthands first, if we have an usize > 0x80. // Handle shorthands first, if we have an usize > 0x80.
if decoder.positioned_at_shorthand() { if decoder.positioned_at_shorthand() {
@ -180,10 +176,9 @@ pub fn decode_ty<'a, 'tcx, D>(decoder: &mut D) -> Result<Ty<'tcx>, D::Error>
} }
#[inline] #[inline]
pub fn decode_predicates<'a, 'tcx, D>(decoder: &mut D) pub fn decode_predicates<D>(decoder: &mut D)
-> Result<ty::GenericPredicates<'tcx>, D::Error> -> Result<ty::GenericPredicates<'tcx>, D::Error>
where D: TyDecoder<'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a,
{ {
Ok(ty::GenericPredicates { Ok(ty::GenericPredicates {
parent: Decodable::decode(decoder)?, parent: Decodable::decode(decoder)?,
@ -205,9 +200,8 @@ pub fn decode_predicates<'a, 'tcx, D>(decoder: &mut D)
} }
#[inline] #[inline]
pub fn decode_substs<'a, 'tcx, D>(decoder: &mut D) -> Result<SubstsRef<'tcx>, D::Error> pub fn decode_substs<D>(decoder: &mut D) -> Result<SubstsRef<'tcx>, D::Error>
where D: TyDecoder<'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a,
{ {
let len = decoder.read_usize()?; let len = decoder.read_usize()?;
let tcx = decoder.tcx(); let tcx = decoder.tcx();
@ -215,38 +209,34 @@ pub fn decode_substs<'a, 'tcx, D>(decoder: &mut D) -> Result<SubstsRef<'tcx>, D:
} }
#[inline] #[inline]
pub fn decode_region<'a, 'tcx, D>(decoder: &mut D) -> Result<ty::Region<'tcx>, D::Error> pub fn decode_region<D>(decoder: &mut D) -> Result<ty::Region<'tcx>, D::Error>
where D: TyDecoder<'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a,
{ {
Ok(decoder.tcx().mk_region(Decodable::decode(decoder)?)) Ok(decoder.tcx().mk_region(Decodable::decode(decoder)?))
} }
#[inline] #[inline]
pub fn decode_ty_slice<'a, 'tcx, D>(decoder: &mut D) pub fn decode_ty_slice<D>(decoder: &mut D)
-> Result<&'tcx ty::List<Ty<'tcx>>, D::Error> -> Result<&'tcx ty::List<Ty<'tcx>>, D::Error>
where D: TyDecoder<'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a,
{ {
let len = decoder.read_usize()?; let len = decoder.read_usize()?;
Ok(decoder.tcx().mk_type_list((0..len).map(|_| Decodable::decode(decoder)))?) Ok(decoder.tcx().mk_type_list((0..len).map(|_| Decodable::decode(decoder)))?)
} }
#[inline] #[inline]
pub fn decode_adt_def<'a, 'tcx, D>(decoder: &mut D) pub fn decode_adt_def<D>(decoder: &mut D)
-> Result<&'tcx ty::AdtDef, D::Error> -> Result<&'tcx ty::AdtDef, D::Error>
where D: TyDecoder<'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a,
{ {
let def_id = DefId::decode(decoder)?; let def_id = DefId::decode(decoder)?;
Ok(decoder.tcx().adt_def(def_id)) Ok(decoder.tcx().adt_def(def_id))
} }
#[inline] #[inline]
pub fn decode_existential_predicate_slice<'a, 'tcx, D>(decoder: &mut D) pub fn decode_existential_predicate_slice<D>(decoder: &mut D)
-> Result<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>, D::Error> -> Result<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>, D::Error>
where D: TyDecoder<'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a,
{ {
let len = decoder.read_usize()?; let len = decoder.read_usize()?;
Ok(decoder.tcx() Ok(decoder.tcx()
@ -254,10 +244,9 @@ pub fn decode_existential_predicate_slice<'a, 'tcx, D>(decoder: &mut D)
} }
#[inline] #[inline]
pub fn decode_canonical_var_infos<'a, 'tcx, D>(decoder: &mut D) pub fn decode_canonical_var_infos<D>(decoder: &mut D)
-> Result<CanonicalVarInfos<'tcx>, D::Error> -> Result<CanonicalVarInfos<'tcx>, D::Error>
where D: TyDecoder<'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a,
{ {
let len = decoder.read_usize()?; let len = decoder.read_usize()?;
let interned: Result<Vec<CanonicalVarInfo>, _> = (0..len).map(|_| Decodable::decode(decoder)) let interned: Result<Vec<CanonicalVarInfo>, _> = (0..len).map(|_| Decodable::decode(decoder))
@ -267,19 +256,17 @@ pub fn decode_canonical_var_infos<'a, 'tcx, D>(decoder: &mut D)
} }
#[inline] #[inline]
pub fn decode_const<'a, 'tcx, D>(decoder: &mut D) pub fn decode_const<D>(decoder: &mut D)
-> Result<&'tcx ty::Const<'tcx>, D::Error> -> Result<&'tcx ty::Const<'tcx>, D::Error>
where D: TyDecoder<'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a,
{ {
Ok(decoder.tcx().mk_const(Decodable::decode(decoder)?)) Ok(decoder.tcx().mk_const(Decodable::decode(decoder)?))
} }
#[inline] #[inline]
pub fn decode_allocation<'a, 'tcx, D>(decoder: &mut D) pub fn decode_allocation<D>(decoder: &mut D)
-> Result<&'tcx Allocation, D::Error> -> Result<&'tcx Allocation, D::Error>
where D: TyDecoder<'tcx>, where D: TyDecoder<'tcx>,
'tcx: 'a,
{ {
Ok(decoder.tcx().intern_const_alloc(Decodable::decode(decoder)?)) Ok(decoder.tcx().intern_const_alloc(Decodable::decode(decoder)?))
} }

View file

@ -1727,7 +1727,7 @@ impl<'tcx> SizeSkeleton<'tcx> {
} }
pub trait HasTyCtxt<'tcx>: HasDataLayout { pub trait HasTyCtxt<'tcx>: HasDataLayout {
fn tcx<'a>(&'a self) -> TyCtxt<'tcx, 'tcx>; fn tcx(&self) -> TyCtxt<'tcx, 'tcx>;
} }
pub trait HasParamEnv<'tcx> { pub trait HasParamEnv<'tcx> {
@ -1741,7 +1741,7 @@ impl<'gcx, 'tcx> HasDataLayout for TyCtxt<'gcx, 'tcx> {
} }
impl<'gcx, 'tcx> HasTyCtxt<'gcx> for TyCtxt<'gcx, 'tcx> { impl<'gcx, 'tcx> HasTyCtxt<'gcx> for TyCtxt<'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'gcx> { fn tcx(&self) -> TyCtxt<'gcx, 'gcx> {
self.global_tcx() self.global_tcx()
} }
} }
@ -1759,7 +1759,7 @@ impl<'tcx, T: HasDataLayout> HasDataLayout for LayoutCx<'tcx, T> {
} }
impl<'gcx, 'tcx, T: HasTyCtxt<'gcx>> HasTyCtxt<'gcx> for LayoutCx<'tcx, T> { impl<'gcx, 'tcx, T: HasTyCtxt<'gcx>> HasTyCtxt<'gcx> for LayoutCx<'tcx, T> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'gcx> { fn tcx(&self) -> TyCtxt<'gcx, 'gcx> {
self.tcx.tcx() self.tcx.tcx()
} }
} }

View file

@ -66,7 +66,7 @@ impl ty::layout::HasDataLayout for Builder<'_, '_, '_> {
} }
impl ty::layout::HasTyCtxt<'tcx> for Builder<'_, '_, 'tcx> { impl ty::layout::HasTyCtxt<'tcx> for Builder<'_, '_, 'tcx> {
fn tcx<'a>(&'a self) -> TyCtxt<'tcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
self.cx.tcx self.cx.tcx
} }
} }

View file

@ -838,7 +838,7 @@ impl HasTargetSpec for CodegenCx<'ll, 'tcx> {
} }
impl ty::layout::HasTyCtxt<'tcx> for CodegenCx<'ll, 'tcx> { impl ty::layout::HasTyCtxt<'tcx> for CodegenCx<'ll, 'tcx> {
fn tcx<'a>(&'a self) -> TyCtxt<'tcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
self.tcx self.tcx
} }
} }

View file

@ -203,7 +203,7 @@ impl Printer<'tcx, 'tcx> for SymbolPrinter<'tcx> {
type DynExistential = Self; type DynExistential = Self;
type Const = Self; type Const = Self;
fn tcx(&'a self) -> TyCtxt<'tcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
self.tcx self.tcx
} }

View file

@ -223,7 +223,7 @@ impl Printer<'tcx, 'tcx> for SymbolMangler<'tcx> {
type DynExistential = Self; type DynExistential = Self;
type Const = Self; type Const = Self;
fn tcx<'a>(&'a self) -> TyCtxt<'tcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
self.tcx self.tcx
} }

View file

@ -173,7 +173,7 @@ impl<'mir, 'tcx, M> layout::HasTyCtxt<'tcx> for InterpretCx<'mir, 'tcx, M>
where M: Machine<'mir, 'tcx> where M: Machine<'mir, 'tcx>
{ {
#[inline] #[inline]
fn tcx<'d>(&'d self) -> TyCtxt<'tcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
*self.tcx *self.tcx
} }
} }

View file

@ -23,7 +23,7 @@ impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'tcx> {
type DynExistential = Self; type DynExistential = Self;
type Const = Self; type Const = Self;
fn tcx<'a>(&'a self) -> TyCtxt<'tcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
self.tcx self.tcx
} }

View file

@ -113,7 +113,7 @@ impl<'mir, 'tcx> HasDataLayout for ConstPropagator<'mir, 'tcx> {
impl<'mir, 'tcx> HasTyCtxt<'tcx> for ConstPropagator<'mir, 'tcx> { impl<'mir, 'tcx> HasTyCtxt<'tcx> for ConstPropagator<'mir, 'tcx> {
#[inline] #[inline]
fn tcx<'c>(&'c self) -> TyCtxt<'tcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
self.tcx self.tcx
} }
} }

View file

@ -119,7 +119,7 @@ impl LayoutOf for UnwrapLayoutCx<'tcx> {
} }
impl HasTyCtxt<'tcx> for UnwrapLayoutCx<'tcx> { impl HasTyCtxt<'tcx> for UnwrapLayoutCx<'tcx> {
fn tcx<'a>(&'a self) -> TyCtxt<'tcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
self.tcx self.tcx
} }
} }

View file

@ -171,7 +171,7 @@ impl ItemCtxt<'tcx> {
} }
impl AstConv<'tcx, 'tcx> for ItemCtxt<'tcx> { impl AstConv<'tcx, 'tcx> for ItemCtxt<'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx, 'tcx> { fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
self.tcx self.tcx
} }