use check_path instead of check_expr
This commit is contained in:
parent
157e7974af
commit
16acf7d618
@ -1,7 +1,7 @@
|
||||
//! Some lints that are only useful in the compiler or crates that use compiler internals, such as
|
||||
//! Clippy.
|
||||
|
||||
use crate::hir::{Expr, ExprKind, PatKind, Path, QPath, Ty, TyKind};
|
||||
use crate::hir::{HirId, Path, QPath, Ty, TyKind};
|
||||
use crate::lint::{
|
||||
EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintArray, LintContext, LintPass,
|
||||
};
|
||||
@ -81,27 +81,7 @@ impl LintPass for TyKindUsage {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TyKindUsage {
|
||||
fn check_expr(&mut self, cx: &LateContext<'_, '_>, expr: &'tcx Expr) {
|
||||
let qpaths = match &expr.node {
|
||||
ExprKind::Match(_, arms, _) => {
|
||||
let mut qpaths = vec![];
|
||||
for arm in arms {
|
||||
for pat in &arm.pats {
|
||||
match &pat.node {
|
||||
PatKind::Path(qpath) | PatKind::TupleStruct(qpath, ..) => {
|
||||
qpaths.push(qpath)
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
qpaths
|
||||
}
|
||||
ExprKind::Path(qpath) => vec![qpath],
|
||||
_ => vec![],
|
||||
};
|
||||
for qpath in qpaths {
|
||||
if let QPath::Resolved(_, path) = qpath {
|
||||
fn check_path(&mut self, cx: &LateContext<'_, '_>, path: &'tcx Path, _: HirId) {
|
||||
let segments_iter = path.segments.iter().rev().skip(1).rev();
|
||||
|
||||
if let Some(last) = segments_iter.clone().last() {
|
||||
@ -134,8 +114,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TyKindUsage {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn check_ty(&mut self, cx: &LateContext<'_, '_>, ty: &'tcx Ty) {
|
||||
if let TyKind::Path(qpath) = &ty.node {
|
||||
|
Loading…
Reference in New Issue
Block a user