Skip to content

Commit 7db5d0e

Browse files
committed
Auto merge of rust-lang#4221 - lzutao:redundant-lifetime, r=matthiaskrgr
Fix warnings about unnecessary lifetime bounds Rustup rust-lang#61172 changelog: none
2 parents 149a988 + 4fa498a commit 7db5d0e

34 files changed

+83
-87
lines changed

clippy_lints/src/assign_ops.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,13 @@ fn is_commutative(op: hir::BinOpKind) -> bool {
236236
}
237237
}
238238

239-
struct ExprVisitor<'a, 'tcx: 'a> {
239+
struct ExprVisitor<'a, 'tcx> {
240240
assignee: &'a hir::Expr,
241241
counter: u8,
242242
cx: &'a LateContext<'a, 'tcx>,
243243
}
244244

245-
impl<'a, 'tcx: 'a> Visitor<'tcx> for ExprVisitor<'a, 'tcx> {
245+
impl<'a, 'tcx> Visitor<'tcx> for ExprVisitor<'a, 'tcx> {
246246
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
247247
if SpanlessEq::new(self.cx).ignore_fn().eq_expr(self.assignee, expr) {
248248
self.counter += 1;

clippy_lints/src/block_in_if_condition.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ declare_clippy_lint! {
4444

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

47-
struct ExVisitor<'a, 'tcx: 'a> {
47+
struct ExVisitor<'a, 'tcx> {
4848
found_block: Option<&'tcx Expr>,
4949
cx: &'a LateContext<'a, 'tcx>,
5050
}
5151

52-
impl<'a, 'tcx: 'a> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
52+
impl<'a, 'tcx> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
5353
fn visit_expr(&mut self, expr: &'tcx Expr) {
5454
if let ExprKind::Closure(_, _, eid, _, _) = expr.node {
5555
let body = self.cx.tcx.hir().body(eid);

clippy_lints/src/booleans.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonminimalBool {
6868
}
6969
}
7070

71-
struct NonminimalBoolVisitor<'a, 'tcx: 'a> {
71+
struct NonminimalBoolVisitor<'a, 'tcx> {
7272
cx: &'a LateContext<'a, 'tcx>,
7373
}
7474

7575
use quine_mc_cluskey::Bool;
76-
struct Hir2Qmm<'a, 'tcx: 'a, 'v> {
76+
struct Hir2Qmm<'a, 'tcx, 'v> {
7777
terminals: Vec<&'v Expr>,
7878
cx: &'a LateContext<'a, 'tcx>,
7979
}
@@ -155,7 +155,7 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> {
155155
}
156156
}
157157

158-
struct SuggestContext<'a, 'tcx: 'a, 'v> {
158+
struct SuggestContext<'a, 'tcx, 'v> {
159159
terminals: &'v [&'v Expr],
160160
cx: &'a LateContext<'a, 'tcx>,
161161
output: String,

clippy_lints/src/cognitive_complexity.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl CognitiveComplexity {
4141
impl_lint_pass!(CognitiveComplexity => [COGNITIVE_COMPLEXITY]);
4242

4343
impl CognitiveComplexity {
44-
fn check<'a, 'tcx: 'a>(&mut self, cx: &'a LateContext<'a, 'tcx>, body: &'tcx Body, span: Span) {
44+
fn check<'a, 'tcx>(&mut self, cx: &'a LateContext<'a, 'tcx>, body: &'tcx Body, span: Span) {
4545
if in_macro_or_desugar(span) {
4646
return;
4747
}
@@ -132,7 +132,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CognitiveComplexity {
132132
}
133133
}
134134

135-
struct CCHelper<'a, 'tcx: 'a> {
135+
struct CCHelper<'a, 'tcx> {
136136
match_arms: u64,
137137
divergence: u64,
138138
returns: u64,

clippy_lints/src/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ pub fn constant_context<'c, 'cc>(
210210
}
211211
}
212212

213-
pub struct ConstEvalLateContext<'a, 'tcx: 'a> {
213+
pub struct ConstEvalLateContext<'a, 'tcx> {
214214
lcx: &'a LateContext<'a, 'tcx>,
215215
tables: &'a ty::TypeckTables<'tcx>,
216216
param_env: ty::ParamEnv<'tcx>,

clippy_lints/src/entry.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ fn check_cond<'a, 'tcx, 'b>(
112112
None
113113
}
114114

115-
struct InsertVisitor<'a, 'tcx: 'a, 'b> {
115+
struct InsertVisitor<'a, 'tcx, 'b> {
116116
cx: &'a LateContext<'a, 'tcx>,
117117
span: Span,
118118
ty: &'static str,

clippy_lints/src/escape.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn is_non_trait_box(ty: Ty<'_>) -> bool {
4343
ty.is_box() && !ty.boxed_ty().is_trait()
4444
}
4545

46-
struct EscapeDelegate<'a, 'tcx: 'a> {
46+
struct EscapeDelegate<'a, 'tcx> {
4747
cx: &'a LateContext<'a, 'tcx>,
4848
set: HirIdSet,
4949
too_large_for_stack: u64,

clippy_lints/src/eval_order_dependence.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EvalOrderDependence {
9292
}
9393
}
9494

95-
struct DivergenceVisitor<'a, 'tcx: 'a> {
95+
struct DivergenceVisitor<'a, 'tcx> {
9696
cx: &'a LateContext<'a, 'tcx>,
9797
}
9898

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

274274
/// A visitor that looks for reads from a variable.
275-
struct ReadVisitor<'a, 'tcx: 'a> {
275+
struct ReadVisitor<'a, 'tcx> {
276276
cx: &'a LateContext<'a, 'tcx>,
277277
/// The ID of the variable we're looking for.
278278
var: HirId,

clippy_lints/src/fallible_impl_from.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_it
4949
use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor};
5050
use rustc::hir::*;
5151

52-
struct FindPanicUnwrap<'a, 'tcx: 'a> {
52+
struct FindPanicUnwrap<'a, 'tcx> {
5353
lcx: &'a LateContext<'a, 'tcx>,
5454
tables: &'tcx ty::TypeckTables<'tcx>,
5555
result: Vec<Span>,
5656
}
5757

58-
impl<'a, 'tcx: 'a> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> {
58+
impl<'a, 'tcx> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> {
5959
fn visit_expr(&mut self, expr: &'tcx Expr) {
6060
// check for `begin_panic`
6161
if_chain! {

clippy_lints/src/functions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ fn raw_ptr_arg(arg: &hir::Arg, ty: &hir::Ty) -> Option<hir::HirId> {
291291
}
292292
}
293293

294-
struct DerefVisitor<'a, 'tcx: 'a> {
294+
struct DerefVisitor<'a, 'tcx> {
295295
cx: &'a LateContext<'a, 'tcx>,
296296
ptrs: FxHashSet<hir::HirId>,
297297
tables: &'a ty::TypeckTables<'tcx>,
@@ -330,7 +330,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> {
330330
}
331331
}
332332

333-
impl<'a, 'tcx: 'a> DerefVisitor<'a, 'tcx> {
333+
impl<'a, 'tcx> DerefVisitor<'a, 'tcx> {
334334
fn check_arg(&self, ptr: &hir::Expr) {
335335
if let hir::ExprKind::Path(ref qpath) = ptr.node {
336336
if let Res::Local(id) = self.cx.tables.qpath_res(qpath, ptr.hir_id) {

clippy_lints/src/let_if_seq.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
135135
}
136136
}
137137

138-
struct UsedVisitor<'a, 'tcx: 'a> {
138+
struct UsedVisitor<'a, 'tcx> {
139139
cx: &'a LateContext<'a, 'tcx>,
140140
id: hir::HirId,
141141
used: bool,
@@ -194,7 +194,7 @@ fn check_assign<'a, 'tcx>(
194194
None
195195
}
196196

197-
fn used_in_expr<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, id: hir::HirId, expr: &'tcx hir::Expr) -> bool {
197+
fn used_in_expr<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, id: hir::HirId, expr: &'tcx hir::Expr) -> bool {
198198
let mut v = UsedVisitor { cx, id, used: false };
199199
hir::intravisit::walk_expr(&mut v, expr);
200200
v.used

clippy_lints/src/lifetimes.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ fn check_fn_inner<'a, 'tcx>(
147147
report_extra_lifetimes(cx, decl, generics);
148148
}
149149

150-
fn could_use_elision<'a, 'tcx: 'a>(
150+
fn could_use_elision<'a, 'tcx>(
151151
cx: &LateContext<'a, 'tcx>,
152152
func: &'tcx FnDecl,
153153
body: Option<BodyId>,
@@ -264,7 +264,7 @@ fn unique_lifetimes(lts: &[RefLt]) -> usize {
264264
}
265265

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

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

448-
fn report_extra_lifetimes<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, func: &'tcx FnDecl, generics: &'tcx Generics) {
448+
fn report_extra_lifetimes<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, func: &'tcx FnDecl, generics: &'tcx Generics) {
449449
let hs = generics
450450
.params
451451
.iter()

clippy_lints/src/loops.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1723,13 +1723,13 @@ impl<'tcx> Visitor<'tcx> for UsedVisitor {
17231723
}
17241724
}
17251725

1726-
struct LocalUsedVisitor<'a, 'tcx: 'a> {
1726+
struct LocalUsedVisitor<'a, 'tcx> {
17271727
cx: &'a LateContext<'a, 'tcx>,
17281728
local: HirId,
17291729
used: bool,
17301730
}
17311731

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

1746-
struct VarVisitor<'a, 'tcx: 'a> {
1746+
struct VarVisitor<'a, 'tcx> {
17471747
/// context reference
17481748
cx: &'a LateContext<'a, 'tcx>,
17491749
/// var name to look for as index
@@ -1914,7 +1914,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
19141914
}
19151915
}
19161916

1917-
fn is_used_inside<'a, 'tcx: 'a>(cx: &'a LateContext<'a, 'tcx>, expr: &'tcx Expr, container: &'tcx Expr) -> bool {
1917+
fn is_used_inside<'a, 'tcx>(cx: &'a LateContext<'a, 'tcx>, expr: &'tcx Expr, container: &'tcx Expr) -> bool {
19181918
let def_id = match var_def_id(cx, expr) {
19191919
Some(id) => id,
19201920
None => return false,
@@ -1927,7 +1927,7 @@ fn is_used_inside<'a, 'tcx: 'a>(cx: &'a LateContext<'a, 'tcx>, expr: &'tcx Expr,
19271927
false
19281928
}
19291929

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

1948-
struct VarUsedAfterLoopVisitor<'a, 'tcx: 'a> {
1948+
struct VarUsedAfterLoopVisitor<'a, 'tcx> {
19491949
cx: &'a LateContext<'a, 'tcx>,
19501950
def_id: HirId,
19511951
iter_expr_id: HirId,
@@ -2051,7 +2051,7 @@ enum VarState {
20512051
}
20522052

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

21072107
/// Checks whether a variable is initialized to zero at the start of a loop.
2108-
struct InitializeVisitor<'a, 'tcx: 'a> {
2108+
struct InitializeVisitor<'a, 'tcx> {
21092109
cx: &'a LateContext<'a, 'tcx>, // context reference
21102110
end_expr: &'tcx Expr, // the for loop. Stop scanning here.
21112111
var_id: HirId,
@@ -2374,7 +2374,7 @@ fn check_infinite_loop<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, cond: &'tcx Expr, e
23742374
/// Stops analysis if a function call is found
23752375
/// Note: In some cases such as `self`, there are no mutable annotation,
23762376
/// All variables definition IDs are collected
2377-
struct VarCollectorVisitor<'a, 'tcx: 'a> {
2377+
struct VarCollectorVisitor<'a, 'tcx> {
23782378
cx: &'a LateContext<'a, 'tcx>,
23792379
ids: FxHashSet<HirId>,
23802380
def_ids: FxHashMap<def_id::DefId, bool>,

clippy_lints/src/matches.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ where
763763
T: Copy + Ord,
764764
{
765765
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
766-
enum Kind<'a, T: 'a> {
766+
enum Kind<'a, T> {
767767
Start(T, &'a SpannedRange<T>),
768768
End(Bound<T>, &'a SpannedRange<T>),
769769
}

clippy_lints/src/methods/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1046,15 +1046,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Methods {
10461046

10471047
/// Checks for the `OR_FUN_CALL` lint.
10481048
#[allow(clippy::too_many_lines)]
1049-
fn lint_or_fun_call<'a, 'tcx: 'a>(
1049+
fn lint_or_fun_call<'a, 'tcx>(
10501050
cx: &LateContext<'a, 'tcx>,
10511051
expr: &hir::Expr,
10521052
method_span: Span,
10531053
name: &str,
10541054
args: &'tcx [hir::Expr],
10551055
) {
10561056
// Searches an expression for method calls or function calls that aren't ctors
1057-
struct FunCallFinder<'a, 'tcx: 'a> {
1057+
struct FunCallFinder<'a, 'tcx> {
10581058
cx: &'a LateContext<'a, 'tcx>,
10591059
found: bool,
10601060
}
@@ -1142,7 +1142,7 @@ fn lint_or_fun_call<'a, 'tcx: 'a>(
11421142

11431143
/// Checks for `*or(foo())`.
11441144
#[allow(clippy::too_many_arguments)]
1145-
fn check_general_case<'a, 'tcx: 'a>(
1145+
fn check_general_case<'a, 'tcx>(
11461146
cx: &LateContext<'a, 'tcx>,
11471147
name: &str,
11481148
method_span: Span,

clippy_lints/src/methods/option_map_unwrap_or.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ pub(super) fn lint<'a, 'tcx>(
7777
}
7878
}
7979

80-
struct UnwrapVisitor<'a, 'tcx: 'a> {
80+
struct UnwrapVisitor<'a, 'tcx> {
8181
cx: &'a LateContext<'a, 'tcx>,
8282
identifiers: FxHashSet<Symbol>,
8383
}
8484

85-
impl<'a, 'tcx: 'a> Visitor<'tcx> for UnwrapVisitor<'a, 'tcx> {
85+
impl<'a, 'tcx> Visitor<'tcx> for UnwrapVisitor<'a, 'tcx> {
8686
fn visit_path(&mut self, path: &'tcx Path, _id: HirId) {
8787
self.identifiers.insert(ident(path));
8888
walk_path(self, path);
@@ -93,13 +93,13 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for UnwrapVisitor<'a, 'tcx> {
9393
}
9494
}
9595

96-
struct MapExprVisitor<'a, 'tcx: 'a> {
96+
struct MapExprVisitor<'a, 'tcx> {
9797
cx: &'a LateContext<'a, 'tcx>,
9898
identifiers: FxHashSet<Symbol>,
9999
found_identifier: bool,
100100
}
101101

102-
impl<'a, 'tcx: 'a> Visitor<'tcx> for MapExprVisitor<'a, 'tcx> {
102+
impl<'a, 'tcx> Visitor<'tcx> for MapExprVisitor<'a, 'tcx> {
103103
fn visit_path(&mut self, path: &'tcx Path, _id: HirId) {
104104
if self.identifiers.contains(&ident(path)) {
105105
self.found_identifier = true;

clippy_lints/src/methods/unnecessary_filter_map.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub(super) fn lint(cx: &LateContext<'_, '_>, expr: &hir::Expr, args: &[hir::Expr
5353
}
5454

5555
// returns (found_mapping, found_filtering)
56-
fn check_expression<'a, 'tcx: 'a>(
56+
fn check_expression<'a, 'tcx>(
5757
cx: &'a LateContext<'a, 'tcx>,
5858
arg_id: hir::HirId,
5959
expr: &'tcx hir::Expr,
@@ -104,7 +104,7 @@ fn check_expression<'a, 'tcx: 'a>(
104104
}
105105
}
106106

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

116-
impl<'a, 'tcx: 'a> ReturnVisitor<'a, 'tcx> {
116+
impl<'a, 'tcx> ReturnVisitor<'a, 'tcx> {
117117
fn new(cx: &'a LateContext<'a, 'tcx>, arg_id: hir::HirId) -> ReturnVisitor<'a, 'tcx> {
118118
ReturnVisitor {
119119
cx,

clippy_lints/src/mut_mut.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutMut {
3737
}
3838
}
3939

40-
pub struct MutVisitor<'a, 'tcx: 'a> {
40+
pub struct MutVisitor<'a, 'tcx> {
4141
cx: &'a LateContext<'a, 'tcx>,
4242
}
4343

clippy_lints/src/needless_pass_by_value.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ fn requires_exact_signature(attrs: &[Attribute]) -> bool {
326326
})
327327
}
328328

329-
struct MovedVariablesCtxt<'a, 'tcx: 'a> {
329+
struct MovedVariablesCtxt<'a, 'tcx> {
330330
cx: &'a LateContext<'a, 'tcx>,
331331
moved_vars: FxHashSet<HirId>,
332332
/// Spans which need to be prefixed with `*` for dereferencing the

0 commit comments

Comments
 (0)