use crate::utils::{snippet_opt, span_lint_and_then};
use if_chain::if_chain;
-use rustc::hir::{BindingAnnotation, BorrowKind, Expr, ExprKind, HirId, Item, Mutability, Pat, PatKind};
-use rustc::impl_lint_pass;
-use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::ty;
use rustc::ty::adjustment::{Adjust, Adjustment};
use rustc_errors::Applicability;
-use rustc_session::declare_tool_lint;
+use rustc_hir::{BindingAnnotation, BorrowKind, Expr, ExprKind, HirId, Item, Mutability, Pat, PatKind};
+use rustc_lint::{LateContext, LateLintPass};
+use rustc_session::{declare_tool_lint, impl_lint_pass};
declare_clippy_lint! {
/// **What it does:** Checks for address of operations (`&`) that are going to
impl_lint_pass!(NeedlessBorrow => [NEEDLESS_BORROW]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow {
- fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
+ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr<'_>) {
if e.span.from_expansion() || self.derived_item.is_some() {
return;
}
}
}
}
- fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
+ fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat<'_>) {
if pat.span.from_expansion() || self.derived_item.is_some() {
return;
}
}
}
- fn check_item(&mut self, _: &LateContext<'a, 'tcx>, item: &'tcx Item) {
+ fn check_item(&mut self, _: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
if item.attrs.iter().any(|a| a.check_name(sym!(automatically_derived))) {
debug_assert!(self.derived_item.is_none());
self.derived_item = Some(item.hir_id);
}
}
- fn check_item_post(&mut self, _: &LateContext<'a, 'tcx>, item: &'tcx Item) {
+ fn check_item_post(&mut self, _: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
if let Some(id) = self.derived_item {
if item.hir_id == id {
self.derived_item = None;