X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc_mir%2Finterpret%2Fintrinsics%2Ftype_name.rs;h=a44a20adbca0e6b2700533361507fa24b5f152a7;hb=fff08cb04389497d254fb40948674cbbee402908;hp=1270b35ebb9555a97a36a4c328740a25f892d863;hpb=17393b26b961937cda562a2f4bb5e80b2ce49b1e;p=rust.git diff --git a/src/librustc_mir/interpret/intrinsics/type_name.rs b/src/librustc_mir/interpret/intrinsics/type_name.rs index 1270b35ebb9..a44a20adbca 100644 --- a/src/librustc_mir/interpret/intrinsics/type_name.rs +++ b/src/librustc_mir/interpret/intrinsics/type_name.rs @@ -9,12 +9,12 @@ use std::fmt::Write; use rustc::mir::interpret::{Allocation, ConstValue}; -struct AbsolutePathPrinter<'a, 'tcx> { - tcx: TyCtxt<'a, 'tcx, 'tcx>, +struct AbsolutePathPrinter<'tcx> { + tcx: TyCtxt<'tcx, 'tcx>, path: String, } -impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'_, 'tcx> { +impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'tcx> { type Error = std::fmt::Error; type Path = Self; @@ -23,7 +23,7 @@ impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'_, 'tcx> { type DynExistential = Self; type Const = Self; - fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'tcx, 'tcx> { self.tcx } @@ -167,7 +167,7 @@ fn path_generic_args( } } } -impl PrettyPrinter<'tcx, 'tcx> for AbsolutePathPrinter<'_, 'tcx> { +impl PrettyPrinter<'tcx, 'tcx> for AbsolutePathPrinter<'tcx> { fn region_should_not_be_omitted( &self, _region: ty::Region<'_>, @@ -204,7 +204,7 @@ fn generic_delimiters( } } -impl Write for AbsolutePathPrinter<'_, '_> { +impl Write for AbsolutePathPrinter<'_> { fn write_str(&mut self, s: &str) -> std::fmt::Result { Ok(self.path.push_str(s)) } @@ -212,7 +212,7 @@ fn write_str(&mut self, s: &str) -> std::fmt::Result { /// Produces an absolute path representation of the given type. See also the documentation on /// `std::any::type_name` -pub fn type_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> &'tcx ty::Const<'tcx> { +pub fn type_name<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>) -> &'tcx ty::Const<'tcx> { let alloc = alloc_type_name(tcx, ty); tcx.mk_const(ty::Const { val: ConstValue::Slice { @@ -225,10 +225,7 @@ pub fn type_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> &'tcx t } /// Directly returns an `Allocation` containing an absolute path representation of the given type. -pub(super) fn alloc_type_name<'a, 'tcx>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, - ty: Ty<'tcx> -) -> &'tcx Allocation { +pub(super) fn alloc_type_name<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>) -> &'tcx Allocation { let path = AbsolutePathPrinter { tcx, path: String::new() }.print_type(ty).unwrap().path; let alloc = Allocation::from_byte_aligned_bytes(path.into_bytes()); tcx.intern_const_alloc(alloc)