remove lifetimes that can be elided (clippy::needless_lifetimes)

This commit is contained in:
Matthias Krüger 2020-03-07 00:56:32 +01:00
parent 23de8275c9
commit 7b1b08cfee
32 changed files with 50 additions and 50 deletions

View File

@ -1427,7 +1427,7 @@ impl<'a, T> CursorMut<'a, T> {
/// `CursorMut`, which means it cannot outlive the `CursorMut` and that the
/// `CursorMut` is frozen for the lifetime of the `Cursor`.
#[unstable(feature = "linked_list_cursors", issue = "58533")]
pub fn as_cursor<'cm>(&'cm self) -> Cursor<'cm, T> {
pub fn as_cursor(&self) -> Cursor<'_, T> {
Cursor { list: self.list, current: self.current, index: self.index }
}
}

View File

@ -179,7 +179,7 @@ macro_rules! define_dep_nodes {
$(
#[inline(always)]
#[allow(unreachable_code, non_snake_case)]
pub fn $variant<'tcx>(_tcx: TyCtxt<'tcx>, $(arg: $tuple_arg_ty)*) -> DepNode {
pub fn $variant(_tcx: TyCtxt<'_>, $(arg: $tuple_arg_ty)*) -> DepNode {
// tuple args
$({
erase!($tuple_arg_ty);

View File

@ -340,7 +340,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
/// deep walking so that we walk nested items in the context of
/// their outer items.
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
panic!("`visit_nested_xxx` must be manually implemented in this visitor");
}

View File

@ -135,7 +135,7 @@ impl<'a, 'hir> HirIdValidator<'a, 'hir> {
impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
type Map = Map<'hir>;
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, Self::Map> {
fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> {
intravisit::NestedVisitorMap::OnlyBodies(self.hir_map)
}

View File

@ -403,7 +403,7 @@ pub enum ClearCrossCrate<T> {
}
impl<T> ClearCrossCrate<T> {
pub fn as_ref(&'a self) -> ClearCrossCrate<&'a T> {
pub fn as_ref(&self) -> ClearCrossCrate<&T> {
match self {
ClearCrossCrate::Clear => ClearCrossCrate::Clear,
ClearCrossCrate::Set(v) => ClearCrossCrate::Set(v),
@ -2503,7 +2503,7 @@ impl UserTypeProjection {
pub(crate) fn variant(
mut self,
adt_def: &'tcx AdtDef,
adt_def: &AdtDef,
variant_index: VariantIdx,
field: Field,
) -> Self {

View File

@ -320,7 +320,7 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
}
}
pub fn val_ty(v: &'ll Value) -> &'ll Type {
pub fn val_ty(v: &Value) -> &Type {
unsafe { llvm::LLVMTypeOf(v) }
}
@ -342,6 +342,6 @@ fn hi_lo_to_u128(lo: u64, hi: u64) -> u128 {
((hi as u128) << 64) | (lo as u128)
}
fn try_as_const_integral(v: &'ll Value) -> Option<&'ll ConstantInt> {
fn try_as_const_integral(v: &Value) -> Option<&ConstantInt> {
unsafe { llvm::LLVMIsAConstantInt(v) }
}

View File

@ -185,12 +185,12 @@ impl Drop for SectionIter<'a> {
}
}
pub fn mk_section_iter(llof: &'a ffi::ObjectFile) -> SectionIter<'a> {
pub fn mk_section_iter(llof: &ffi::ObjectFile) -> SectionIter<'_> {
unsafe { SectionIter { llsi: LLVMGetSections(llof) } }
}
/// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
pub fn get_param(llfn: &'a Value, index: c_uint) -> &'a Value {
pub fn get_param(llfn: &Value, index: c_uint) -> &Value {
unsafe {
assert!(
index < LLVMCountParams(llfn),
@ -203,7 +203,7 @@ pub fn get_param(llfn: &'a Value, index: c_uint) -> &'a Value {
}
/// Safe wrapper for `LLVMGetValueName2` into a byte slice
pub fn get_value_name(value: &'a Value) -> &'a [u8] {
pub fn get_value_name(value: &Value) -> &[u8] {
unsafe {
let mut len = 0;
let data = LLVMGetValueName2(value, &mut len);

View File

@ -240,7 +240,7 @@ impl Type {
unsafe { llvm::LLVMIntTypeInContext(llcx, num_bits as c_uint) }
}
pub fn i8p_llcx(llcx: &'ll llvm::Context) -> &'ll Type {
pub fn i8p_llcx(llcx: &llvm::Context) -> &Type {
Type::i8_llcx(llcx).ptr_to()
}

View File

@ -97,7 +97,7 @@ impl<N: Idx, S: Idx> GraphSuccessors<'graph> for Sccs<N, S> {
}
impl<N: Idx, S: Idx> WithSuccessors for Sccs<N, S> {
fn successors<'graph>(&'graph self, node: S) -> <Self as GraphSuccessors<'graph>>::Iter {
fn successors(&self, node: S) -> <Self as GraphSuccessors<'_>>::Iter {
self.successors(node).iter().cloned()
}
}

View File

@ -101,7 +101,7 @@ impl<N: Idx> GraphSuccessors<'graph> for VecGraph<N> {
}
impl<N: Idx> WithSuccessors for VecGraph<N> {
fn successors<'graph>(&'graph self, node: N) -> <Self as GraphSuccessors<'graph>>::Iter {
fn successors(&self, node: N) -> <Self as GraphSuccessors<'_>>::Iter {
self.successors(node).iter().cloned()
}
}

View File

@ -96,7 +96,7 @@ trait PrinterSupport: pprust::PpAnn {
///
/// (Rust does not yet support upcasting from a trait object to
/// an object for one of its super-traits.)
fn pp_ann<'a>(&'a self) -> &'a dyn pprust::PpAnn;
fn pp_ann(&self) -> &dyn pprust::PpAnn;
}
trait HirPrinterSupport<'hir>: pprust_hir::PpAnn {
@ -106,13 +106,13 @@ trait HirPrinterSupport<'hir>: pprust_hir::PpAnn {
/// Provides a uniform interface for re-extracting a reference to an
/// `hir_map::Map` from a value that now owns it.
fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'hir>>;
fn hir_map(&self) -> Option<&hir_map::Map<'hir>>;
/// Produces the pretty-print annotation object.
///
/// (Rust does not yet support upcasting from a trait object to
/// an object for one of its super-traits.)
fn pp_ann<'a>(&'a self) -> &'a dyn pprust_hir::PpAnn;
fn pp_ann(&self) -> &dyn pprust_hir::PpAnn;
/// Computes an user-readable representation of a path, if possible.
fn node_path(&self, id: hir::HirId) -> Option<String> {
@ -132,7 +132,7 @@ impl<'hir> PrinterSupport for NoAnn<'hir> {
self.sess
}
fn pp_ann<'a>(&'a self) -> &'a dyn pprust::PpAnn {
fn pp_ann(&self) -> &dyn pprust::PpAnn {
self
}
}
@ -142,11 +142,11 @@ impl<'hir> HirPrinterSupport<'hir> for NoAnn<'hir> {
self.sess
}
fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'hir>> {
fn hir_map(&self) -> Option<&hir_map::Map<'hir>> {
self.tcx.map(|tcx| *tcx.hir())
}
fn pp_ann<'a>(&'a self) -> &'a dyn pprust_hir::PpAnn {
fn pp_ann(&self) -> &dyn pprust_hir::PpAnn {
self
}
}
@ -170,7 +170,7 @@ impl<'hir> PrinterSupport for IdentifiedAnnotation<'hir> {
self.sess
}
fn pp_ann<'a>(&'a self) -> &'a dyn pprust::PpAnn {
fn pp_ann(&self) -> &dyn pprust::PpAnn {
self
}
}
@ -216,11 +216,11 @@ impl<'hir> HirPrinterSupport<'hir> for IdentifiedAnnotation<'hir> {
self.sess
}
fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'hir>> {
fn hir_map(&self) -> Option<&hir_map::Map<'hir>> {
self.tcx.map(|tcx| *tcx.hir())
}
fn pp_ann<'a>(&'a self) -> &'a dyn pprust_hir::PpAnn {
fn pp_ann(&self) -> &dyn pprust_hir::PpAnn {
self
}
}
@ -315,11 +315,11 @@ impl<'b, 'tcx> HirPrinterSupport<'tcx> for TypedAnnotation<'b, 'tcx> {
&self.tcx.sess
}
fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'tcx>> {
fn hir_map(&self) -> Option<&hir_map::Map<'tcx>> {
Some(&self.tcx.hir())
}
fn pp_ann<'a>(&'a self) -> &'a dyn pprust_hir::PpAnn {
fn pp_ann(&self) -> &dyn pprust_hir::PpAnn {
self
}

View File

@ -284,7 +284,7 @@ pub trait Visitor<'v>: Sized {
/// If you use this, you probably don't want to process the
/// contents of nested item-like things, since the outer loop will
/// visit them as well.
fn as_deep_visitor<'s>(&'s mut self) -> DeepVisitor<'s, Self> {
fn as_deep_visitor(&mut self) -> DeepVisitor<'_, Self> {
DeepVisitor::new(self)
}

View File

@ -162,7 +162,7 @@ impl IfThisChanged<'tcx> {
impl Visitor<'tcx> for IfThisChanged<'tcx> {
type Map = Map<'tcx>;
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir())
}

View File

@ -548,7 +548,7 @@ impl FindAllAttrs<'tcx> {
impl intravisit::Visitor<'tcx> for FindAllAttrs<'tcx> {
type Map = Map<'tcx>;
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, Self::Map> {
fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> {
intravisit::NestedVisitorMap::All(&self.tcx.hir())
}

View File

@ -69,7 +69,7 @@ impl<'a, 'tcx> FindLocalByTypeVisitor<'a, 'tcx> {
impl<'a, 'tcx> Visitor<'tcx> for FindLocalByTypeVisitor<'a, 'tcx> {
type Map = Map<'tcx>;
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::OnlyBodies(&self.hir_map)
}

View File

@ -93,7 +93,7 @@ struct FindNestedTypeVisitor<'tcx> {
impl Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
type Map = Map<'tcx>;
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir())
}

View File

@ -451,7 +451,7 @@ fn def_id_is_local(def_id: DefId, in_crate: InCrate) -> bool {
}
}
fn ty_is_non_local_constructor<'tcx>(ty: Ty<'tcx>, in_crate: InCrate) -> Option<Ty<'tcx>> {
fn ty_is_non_local_constructor(ty: Ty<'_>, in_crate: InCrate) -> Option<Ty<'_>> {
debug!("ty_is_non_local_constructor({:?})", ty);
match ty.kind {

View File

@ -33,7 +33,7 @@ use std::slice;
/// Extract the `LintStore` from the query context.
/// This function exists because we've erased `LintStore` as `dyn Any` in the context.
crate fn unerased_lint_store<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx LintStore {
crate fn unerased_lint_store(tcx: TyCtxt<'_>) -> &LintStore {
let store: &dyn Any = &*tcx.lint_store;
store.downcast_ref().unwrap()
}
@ -99,7 +99,7 @@ impl<'a, 'tcx, T: LateLintPass<'a, 'tcx>> hir_visit::Visitor<'tcx>
/// Because lints are scoped lexically, we want to walk nested
/// items in the context of the outer item, so enable
/// deep-walking.
fn nested_visit_map<'this>(&'this mut self) -> hir_visit::NestedVisitorMap<'this, Self::Map> {
fn nested_visit_map(&mut self) -> hir_visit::NestedVisitorMap<'_, Self::Map> {
hir_visit::NestedVisitorMap::All(&self.context.tcx.hir())
}

View File

@ -438,7 +438,7 @@ impl LintLevelMapBuilder<'_, '_> {
impl<'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'_, 'tcx> {
type Map = Map<'tcx>;
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, Self::Map> {
fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> {
intravisit::NestedVisitorMap::All(&self.tcx.hir())
}

View File

@ -43,7 +43,7 @@ pub(crate) fn const_field<'tcx>(
op_to_const(&ecx, field)
}
pub(crate) fn const_caller_location<'tcx>(
pub(crate) fn const_caller_location(
tcx: TyCtxt<'tcx>,
(file, line, col): (Symbol, u32, u32),
) -> ConstValue<'tcx> {

View File

@ -34,7 +34,7 @@ fn is_stable(place: PlaceRef<'_>) -> bool {
}
/// Determine whether this type may be a reference (or box), and thus needs retagging.
fn may_be_reference<'tcx>(ty: Ty<'tcx>) -> bool {
fn may_be_reference(ty: Ty<'tcx>) -> bool {
match ty.kind {
// Primitive types that are not references
ty::Bool

View File

@ -453,7 +453,7 @@ struct UnusedUnsafeVisitor<'a> {
impl<'a, 'tcx> intravisit::Visitor<'tcx> for UnusedUnsafeVisitor<'a> {
type Map = Map<'tcx>;
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, Self::Map> {
fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> {
intravisit::NestedVisitorMap::None
}

View File

@ -87,7 +87,7 @@ fn mir_keys(tcx: TyCtxt<'_>, krate: CrateNum) -> &DefIdSet {
intravisit::walk_struct_def(self, v)
}
type Map = Map<'tcx>;
fn nested_visit_map<'b>(&'b mut self) -> NestedVisitorMap<'b, Self::Map> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}

View File

@ -271,11 +271,11 @@ pub fn stream_to_parser<'a>(
/// The main usage of this function is outside of rustc, for those who uses
/// librustc_ast as a library. Please do not remove this function while refactoring
/// just because it is not used in rustc codebase!
pub fn stream_to_parser_with_base_dir<'a>(
sess: &'a ParseSess,
pub fn stream_to_parser_with_base_dir(
sess: &ParseSess,
stream: TokenStream,
base_dir: Directory,
) -> Parser<'a> {
) -> Parser<'_> {
Parser::new(sess, stream, Some(base_dir), true, false, None)
}

View File

@ -418,7 +418,7 @@ impl CheckAttrVisitor<'tcx> {
impl Visitor<'tcx> for CheckAttrVisitor<'tcx> {
type Map = Map<'tcx>;
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir())
}

View File

@ -143,7 +143,7 @@ impl LanguageItemCollector<'tcx> {
}
/// Traverses and collects all the lang items in all crates.
fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> LanguageItems {
fn collect(tcx: TyCtxt<'_>) -> LanguageItems {
// Initialize the collector.
let mut collector = LanguageItemCollector::new(tcx);

View File

@ -46,7 +46,7 @@ struct LocalCollector {
impl Visitor<'tcx> for LocalCollector {
type Map = Map<'tcx>;
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
@ -75,7 +75,7 @@ impl CaptureCollector<'_, '_> {
impl Visitor<'tcx> for CaptureCollector<'a, 'tcx> {
type Map = Map<'tcx>;
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}

View File

@ -603,7 +603,7 @@ impl ClauseDumper<'tcx> {
impl Visitor<'tcx> for ClauseDumper<'tcx> {
type Map = Map<'tcx>;
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> {
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir())
}

View File

@ -210,7 +210,7 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] {
}
}
fn associated_items<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ty::AssociatedItems {
fn associated_items(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::AssociatedItems {
let items = tcx.associated_item_def_ids(def_id).iter().map(|did| tcx.associated_item(*did));
tcx.arena.alloc(ty::AssociatedItems::new(items))
}

View File

@ -111,7 +111,7 @@ fn identity(_: Ty<'_>) -> Vec<Adjustment<'_>> {
vec![]
}
fn simple<'tcx>(kind: Adjust<'tcx>) -> impl FnOnce(Ty<'tcx>) -> Vec<Adjustment<'tcx>> {
fn simple(kind: Adjust<'tcx>) -> impl FnOnce(Ty<'tcx>) -> Vec<Adjustment<'tcx>> {
move |target| vec![Adjustment { kind, target }]
}

View File

@ -860,7 +860,7 @@ enum Op {
}
/// Dereferences a single level of immutable referencing.
fn deref_ty_if_possible<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> {
fn deref_ty_if_possible(ty: Ty<'tcx>) -> Ty<'tcx> {
match ty.kind {
ty::Ref(_, ty, hir::Mutability::Not) => ty,
_ => ty,

View File

@ -322,7 +322,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: DefId) {
}
}
pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedInfo {
pub fn coerce_unsized_info(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedInfo {
debug!("compute_coerce_unsized_info(impl_did={:?})", impl_did);
let coerce_unsized_trait = tcx.lang_items().coerce_unsized_trait().unwrap();