Skip to content

Commit

Permalink
Auto merge of #4221 - lzutao:redundant-lifetime, r=matthiaskrgr
Browse files Browse the repository at this point in the history
Fix warnings about unnecessary lifetime bounds

Rustup #61172

changelog: none
  • Loading branch information
bors committed Jun 19, 2019
2 parents 149a988 + 4fa498a commit 7db5d0e
Show file tree
Hide file tree
Showing 34 changed files with 83 additions and 87 deletions.
4 changes: 2 additions & 2 deletions clippy_lints/src/assign_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,13 @@ fn is_commutative(op: hir::BinOpKind) -> bool {
}
}

struct ExprVisitor<'a, 'tcx: 'a> {
struct ExprVisitor<'a, 'tcx> {
assignee: &'a hir::Expr,
counter: u8,
cx: &'a LateContext<'a, 'tcx>,
}

impl<'a, 'tcx: 'a> Visitor<'tcx> for ExprVisitor<'a, 'tcx> {
impl<'a, 'tcx> Visitor<'tcx> for ExprVisitor<'a, 'tcx> {
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
if SpanlessEq::new(self.cx).ignore_fn().eq_expr(self.assignee, expr) {
self.counter += 1;
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/block_in_if_condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ declare_clippy_lint! {

declare_lint_pass!(BlockInIfCondition => [BLOCK_IN_IF_CONDITION_EXPR, BLOCK_IN_IF_CONDITION_STMT]);

struct ExVisitor<'a, 'tcx: 'a> {
struct ExVisitor<'a, 'tcx> {
found_block: Option<&'tcx Expr>,
cx: &'a LateContext<'a, 'tcx>,
}

impl<'a, 'tcx: 'a> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
impl<'a, 'tcx> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
fn visit_expr(&mut self, expr: &'tcx Expr) {
if let ExprKind::Closure(_, _, eid, _, _) = expr.node {
let body = self.cx.tcx.hir().body(eid);
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/booleans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonminimalBool {
}
}

struct NonminimalBoolVisitor<'a, 'tcx: 'a> {
struct NonminimalBoolVisitor<'a, 'tcx> {
cx: &'a LateContext<'a, 'tcx>,
}

use quine_mc_cluskey::Bool;
struct Hir2Qmm<'a, 'tcx: 'a, 'v> {
struct Hir2Qmm<'a, 'tcx, 'v> {
terminals: Vec<&'v Expr>,
cx: &'a LateContext<'a, 'tcx>,
}
Expand Down Expand Up @@ -155,7 +155,7 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> {
}
}

struct SuggestContext<'a, 'tcx: 'a, 'v> {
struct SuggestContext<'a, 'tcx, 'v> {
terminals: &'v [&'v Expr],
cx: &'a LateContext<'a, 'tcx>,
output: String,
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/cognitive_complexity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl CognitiveComplexity {
impl_lint_pass!(CognitiveComplexity => [COGNITIVE_COMPLEXITY]);

impl CognitiveComplexity {
fn check<'a, 'tcx: 'a>(&mut self, cx: &'a LateContext<'a, 'tcx>, body: &'tcx Body, span: Span) {
fn check<'a, 'tcx>(&mut self, cx: &'a LateContext<'a, 'tcx>, body: &'tcx Body, span: Span) {
if in_macro_or_desugar(span) {
return;
}
Expand Down Expand Up @@ -132,7 +132,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CognitiveComplexity {
}
}

struct CCHelper<'a, 'tcx: 'a> {
struct CCHelper<'a, 'tcx> {
match_arms: u64,
divergence: u64,
returns: u64,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ pub fn constant_context<'c, 'cc>(
}
}

pub struct ConstEvalLateContext<'a, 'tcx: 'a> {
pub struct ConstEvalLateContext<'a, 'tcx> {
lcx: &'a LateContext<'a, 'tcx>,
tables: &'a ty::TypeckTables<'tcx>,
param_env: ty::ParamEnv<'tcx>,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ fn check_cond<'a, 'tcx, 'b>(
None
}

struct InsertVisitor<'a, 'tcx: 'a, 'b> {
struct InsertVisitor<'a, 'tcx, 'b> {
cx: &'a LateContext<'a, 'tcx>,
span: Span,
ty: &'static str,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn is_non_trait_box(ty: Ty<'_>) -> bool {
ty.is_box() && !ty.boxed_ty().is_trait()
}

struct EscapeDelegate<'a, 'tcx: 'a> {
struct EscapeDelegate<'a, 'tcx> {
cx: &'a LateContext<'a, 'tcx>,
set: HirIdSet,
too_large_for_stack: u64,
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/eval_order_dependence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EvalOrderDependence {
}
}

struct DivergenceVisitor<'a, 'tcx: 'a> {
struct DivergenceVisitor<'a, 'tcx> {
cx: &'a LateContext<'a, 'tcx>,
}

Expand Down Expand Up @@ -272,7 +272,7 @@ fn check_stmt<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, stmt: &'tcx Stmt) -> St
}

/// A visitor that looks for reads from a variable.
struct ReadVisitor<'a, 'tcx: 'a> {
struct ReadVisitor<'a, 'tcx> {
cx: &'a LateContext<'a, 'tcx>,
/// The ID of the variable we're looking for.
var: HirId,
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/fallible_impl_from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_it
use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc::hir::*;

struct FindPanicUnwrap<'a, 'tcx: 'a> {
struct FindPanicUnwrap<'a, 'tcx> {
lcx: &'a LateContext<'a, 'tcx>,
tables: &'tcx ty::TypeckTables<'tcx>,
result: Vec<Span>,
}

impl<'a, 'tcx: 'a> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> {
impl<'a, 'tcx> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> {
fn visit_expr(&mut self, expr: &'tcx Expr) {
// check for `begin_panic`
if_chain! {
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ fn raw_ptr_arg(arg: &hir::Arg, ty: &hir::Ty) -> Option<hir::HirId> {
}
}

struct DerefVisitor<'a, 'tcx: 'a> {
struct DerefVisitor<'a, 'tcx> {
cx: &'a LateContext<'a, 'tcx>,
ptrs: FxHashSet<hir::HirId>,
tables: &'a ty::TypeckTables<'tcx>,
Expand Down Expand Up @@ -330,7 +330,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> {
}
}

impl<'a, 'tcx: 'a> DerefVisitor<'a, 'tcx> {
impl<'a, 'tcx> DerefVisitor<'a, 'tcx> {
fn check_arg(&self, ptr: &hir::Expr) {
if let hir::ExprKind::Path(ref qpath) = ptr.node {
if let Res::Local(id) = self.cx.tables.qpath_res(qpath, ptr.hir_id) {
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/let_if_seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
}
}

struct UsedVisitor<'a, 'tcx: 'a> {
struct UsedVisitor<'a, 'tcx> {
cx: &'a LateContext<'a, 'tcx>,
id: hir::HirId,
used: bool,
Expand Down Expand Up @@ -194,7 +194,7 @@ fn check_assign<'a, 'tcx>(
None
}

fn used_in_expr<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, id: hir::HirId, expr: &'tcx hir::Expr) -> bool {
fn used_in_expr<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, id: hir::HirId, expr: &'tcx hir::Expr) -> bool {
let mut v = UsedVisitor { cx, id, used: false };
hir::intravisit::walk_expr(&mut v, expr);
v.used
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ fn check_fn_inner<'a, 'tcx>(
report_extra_lifetimes(cx, decl, generics);
}

fn could_use_elision<'a, 'tcx: 'a>(
fn could_use_elision<'a, 'tcx>(
cx: &LateContext<'a, 'tcx>,
func: &'tcx FnDecl,
body: Option<BodyId>,
Expand Down Expand Up @@ -264,7 +264,7 @@ fn unique_lifetimes(lts: &[RefLt]) -> usize {
}

/// A visitor usable for `rustc_front::visit::walk_ty()`.
struct RefVisitor<'a, 'tcx: 'a> {
struct RefVisitor<'a, 'tcx> {
cx: &'a LateContext<'a, 'tcx>,
lts: Vec<RefLt>,
abort: bool,
Expand Down Expand Up @@ -377,7 +377,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {

/// Are any lifetimes mentioned in the `where` clause? If so, we don't try to
/// reason about elision.
fn has_where_lifetimes<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, where_clause: &'tcx WhereClause) -> bool {
fn has_where_lifetimes<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, where_clause: &'tcx WhereClause) -> bool {
for predicate in &where_clause.predicates {
match *predicate {
WherePredicate::RegionPredicate(..) => return true,
Expand Down Expand Up @@ -445,7 +445,7 @@ impl<'tcx> Visitor<'tcx> for LifetimeChecker {
}
}

fn report_extra_lifetimes<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, func: &'tcx FnDecl, generics: &'tcx Generics) {
fn report_extra_lifetimes<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, func: &'tcx FnDecl, generics: &'tcx Generics) {
let hs = generics
.params
.iter()
Expand Down
18 changes: 9 additions & 9 deletions clippy_lints/src/loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1723,13 +1723,13 @@ impl<'tcx> Visitor<'tcx> for UsedVisitor {
}
}

struct LocalUsedVisitor<'a, 'tcx: 'a> {
struct LocalUsedVisitor<'a, 'tcx> {
cx: &'a LateContext<'a, 'tcx>,
local: HirId,
used: bool,
}

impl<'a, 'tcx: 'a> Visitor<'tcx> for LocalUsedVisitor<'a, 'tcx> {
impl<'a, 'tcx> Visitor<'tcx> for LocalUsedVisitor<'a, 'tcx> {
fn visit_expr(&mut self, expr: &'tcx Expr) {
if same_var(self.cx, expr, self.local) {
self.used = true;
Expand All @@ -1743,7 +1743,7 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for LocalUsedVisitor<'a, 'tcx> {
}
}

struct VarVisitor<'a, 'tcx: 'a> {
struct VarVisitor<'a, 'tcx> {
/// context reference
cx: &'a LateContext<'a, 'tcx>,
/// var name to look for as index
Expand Down Expand Up @@ -1914,7 +1914,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
}
}

fn is_used_inside<'a, 'tcx: 'a>(cx: &'a LateContext<'a, 'tcx>, expr: &'tcx Expr, container: &'tcx Expr) -> bool {
fn is_used_inside<'a, 'tcx>(cx: &'a LateContext<'a, 'tcx>, expr: &'tcx Expr, container: &'tcx Expr) -> bool {
let def_id = match var_def_id(cx, expr) {
Some(id) => id,
None => return false,
Expand All @@ -1927,7 +1927,7 @@ fn is_used_inside<'a, 'tcx: 'a>(cx: &'a LateContext<'a, 'tcx>, expr: &'tcx Expr,
false
}

fn is_iterator_used_after_while_let<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, iter_expr: &'tcx Expr) -> bool {
fn is_iterator_used_after_while_let<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, iter_expr: &'tcx Expr) -> bool {
let def_id = match var_def_id(cx, iter_expr) {
Some(id) => id,
None => return false,
Expand All @@ -1945,7 +1945,7 @@ fn is_iterator_used_after_while_let<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, it
visitor.var_used_after_while_let
}

struct VarUsedAfterLoopVisitor<'a, 'tcx: 'a> {
struct VarUsedAfterLoopVisitor<'a, 'tcx> {
cx: &'a LateContext<'a, 'tcx>,
def_id: HirId,
iter_expr_id: HirId,
Expand Down Expand Up @@ -2051,7 +2051,7 @@ enum VarState {
}

/// Scan a for loop for variables that are incremented exactly once.
struct IncrementVisitor<'a, 'tcx: 'a> {
struct IncrementVisitor<'a, 'tcx> {
cx: &'a LateContext<'a, 'tcx>, // context reference
states: FxHashMap<HirId, VarState>, // incremented variables
depth: u32, // depth of conditional expressions
Expand Down Expand Up @@ -2105,7 +2105,7 @@ impl<'a, 'tcx> Visitor<'tcx> for IncrementVisitor<'a, 'tcx> {
}

/// Checks whether a variable is initialized to zero at the start of a loop.
struct InitializeVisitor<'a, 'tcx: 'a> {
struct InitializeVisitor<'a, 'tcx> {
cx: &'a LateContext<'a, 'tcx>, // context reference
end_expr: &'tcx Expr, // the for loop. Stop scanning here.
var_id: HirId,
Expand Down Expand Up @@ -2374,7 +2374,7 @@ fn check_infinite_loop<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, cond: &'tcx Expr, e
/// Stops analysis if a function call is found
/// Note: In some cases such as `self`, there are no mutable annotation,
/// All variables definition IDs are collected
struct VarCollectorVisitor<'a, 'tcx: 'a> {
struct VarCollectorVisitor<'a, 'tcx> {
cx: &'a LateContext<'a, 'tcx>,
ids: FxHashSet<HirId>,
def_ids: FxHashMap<def_id::DefId, bool>,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ where
T: Copy + Ord,
{
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
enum Kind<'a, T: 'a> {
enum Kind<'a, T> {
Start(T, &'a SpannedRange<T>),
End(Bound<T>, &'a SpannedRange<T>),
}
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,15 +1046,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Methods {

/// Checks for the `OR_FUN_CALL` lint.
#[allow(clippy::too_many_lines)]
fn lint_or_fun_call<'a, 'tcx: 'a>(
fn lint_or_fun_call<'a, 'tcx>(
cx: &LateContext<'a, 'tcx>,
expr: &hir::Expr,
method_span: Span,
name: &str,
args: &'tcx [hir::Expr],
) {
// Searches an expression for method calls or function calls that aren't ctors
struct FunCallFinder<'a, 'tcx: 'a> {
struct FunCallFinder<'a, 'tcx> {
cx: &'a LateContext<'a, 'tcx>,
found: bool,
}
Expand Down Expand Up @@ -1142,7 +1142,7 @@ fn lint_or_fun_call<'a, 'tcx: 'a>(

/// Checks for `*or(foo())`.
#[allow(clippy::too_many_arguments)]
fn check_general_case<'a, 'tcx: 'a>(
fn check_general_case<'a, 'tcx>(
cx: &LateContext<'a, 'tcx>,
name: &str,
method_span: Span,
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/methods/option_map_unwrap_or.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ pub(super) fn lint<'a, 'tcx>(
}
}

struct UnwrapVisitor<'a, 'tcx: 'a> {
struct UnwrapVisitor<'a, 'tcx> {
cx: &'a LateContext<'a, 'tcx>,
identifiers: FxHashSet<Symbol>,
}

impl<'a, 'tcx: 'a> Visitor<'tcx> for UnwrapVisitor<'a, 'tcx> {
impl<'a, 'tcx> Visitor<'tcx> for UnwrapVisitor<'a, 'tcx> {
fn visit_path(&mut self, path: &'tcx Path, _id: HirId) {
self.identifiers.insert(ident(path));
walk_path(self, path);
Expand All @@ -93,13 +93,13 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for UnwrapVisitor<'a, 'tcx> {
}
}

struct MapExprVisitor<'a, 'tcx: 'a> {
struct MapExprVisitor<'a, 'tcx> {
cx: &'a LateContext<'a, 'tcx>,
identifiers: FxHashSet<Symbol>,
found_identifier: bool,
}

impl<'a, 'tcx: 'a> Visitor<'tcx> for MapExprVisitor<'a, 'tcx> {
impl<'a, 'tcx> Visitor<'tcx> for MapExprVisitor<'a, 'tcx> {
fn visit_path(&mut self, path: &'tcx Path, _id: HirId) {
if self.identifiers.contains(&ident(path)) {
self.found_identifier = true;
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/methods/unnecessary_filter_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub(super) fn lint(cx: &LateContext<'_, '_>, expr: &hir::Expr, args: &[hir::Expr
}

// returns (found_mapping, found_filtering)
fn check_expression<'a, 'tcx: 'a>(
fn check_expression<'a, 'tcx>(
cx: &'a LateContext<'a, 'tcx>,
arg_id: hir::HirId,
expr: &'tcx hir::Expr,
Expand Down Expand Up @@ -104,7 +104,7 @@ fn check_expression<'a, 'tcx: 'a>(
}
}

struct ReturnVisitor<'a, 'tcx: 'a> {
struct ReturnVisitor<'a, 'tcx> {
cx: &'a LateContext<'a, 'tcx>,
arg_id: hir::HirId,
// Found a non-None return that isn't Some(input)
Expand All @@ -113,7 +113,7 @@ struct ReturnVisitor<'a, 'tcx: 'a> {
found_filtering: bool,
}

impl<'a, 'tcx: 'a> ReturnVisitor<'a, 'tcx> {
impl<'a, 'tcx> ReturnVisitor<'a, 'tcx> {
fn new(cx: &'a LateContext<'a, 'tcx>, arg_id: hir::HirId) -> ReturnVisitor<'a, 'tcx> {
ReturnVisitor {
cx,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/mut_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutMut {
}
}

pub struct MutVisitor<'a, 'tcx: 'a> {
pub struct MutVisitor<'a, 'tcx> {
cx: &'a LateContext<'a, 'tcx>,
}

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/needless_pass_by_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ fn requires_exact_signature(attrs: &[Attribute]) -> bool {
})
}

struct MovedVariablesCtxt<'a, 'tcx: 'a> {
struct MovedVariablesCtxt<'a, 'tcx> {
cx: &'a LateContext<'a, 'tcx>,
moved_vars: FxHashSet<HirId>,
/// Spans which need to be prefixed with `*` for dereferencing the
Expand Down
Loading

0 comments on commit 7db5d0e

Please sign in to comment.