Skip to content

Commit

Permalink
rustc: remove some unnecessary lifetimes in -> TyCtxt methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Jun 12, 2019
1 parent 17cdd35 commit 21ac960
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/librustc/lint/context.rs
Expand Up @@ -793,7 +793,7 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
type DynExistential = ();
type Const = ();

fn tcx<'a>(&'a self) -> TyCtxt<'tcx, 'tcx> {
fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
self.tcx
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/interpret/mod.rs
Expand Up @@ -144,7 +144,7 @@ pub struct AllocDecodingSession<'s> {
impl<'s> AllocDecodingSession<'s> {

// 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)
-> Result<AllocId, D::Error>
where D: TyDecoder<'tcx>,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/query/normalize_erasing_regions.rs
Expand Up @@ -68,7 +68,7 @@ struct 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
}

Expand Down
39 changes: 13 additions & 26 deletions src/librustc/ty/codec.rs
Expand Up @@ -131,38 +131,34 @@ pub trait TyDecoder<'tcx>: Decoder {
}

#[inline]
pub fn decode_arena_allocable<'a, 'tcx, D, T: ArenaAllocatable + Decodable>(
pub fn decode_arena_allocable<D, T: ArenaAllocatable + Decodable>(
decoder: &mut D
) -> Result<&'tcx T, D::Error>
where D: TyDecoder<'tcx>,
'tcx: 'a,
{
Ok(decoder.tcx().arena.alloc(Decodable::decode(decoder)?))
}

#[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
) -> Result<&'tcx [T], D::Error>
where D: TyDecoder<'tcx>,
'tcx: 'a,
{
Ok(decoder.tcx().arena.alloc_from_iter(<Vec<T> as Decodable>::decode(decoder)?))
}

#[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>,
'tcx: 'a,
{
let cnum = CrateNum::from_u32(u32::decode(decoder)?);
Ok(decoder.map_encoded_cnum_to_current(cnum))
}

#[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>,
'tcx: 'a,
{
// Handle shorthands first, if we have an usize > 0x80.
if decoder.positioned_at_shorthand() {
Expand All @@ -180,10 +176,9 @@ pub fn decode_ty<'a, 'tcx, D>(decoder: &mut D) -> Result<Ty<'tcx>, D::Error>
}

#[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>
where D: TyDecoder<'tcx>,
'tcx: 'a,
{
Ok(ty::GenericPredicates {
parent: Decodable::decode(decoder)?,
Expand All @@ -205,59 +200,53 @@ pub fn decode_predicates<'a, 'tcx, D>(decoder: &mut D)
}

#[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>,
'tcx: 'a,
{
let len = decoder.read_usize()?;
let tcx = decoder.tcx();
Ok(tcx.mk_substs((0..len).map(|_| Decodable::decode(decoder)))?)
}

#[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>,
'tcx: 'a,
{
Ok(decoder.tcx().mk_region(Decodable::decode(decoder)?))
}

#[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>
where D: TyDecoder<'tcx>,
'tcx: 'a,
{
let len = decoder.read_usize()?;
Ok(decoder.tcx().mk_type_list((0..len).map(|_| Decodable::decode(decoder)))?)
}

#[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>
where D: TyDecoder<'tcx>,
'tcx: 'a,
{
let def_id = DefId::decode(decoder)?;
Ok(decoder.tcx().adt_def(def_id))
}

#[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>
where D: TyDecoder<'tcx>,
'tcx: 'a,
{
let len = decoder.read_usize()?;
Ok(decoder.tcx()
.mk_existential_predicates((0..len).map(|_| Decodable::decode(decoder)))?)
}

#[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>
where D: TyDecoder<'tcx>,
'tcx: 'a,
{
let len = decoder.read_usize()?;
let interned: Result<Vec<CanonicalVarInfo>, _> = (0..len).map(|_| Decodable::decode(decoder))
Expand All @@ -267,19 +256,17 @@ pub fn decode_canonical_var_infos<'a, 'tcx, D>(decoder: &mut D)
}

#[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>
where D: TyDecoder<'tcx>,
'tcx: 'a,
{
Ok(decoder.tcx().mk_const(Decodable::decode(decoder)?))
}

#[inline]
pub fn decode_allocation<'a, 'tcx, D>(decoder: &mut D)
pub fn decode_allocation<D>(decoder: &mut D)
-> Result<&'tcx Allocation, D::Error>
where D: TyDecoder<'tcx>,
'tcx: 'a,
{
Ok(decoder.tcx().intern_const_alloc(Decodable::decode(decoder)?))
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/ty/layout.rs
Expand Up @@ -1727,7 +1727,7 @@ impl<'tcx> SizeSkeleton<'tcx> {
}

pub trait HasTyCtxt<'tcx>: HasDataLayout {
fn tcx<'a>(&'a self) -> TyCtxt<'tcx, 'tcx>;
fn tcx(&self) -> TyCtxt<'tcx, 'tcx>;
}

pub trait HasParamEnv<'tcx> {
Expand All @@ -1741,7 +1741,7 @@ impl<'gcx, 'tcx> HasDataLayout 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()
}
}
Expand All @@ -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> {
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'gcx> {
fn tcx(&self) -> TyCtxt<'gcx, 'gcx> {
self.tcx.tcx()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/builder.rs
Expand Up @@ -66,7 +66,7 @@ impl ty::layout::HasDataLayout for Builder<'_, '_, '_> {
}

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
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/context.rs
Expand Up @@ -838,7 +838,7 @@ impl HasTargetSpec 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
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_utils/symbol_names/legacy.rs
Expand Up @@ -203,7 +203,7 @@ impl Printer<'tcx, 'tcx> for SymbolPrinter<'tcx> {
type DynExistential = Self;
type Const = Self;

fn tcx(&'a self) -> TyCtxt<'tcx, 'tcx> {
fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
self.tcx
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_utils/symbol_names/v0.rs
Expand Up @@ -223,7 +223,7 @@ impl Printer<'tcx, 'tcx> for SymbolMangler<'tcx> {
type DynExistential = Self;
type Const = Self;

fn tcx<'a>(&'a self) -> TyCtxt<'tcx, 'tcx> {
fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
self.tcx
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/eval_context.rs
Expand Up @@ -173,7 +173,7 @@ impl<'mir, 'tcx, M> layout::HasTyCtxt<'tcx> for InterpretCx<'mir, 'tcx, M>
where M: Machine<'mir, 'tcx>
{
#[inline]
fn tcx<'d>(&'d self) -> TyCtxt<'tcx, 'tcx> {
fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
*self.tcx
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/intrinsics/type_name.rs
Expand Up @@ -23,7 +23,7 @@ impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'tcx> {
type DynExistential = Self;
type Const = Self;

fn tcx<'a>(&'a self) -> TyCtxt<'tcx, 'tcx> {
fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
self.tcx
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/const_prop.rs
Expand Up @@ -113,7 +113,7 @@ impl<'mir, 'tcx> HasDataLayout for ConstPropagator<'mir, 'tcx> {

impl<'mir, 'tcx> HasTyCtxt<'tcx> for ConstPropagator<'mir, 'tcx> {
#[inline]
fn tcx<'c>(&'c self) -> TyCtxt<'tcx, 'tcx> {
fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
self.tcx
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_passes/layout_test.rs
Expand Up @@ -119,7 +119,7 @@ impl LayoutOf 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
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/collect.rs
Expand Up @@ -171,7 +171,7 @@ impl 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
}

Expand Down

0 comments on commit 21ac960

Please sign in to comment.