Skip to content

Commit

Permalink
remove lifetimes that can be elided (clippy::needless_lifetimes)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskrgr committed Mar 12, 2020
1 parent 23de827 commit 7b1b08c
Show file tree
Hide file tree
Showing 32 changed files with 50 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/liballoc/collections/linked_list.rs
Expand Up @@ -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 }
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/dep_graph/dep_node.rs
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/collector.rs
Expand Up @@ -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");
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/hir_id_validator.rs
Expand Up @@ -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)
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/mir/mod.rs
Expand Up @@ -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),
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/common.rs
Expand Up @@ -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) }
}

Expand All @@ -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) }
}
6 changes: 3 additions & 3 deletions src/librustc_codegen_llvm/llvm/mod.rs
Expand Up @@ -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),
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/type_.rs
Expand Up @@ -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()
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_data_structures/graph/scc/mod.rs
Expand Up @@ -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()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_data_structures/graph/vec_graph/mod.rs
Expand Up @@ -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()
}
}
22 changes: 11 additions & 11 deletions src/librustc_driver/pretty.rs
Expand Up @@ -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 {
Expand All @@ -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> {
Expand All @@ -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
}
}
Expand All @@ -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
}
}
Expand All @@ -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
}
}
Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_hir/intravisit.rs
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_incremental/assert_dep_graph.rs
Expand Up @@ -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())
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_incremental/persist/dirty_clean.rs
Expand Up @@ -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())
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/infer/error_reporting/need_type_info.rs
Expand Up @@ -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)
}

Expand Down
Expand Up @@ -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())
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/traits/coherence.rs
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_lint/late.rs
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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())
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/levels.rs
Expand Up @@ -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())
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/const_eval/mod.rs
Expand Up @@ -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> {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/add_retag.rs
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/check_unsafety.rs
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/mod.rs
Expand Up @@ -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
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_parse/lib.rs
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_passes/check_attr.rs
Expand Up @@ -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())
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_passes/lang_items.rs
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_passes/upvars.rs
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_traits/lowering/mod.rs
Expand Up @@ -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())
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_ty/ty.rs
Expand Up @@ -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))
}
Expand Down

0 comments on commit 7b1b08c

Please sign in to comment.