-use crate::utils::{is_try, match_qpath, match_trait_method, paths, span_lint};
+use crate::utils::{is_try, match_trait_method, paths, span_lint};
use rustc_hir as hir;
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};
declare_lint_pass!(UnusedIoAmount => [UNUSED_IO_AMOUNT]);
-impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedIoAmount {
- fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt<'_>) {
+impl<'tcx> LateLintPass<'tcx> for UnusedIoAmount {
+ fn check_stmt(&mut self, cx: &LateContext<'_>, s: &hir::Stmt<'_>) {
let expr = match s.kind {
hir::StmtKind::Semi(ref expr) | hir::StmtKind::Expr(ref expr) => &**expr,
_ => return,
match expr.kind {
hir::ExprKind::Match(ref res, _, _) if is_try(expr).is_some() => {
if let hir::ExprKind::Call(ref func, ref args) = res.kind {
- if let hir::ExprKind::Path(ref path) = func.kind {
- if match_qpath(path, &paths::TRY_INTO_RESULT) && args.len() == 1 {
- check_method_call(cx, &args[0], expr);
- }
+ if matches!(
+ func.kind,
+ hir::ExprKind::Path(hir::QPath::LangItem(hir::LangItem::TryIntoResult, _))
+ ) {
+ check_method_call(cx, &args[0], expr);
}
} else {
check_method_call(cx, res, expr);
}
}
-fn check_method_call(cx: &LateContext<'_, '_>, call: &hir::Expr<'_>, expr: &hir::Expr<'_>) {
+fn check_method_call(cx: &LateContext<'_>, call: &hir::Expr<'_>, expr: &hir::Expr<'_>) {
if let hir::ExprKind::MethodCall(ref path, _, _, _) = call.kind {
let symbol = &*path.ident.as_str();
let read_trait = match_trait_method(cx, call, &paths::IO_READ);