|
2 | 2 |
|
3 | 3 | use crate::reexport::*; |
4 | 4 | use crate::utils::{ |
5 | | - in_macro, last_line_of_span, match_def_path, paths, snippet_opt, span_lint, span_lint_and_sugg, span_lint_and_then, |
| 5 | + in_macro, last_line_of_span, paths, snippet_opt, span_lint, span_lint_and_sugg, span_lint_and_then, |
6 | 6 | without_block_comments, |
7 | 7 | }; |
8 | 8 | use if_chain::if_chain; |
9 | 9 | use rustc::hir::*; |
10 | 10 | use rustc::lint::{ |
11 | 11 | CheckLintNameResult, EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintArray, LintContext, LintPass, |
12 | 12 | }; |
13 | | -use rustc::ty::{self, TyCtxt}; |
| 13 | +use rustc::ty; |
14 | 14 | use rustc::{declare_tool_lint, lint_array}; |
15 | 15 | use rustc_errors::Applicability; |
16 | 16 | use semver::Version; |
@@ -233,7 +233,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass { |
233 | 233 | } |
234 | 234 |
|
235 | 235 | fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { |
236 | | - if is_relevant_item(cx.tcx, item) { |
| 236 | + if is_relevant_item(cx, item) { |
237 | 237 | check_attrs(cx, item.span, item.ident.name, &item.attrs) |
238 | 238 | } |
239 | 239 | match item.node { |
@@ -298,13 +298,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass { |
298 | 298 | } |
299 | 299 |
|
300 | 300 | fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) { |
301 | | - if is_relevant_impl(cx.tcx, item) { |
| 301 | + if is_relevant_impl(cx, item) { |
302 | 302 | check_attrs(cx, item.span, item.ident.name, &item.attrs) |
303 | 303 | } |
304 | 304 | } |
305 | 305 |
|
306 | 306 | fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) { |
307 | | - if is_relevant_trait(cx.tcx, item) { |
| 307 | + if is_relevant_trait(cx, item) { |
308 | 308 | check_attrs(cx, item.span, item.ident.name, &item.attrs) |
309 | 309 | } |
310 | 310 | } |
@@ -357,52 +357,52 @@ fn check_clippy_lint_names(cx: &LateContext<'_, '_>, items: &[NestedMetaItem]) { |
357 | 357 | } |
358 | 358 | } |
359 | 359 |
|
360 | | -fn is_relevant_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item: &Item) -> bool { |
| 360 | +fn is_relevant_item(cx: &LateContext<'_, '_>, item: &Item) -> bool { |
361 | 361 | if let ItemKind::Fn(_, _, _, eid) = item.node { |
362 | | - is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.hir().body(eid).value) |
| 362 | + is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value) |
363 | 363 | } else { |
364 | 364 | true |
365 | 365 | } |
366 | 366 | } |
367 | 367 |
|
368 | | -fn is_relevant_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item: &ImplItem) -> bool { |
| 368 | +fn is_relevant_impl(cx: &LateContext<'_, '_>, item: &ImplItem) -> bool { |
369 | 369 | match item.node { |
370 | | - ImplItemKind::Method(_, eid) => is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.hir().body(eid).value), |
| 370 | + ImplItemKind::Method(_, eid) => is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value), |
371 | 371 | _ => false, |
372 | 372 | } |
373 | 373 | } |
374 | 374 |
|
375 | | -fn is_relevant_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item: &TraitItem) -> bool { |
| 375 | +fn is_relevant_trait(cx: &LateContext<'_, '_>, item: &TraitItem) -> bool { |
376 | 376 | match item.node { |
377 | 377 | TraitItemKind::Method(_, TraitMethod::Required(_)) => true, |
378 | 378 | TraitItemKind::Method(_, TraitMethod::Provided(eid)) => { |
379 | | - is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.hir().body(eid).value) |
| 379 | + is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value) |
380 | 380 | }, |
381 | 381 | _ => false, |
382 | 382 | } |
383 | 383 | } |
384 | 384 |
|
385 | | -fn is_relevant_block<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, tables: &ty::TypeckTables<'_>, block: &Block) -> bool { |
| 385 | +fn is_relevant_block(cx: &LateContext<'_, '_>, tables: &ty::TypeckTables<'_>, block: &Block) -> bool { |
386 | 386 | if let Some(stmt) = block.stmts.first() { |
387 | 387 | match &stmt.node { |
388 | 388 | StmtKind::Local(_) => true, |
389 | | - StmtKind::Expr(expr) | StmtKind::Semi(expr) => is_relevant_expr(tcx, tables, expr), |
| 389 | + StmtKind::Expr(expr) | StmtKind::Semi(expr) => is_relevant_expr(cx, tables, expr), |
390 | 390 | _ => false, |
391 | 391 | } |
392 | 392 | } else { |
393 | | - block.expr.as_ref().map_or(false, |e| is_relevant_expr(tcx, tables, e)) |
| 393 | + block.expr.as_ref().map_or(false, |e| is_relevant_expr(cx, tables, e)) |
394 | 394 | } |
395 | 395 | } |
396 | 396 |
|
397 | | -fn is_relevant_expr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, tables: &ty::TypeckTables<'_>, expr: &Expr) -> bool { |
| 397 | +fn is_relevant_expr(cx: &LateContext<'_, '_>, tables: &ty::TypeckTables<'_>, expr: &Expr) -> bool { |
398 | 398 | match &expr.node { |
399 | | - ExprKind::Block(block, _) => is_relevant_block(tcx, tables, block), |
400 | | - ExprKind::Ret(Some(e)) => is_relevant_expr(tcx, tables, e), |
| 399 | + ExprKind::Block(block, _) => is_relevant_block(cx, tables, block), |
| 400 | + ExprKind::Ret(Some(e)) => is_relevant_expr(cx, tables, e), |
401 | 401 | ExprKind::Ret(None) | ExprKind::Break(_, None) => false, |
402 | 402 | ExprKind::Call(path_expr, _) => { |
403 | 403 | if let ExprKind::Path(qpath) = &path_expr.node { |
404 | 404 | if let Some(fun_id) = tables.qpath_def(qpath, path_expr.hir_id).opt_def_id() { |
405 | | - !match_def_path(tcx, fun_id, &paths::BEGIN_PANIC) |
| 405 | + !cx.match_def_path(fun_id, &paths::BEGIN_PANIC) |
406 | 406 | } else { |
407 | 407 | true |
408 | 408 | } |
|
0 commit comments