Skip to content

Commit a4c201e

Browse files
committed
1 parent c807fbc commit a4c201e

36 files changed

+139
-131
lines changed

clippy_lints/src/booleans.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonminimalBool {
6060
&mut self,
6161
cx: &LateContext<'a, 'tcx>,
6262
_: intravisit::FnKind<'tcx>,
63-
_: &'tcx FnDecl,
63+
_: &'tcx FnDecl<'_>,
6464
body: &'tcx Body<'_>,
6565
_: Span,
6666
_: HirId,

clippy_lints/src/checked_conversions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ fn get_types_from_cast<'a>(expr: &'a Expr<'_>, func: &'a str, types: &'a [&str])
287287
}
288288

289289
/// Gets the type which implements the called function
290-
fn get_implementing_type<'a>(path: &QPath, candidates: &'a [&str], function: &str) -> Option<&'a str> {
290+
fn get_implementing_type<'a>(path: &QPath<'_>, candidates: &'a [&str], function: &str) -> Option<&'a str> {
291291
if_chain! {
292292
if let QPath::TypeRelative(ref ty, ref path) = &path;
293293
if path.ident.name.as_str() == function;
@@ -304,7 +304,7 @@ fn get_implementing_type<'a>(path: &QPath, candidates: &'a [&str], function: &st
304304
}
305305

306306
/// Gets the type as a string, if it is a supported integer
307-
fn int_ty_to_sym(path: &QPath) -> Option<&str> {
307+
fn int_ty_to_sym<'tcx>(path: &QPath<'_>) -> Option<&'tcx str> {
308308
if_chain! {
309309
if let QPath::Resolved(_, ref path) = *path;
310310
if let [ty] = &*path.segments;

clippy_lints/src/cognitive_complexity.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl CognitiveComplexity {
4747
&mut self,
4848
cx: &'a LateContext<'a, 'tcx>,
4949
kind: FnKind<'tcx>,
50-
decl: &'tcx FnDecl,
50+
decl: &'tcx FnDecl<'_>,
5151
body: &'tcx Body<'_>,
5252
body_span: Span,
5353
) {
@@ -116,7 +116,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CognitiveComplexity {
116116
&mut self,
117117
cx: &LateContext<'a, 'tcx>,
118118
kind: FnKind<'tcx>,
119-
decl: &'tcx FnDecl,
119+
decl: &'tcx FnDecl<'_>,
120120
body: &'tcx Body<'_>,
121121
span: Span,
122122
hir_id: HirId,

clippy_lints/src/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
320320
}
321321

322322
/// Lookup a possibly constant expression from a `ExprKind::Path`.
323-
fn fetch_path(&mut self, qpath: &QPath, id: HirId) -> Option<Constant> {
323+
fn fetch_path(&mut self, qpath: &QPath<'_>, id: HirId) -> Option<Constant> {
324324
let res = self.tables.qpath_res(qpath, id);
325325
match res {
326326
Res::Def(DefKind::Const, def_id) | Res::Def(DefKind::AssocConst, def_id) => {

clippy_lints/src/derive.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Derive {
8484
fn check_hash_peq<'a, 'tcx>(
8585
cx: &LateContext<'a, 'tcx>,
8686
span: Span,
87-
trait_ref: &TraitRef,
87+
trait_ref: &TraitRef<'_>,
8888
ty: Ty<'tcx>,
8989
hash_is_automatically_derived: bool,
9090
) {
@@ -130,7 +130,7 @@ fn check_hash_peq<'a, 'tcx>(
130130
}
131131

132132
/// Implementation of the `EXPL_IMPL_CLONE_ON_COPY` lint.
133-
fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item<'_>, trait_ref: &TraitRef, ty: Ty<'tcx>) {
133+
fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item<'_>, trait_ref: &TraitRef<'_>, ty: Ty<'tcx>) {
134134
if match_path(&trait_ref.path, &paths::CLONE_TRAIT) {
135135
if !is_copy(cx, ty) {
136136
return;

clippy_lints/src/doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ fn lint_for_missing_headers<'a, 'tcx>(
190190
cx: &LateContext<'a, 'tcx>,
191191
hir_id: hir::HirId,
192192
span: impl Into<MultiSpan> + Copy,
193-
sig: &hir::FnSig,
193+
sig: &hir::FnSig<'_>,
194194
headers: DocHeaders,
195195
) {
196196
if !cx.access_levels.is_exported(hir_id) {

clippy_lints/src/drop_bounds.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,21 @@ const DROP_BOUNDS_SUMMARY: &str = "Bounds of the form `T: Drop` are useless. \
3939
declare_lint_pass!(DropBounds => [DROP_BOUNDS]);
4040

4141
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DropBounds {
42-
fn check_generic_param(&mut self, cx: &rustc::lint::LateContext<'a, 'tcx>, p: &'tcx GenericParam) {
43-
for bound in &p.bounds {
42+
fn check_generic_param(&mut self, cx: &rustc::lint::LateContext<'a, 'tcx>, p: &'tcx GenericParam<'_>) {
43+
for bound in p.bounds.iter() {
4444
lint_bound(cx, bound);
4545
}
4646
}
47-
fn check_where_predicate(&mut self, cx: &rustc::lint::LateContext<'a, 'tcx>, p: &'tcx WherePredicate) {
47+
fn check_where_predicate(&mut self, cx: &rustc::lint::LateContext<'a, 'tcx>, p: &'tcx WherePredicate<'_>) {
4848
if let WherePredicate::BoundPredicate(WhereBoundPredicate { bounds, .. }) = p {
49-
for bound in bounds {
49+
for bound in *bounds {
5050
lint_bound(cx, bound);
5151
}
5252
}
5353
}
5454
}
5555

56-
fn lint_bound<'a, 'tcx>(cx: &rustc::lint::LateContext<'a, 'tcx>, bound: &'tcx GenericBound) {
56+
fn lint_bound<'a, 'tcx>(cx: &rustc::lint::LateContext<'a, 'tcx>, bound: &'tcx GenericBound<'_>) {
5757
if_chain! {
5858
if let GenericBound::Trait(t, _) = bound;
5959
if let Some(def_id) = t.trait_ref.path.res.opt_def_id();

clippy_lints/src/escape.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxedLocal {
5555
&mut self,
5656
cx: &LateContext<'a, 'tcx>,
5757
_: visit::FnKind<'tcx>,
58-
_: &'tcx FnDecl,
58+
_: &'tcx FnDecl<'_>,
5959
body: &'tcx Body<'_>,
6060
_: Span,
6161
hir_id: HirId,

clippy_lints/src/fallible_impl_from.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for FallibleImplFrom {
4646
}
4747
}
4848

49-
fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_items: &[hir::ImplItemRef]) {
49+
fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_items: &[hir::ImplItemRef<'_>]) {
5050
use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor};
5151
use rustc::hir::*;
5252

clippy_lints/src/functions.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
187187
&mut self,
188188
cx: &LateContext<'a, 'tcx>,
189189
kind: intravisit::FnKind<'tcx>,
190-
decl: &'tcx hir::FnDecl,
190+
decl: &'tcx hir::FnDecl<'_>,
191191
body: &'tcx hir::Body<'_>,
192192
span: Span,
193193
hir_id: hir::HirId,
@@ -306,7 +306,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
306306
}
307307

308308
impl<'a, 'tcx> Functions {
309-
fn check_arg_number(self, cx: &LateContext<'_, '_>, decl: &hir::FnDecl, fn_span: Span) {
309+
fn check_arg_number(self, cx: &LateContext<'_, '_>, decl: &hir::FnDecl<'_>, fn_span: Span) {
310310
let args = decl.inputs.len() as u64;
311311
if args > self.threshold {
312312
span_lint(
@@ -375,7 +375,7 @@ impl<'a, 'tcx> Functions {
375375
fn check_raw_ptr(
376376
cx: &LateContext<'a, 'tcx>,
377377
unsafety: hir::Unsafety,
378-
decl: &'tcx hir::FnDecl,
378+
decl: &'tcx hir::FnDecl<'_>,
379379
body: &'tcx hir::Body<'_>,
380380
hir_id: hir::HirId,
381381
) {
@@ -402,7 +402,7 @@ impl<'a, 'tcx> Functions {
402402

403403
fn check_needless_must_use(
404404
cx: &LateContext<'_, '_>,
405-
decl: &hir::FnDecl,
405+
decl: &hir::FnDecl<'_>,
406406
item_id: hir::HirId,
407407
item_span: Span,
408408
fn_header_span: Span,
@@ -439,7 +439,7 @@ fn check_needless_must_use(
439439

440440
fn check_must_use_candidate<'a, 'tcx>(
441441
cx: &LateContext<'a, 'tcx>,
442-
decl: &'tcx hir::FnDecl,
442+
decl: &'tcx hir::FnDecl<'_>,
443443
body: &'tcx hir::Body<'_>,
444444
item_span: Span,
445445
item_id: hir::HirId,
@@ -467,7 +467,7 @@ fn check_must_use_candidate<'a, 'tcx>(
467467
});
468468
}
469469

470-
fn returns_unit(decl: &hir::FnDecl) -> bool {
470+
fn returns_unit(decl: &hir::FnDecl<'_>) -> bool {
471471
match decl.output {
472472
hir::FunctionRetTy::DefaultReturn(_) => true,
473473
hir::FunctionRetTy::Return(ref ty) => match ty.kind {
@@ -518,7 +518,7 @@ fn is_mutable_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'tcx>, span: Span,
518518
}
519519
}
520520

521-
fn raw_ptr_arg(arg: &hir::Param<'_>, ty: &hir::Ty) -> Option<hir::HirId> {
521+
fn raw_ptr_arg(arg: &hir::Param<'_>, ty: &hir::Ty<'_>) -> Option<hir::HirId> {
522522
if let (&hir::PatKind::Binding(_, id, _, _), &hir::TyKind::Ptr(_)) = (&arg.pat.kind, &ty.kind) {
523523
Some(id)
524524
} else {

clippy_lints/src/implicit_return.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImplicitReturn {
129129
&mut self,
130130
cx: &LateContext<'a, 'tcx>,
131131
_: FnKind<'tcx>,
132-
_: &'tcx FnDecl,
132+
_: &'tcx FnDecl<'_>,
133133
body: &'tcx Body<'_>,
134134
span: Span,
135135
_: HirId,

clippy_lints/src/len_zero.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ fn check_trait_items(cx: &LateContext<'_, '_>, visited_trait: &Item<'_>, trait_i
166166
}
167167
}
168168

169-
fn check_impl_items(cx: &LateContext<'_, '_>, item: &Item<'_>, impl_items: &[ImplItemRef]) {
170-
fn is_named_self(cx: &LateContext<'_, '_>, item: &ImplItemRef, name: &str) -> bool {
169+
fn check_impl_items(cx: &LateContext<'_, '_>, item: &Item<'_>, impl_items: &[ImplItemRef<'_>]) {
170+
fn is_named_self(cx: &LateContext<'_, '_>, item: &ImplItemRef<'_>, name: &str) -> bool {
171171
item.ident.name.as_str() == name
172172
&& if let AssocItemKind::Method { has_self } = item.kind {
173173
has_self && {

clippy_lints/src/lifetimes.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ enum RefLt {
112112

113113
fn check_fn_inner<'a, 'tcx>(
114114
cx: &LateContext<'a, 'tcx>,
115-
decl: &'tcx FnDecl,
115+
decl: &'tcx FnDecl<'_>,
116116
body: Option<BodyId>,
117-
generics: &'tcx Generics,
117+
generics: &'tcx Generics<'_>,
118118
span: Span,
119119
report_extra_lifetimes: bool,
120120
) {
@@ -128,7 +128,7 @@ fn check_fn_inner<'a, 'tcx>(
128128
_ => false,
129129
});
130130
for typ in types {
131-
for bound in &typ.bounds {
131+
for bound in typ.bounds {
132132
let mut visitor = RefVisitor::new(cx);
133133
walk_param_bound(&mut visitor, bound);
134134
if visitor.lts.iter().any(|lt| matches!(lt, RefLt::Named(_))) {
@@ -173,9 +173,9 @@ fn check_fn_inner<'a, 'tcx>(
173173

174174
fn could_use_elision<'a, 'tcx>(
175175
cx: &LateContext<'a, 'tcx>,
176-
func: &'tcx FnDecl,
176+
func: &'tcx FnDecl<'_>,
177177
body: Option<BodyId>,
178-
named_generics: &'tcx [GenericParam],
178+
named_generics: &'tcx [GenericParam<'_>],
179179
bounds_lts: Vec<&'tcx Lifetime>,
180180
) -> bool {
181181
// There are two scenarios where elision works:
@@ -192,7 +192,7 @@ fn could_use_elision<'a, 'tcx>(
192192
let mut output_visitor = RefVisitor::new(cx);
193193

194194
// extract lifetimes in input argument types
195-
for arg in &func.inputs {
195+
for arg in func.inputs {
196196
input_visitor.visit_ty(arg);
197197
}
198198
// extract lifetimes in output type
@@ -258,7 +258,7 @@ fn could_use_elision<'a, 'tcx>(
258258
}
259259
}
260260

261-
fn allowed_lts_from(named_generics: &[GenericParam]) -> FxHashSet<RefLt> {
261+
fn allowed_lts_from(named_generics: &[GenericParam<'_>]) -> FxHashSet<RefLt> {
262262
let mut allowed_lts = FxHashSet::default();
263263
for par in named_generics.iter() {
264264
if let GenericParamKind::Lifetime { .. } = par.kind {
@@ -328,7 +328,7 @@ impl<'v, 't> RefVisitor<'v, 't> {
328328
}
329329
}
330330

331-
fn collect_anonymous_lifetimes(&mut self, qpath: &QPath, ty: &Ty) {
331+
fn collect_anonymous_lifetimes(&mut self, qpath: &QPath<'_>, ty: &Ty<'_>) {
332332
if let Some(ref last_path_segment) = last_path_segment(qpath).args {
333333
if !last_path_segment.parenthesized
334334
&& !last_path_segment.args.iter().any(|arg| match arg {
@@ -363,7 +363,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
363363
self.record(&Some(*lifetime));
364364
}
365365

366-
fn visit_ty(&mut self, ty: &'tcx Ty) {
366+
fn visit_ty(&mut self, ty: &'tcx Ty<'_>) {
367367
match ty.kind {
368368
TyKind::Rptr(ref lt, _) if lt.is_elided() => {
369369
self.record(&None);
@@ -374,7 +374,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
374374
TyKind::Def(item, _) => {
375375
let map = self.cx.tcx.hir();
376376
if let ItemKind::OpaqueTy(ref exist_ty) = map.expect_item(item.id).kind {
377-
for bound in &exist_ty.bounds {
377+
for bound in exist_ty.bounds {
378378
if let GenericBound::Outlives(_) = *bound {
379379
self.record(&None);
380380
}
@@ -384,7 +384,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
384384
}
385385
walk_ty(self, ty);
386386
},
387-
TyKind::TraitObject(ref bounds, ref lt) => {
387+
TyKind::TraitObject(bounds, ref lt) => {
388388
if !lt.is_elided() {
389389
self.abort = true;
390390
}
@@ -404,8 +404,8 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
404404

405405
/// Are any lifetimes mentioned in the `where` clause? If so, we don't try to
406406
/// reason about elision.
407-
fn has_where_lifetimes<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, where_clause: &'tcx WhereClause) -> bool {
408-
for predicate in &where_clause.predicates {
407+
fn has_where_lifetimes<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, where_clause: &'tcx WhereClause<'_>) -> bool {
408+
for predicate in where_clause.predicates {
409409
match *predicate {
410410
WherePredicate::RegionPredicate(..) => return true,
411411
WherePredicate::BoundPredicate(ref pred) => {
@@ -457,7 +457,7 @@ impl<'tcx> Visitor<'tcx> for LifetimeChecker {
457457
self.map.remove(&lifetime.name.ident().name);
458458
}
459459

460-
fn visit_generic_param(&mut self, param: &'tcx GenericParam) {
460+
fn visit_generic_param(&mut self, param: &'tcx GenericParam<'_>) {
461461
// don't actually visit `<'a>` or `<'a: 'b>`
462462
// we've already visited the `'a` declarations and
463463
// don't want to spuriously remove them
@@ -472,7 +472,7 @@ impl<'tcx> Visitor<'tcx> for LifetimeChecker {
472472
}
473473
}
474474

475-
fn report_extra_lifetimes<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, func: &'tcx FnDecl, generics: &'tcx Generics) {
475+
fn report_extra_lifetimes<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, func: &'tcx FnDecl<'_>, generics: &'tcx Generics<'_>) {
476476
let hs = generics
477477
.params
478478
.iter()

clippy_lints/src/methods/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3109,8 +3109,8 @@ enum OutType {
31093109
}
31103110

31113111
impl OutType {
3112-
fn matches(self, cx: &LateContext<'_, '_>, ty: &hir::FunctionRetTy) -> bool {
3113-
let is_unit = |ty: &hir::Ty| SpanlessEq::new(cx).eq_ty_kind(&ty.kind, &hir::TyKind::Tup(vec![].into()));
3112+
fn matches(self, cx: &LateContext<'_, '_>, ty: &hir::FunctionRetTy<'_>) -> bool {
3113+
let is_unit = |ty: &hir::Ty<'_>| SpanlessEq::new(cx).eq_ty_kind(&ty.kind, &hir::TyKind::Tup(&[]));
31143114
match (self, ty) {
31153115
(Self::Unit, &hir::DefaultReturn(_)) => true,
31163116
(Self::Unit, &hir::Return(ref ty)) if is_unit(ty) => true,
@@ -3122,7 +3122,7 @@ impl OutType {
31223122
}
31233123
}
31243124

3125-
fn is_bool(ty: &hir::Ty) -> bool {
3125+
fn is_bool(ty: &hir::Ty<'_>) -> bool {
31263126
if let hir::TyKind::Path(ref p) = ty.kind {
31273127
match_qpath(p, &["bool"])
31283128
} else {

clippy_lints/src/methods/option_map_unwrap_or.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ struct UnwrapVisitor<'a, 'tcx> {
8383
}
8484

8585
impl<'a, 'tcx> Visitor<'tcx> for UnwrapVisitor<'a, 'tcx> {
86-
fn visit_path(&mut self, path: &'tcx Path, _id: HirId) {
86+
fn visit_path(&mut self, path: &'tcx Path<'_>, _id: HirId) {
8787
self.identifiers.insert(ident(path));
8888
walk_path(self, path);
8989
}
@@ -100,7 +100,7 @@ struct MapExprVisitor<'a, 'tcx> {
100100
}
101101

102102
impl<'a, 'tcx> Visitor<'tcx> for MapExprVisitor<'a, 'tcx> {
103-
fn visit_path(&mut self, path: &'tcx Path, _id: HirId) {
103+
fn visit_path(&mut self, path: &'tcx Path<'_>, _id: HirId) {
104104
if self.identifiers.contains(&ident(path)) {
105105
self.found_identifier = true;
106106
return;
@@ -113,7 +113,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MapExprVisitor<'a, 'tcx> {
113113
}
114114
}
115115

116-
fn ident(path: &Path) -> Symbol {
116+
fn ident(path: &Path<'_>) -> Symbol {
117117
path.segments
118118
.last()
119119
.expect("segments should be composed of at least 1 element")

clippy_lints/src/misc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MiscLints {
237237
&mut self,
238238
cx: &LateContext<'a, 'tcx>,
239239
k: FnKind<'tcx>,
240-
decl: &'tcx FnDecl,
240+
decl: &'tcx FnDecl<'_>,
241241
body: &'tcx Body<'_>,
242242
_: Span,
243243
_: HirId,
@@ -626,7 +626,7 @@ fn non_macro_local(cx: &LateContext<'_, '_>, res: def::Res) -> bool {
626626
}
627627
}
628628

629-
fn check_cast(cx: &LateContext<'_, '_>, span: Span, e: &Expr<'_>, ty: &Ty) {
629+
fn check_cast(cx: &LateContext<'_, '_>, span: Span, e: &Expr<'_>, ty: &Ty<'_>) {
630630
if_chain! {
631631
if let TyKind::Ptr(ref mut_ty) = ty.kind;
632632
if let ExprKind::Lit(ref lit) = e.kind;

0 commit comments

Comments
 (0)