Check trait items
This commit is contained in:
parent
eb300fdad4
commit
2526765fc8
@ -2,8 +2,8 @@
|
||||
use clippy_utils::is_from_proc_macro;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::intravisit::{walk_item, Visitor};
|
||||
use rustc_hir::{GenericParamKind, HirId, Item, ItemKind, ItemLocalId, Node, Pat, PatKind, UsePath};
|
||||
use rustc_hir::intravisit::{walk_item, walk_trait_item, Visitor};
|
||||
use rustc_hir::{GenericParamKind, HirId, Item, ItemKind, ItemLocalId, Node, Pat, PatKind, TraitItem, UsePath};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_middle::lint::in_external_macro;
|
||||
use rustc_session::impl_lint_pass;
|
||||
@ -66,6 +66,14 @@ fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
|
||||
walk_item(&mut IdentVisitor { conf: self, cx }, item);
|
||||
}
|
||||
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'_>, item: &TraitItem<'_>) {
|
||||
if self.min_ident_chars_threshold == 0 {
|
||||
return;
|
||||
}
|
||||
|
||||
walk_trait_item(&mut IdentVisitor { conf: self, cx }, item);
|
||||
}
|
||||
|
||||
// This is necessary as `Node::Pat`s are not visited in `visit_id`. :/
|
||||
fn check_pat(&mut self, cx: &LateContext<'_>, pat: &Pat<'_>) {
|
||||
if let PatKind::Binding(_, _, ident, ..) = pat.kind
|
||||
|
@ -37,6 +37,12 @@ struct Vec4 {
|
||||
|
||||
struct AA<T, E>(T, E);
|
||||
|
||||
trait Trait {
|
||||
const A: u32 = 0;
|
||||
type A;
|
||||
fn a() {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Allowed idents
|
||||
let w = 1;
|
||||
|
@ -68,112 +68,130 @@ LL | F,
|
||||
| ^
|
||||
|
||||
error: this ident consists of a single char
|
||||
--> $DIR/min_ident_chars.rs:51:9
|
||||
--> $DIR/min_ident_chars.rs:41:11
|
||||
|
|
||||
LL | const A: u32 = 0;
|
||||
| ^
|
||||
|
||||
error: this ident consists of a single char
|
||||
--> $DIR/min_ident_chars.rs:42:10
|
||||
|
|
||||
LL | type A;
|
||||
| ^
|
||||
|
||||
error: this ident consists of a single char
|
||||
--> $DIR/min_ident_chars.rs:43:8
|
||||
|
|
||||
LL | fn a() {}
|
||||
| ^
|
||||
|
||||
error: this ident consists of a single char
|
||||
--> $DIR/min_ident_chars.rs:57:9
|
||||
|
|
||||
LL | let h = 1;
|
||||
| ^
|
||||
|
||||
error: this ident consists of a single char
|
||||
--> $DIR/min_ident_chars.rs:52:9
|
||||
--> $DIR/min_ident_chars.rs:58:9
|
||||
|
|
||||
LL | let e = 2;
|
||||
| ^
|
||||
|
||||
error: this ident consists of a single char
|
||||
--> $DIR/min_ident_chars.rs:53:9
|
||||
--> $DIR/min_ident_chars.rs:59:9
|
||||
|
|
||||
LL | let l = 3;
|
||||
| ^
|
||||
|
||||
error: this ident consists of a single char
|
||||
--> $DIR/min_ident_chars.rs:54:9
|
||||
--> $DIR/min_ident_chars.rs:60:9
|
||||
|
|
||||
LL | let l = 4;
|
||||
| ^
|
||||
|
||||
error: this ident consists of a single char
|
||||
--> $DIR/min_ident_chars.rs:55:9
|
||||
--> $DIR/min_ident_chars.rs:61:9
|
||||
|
|
||||
LL | let o = 6;
|
||||
| ^
|
||||
|
||||
error: this ident consists of a single char
|
||||
--> $DIR/min_ident_chars.rs:59:10
|
||||
--> $DIR/min_ident_chars.rs:65:10
|
||||
|
|
||||
LL | let (h, o, w) = (1, 2, 3);
|
||||
| ^
|
||||
|
||||
error: this ident consists of a single char
|
||||
--> $DIR/min_ident_chars.rs:59:13
|
||||
--> $DIR/min_ident_chars.rs:65:13
|
||||
|
|
||||
LL | let (h, o, w) = (1, 2, 3);
|
||||
| ^
|
||||
|
||||
error: this ident consists of a single char
|
||||
--> $DIR/min_ident_chars.rs:60:10
|
||||
--> $DIR/min_ident_chars.rs:66:10
|
||||
|
|
||||
LL | for (a, (r, e)) in (0..1000).enumerate().enumerate() {}
|
||||
| ^
|
||||
|
||||
error: this ident consists of a single char
|
||||
--> $DIR/min_ident_chars.rs:60:14
|
||||
--> $DIR/min_ident_chars.rs:66:14
|
||||
|
|
||||
LL | for (a, (r, e)) in (0..1000).enumerate().enumerate() {}
|
||||
| ^
|
||||
|
||||
error: this ident consists of a single char
|
||||
--> $DIR/min_ident_chars.rs:60:17
|
||||
--> $DIR/min_ident_chars.rs:66:17
|
||||
|
|
||||
LL | for (a, (r, e)) in (0..1000).enumerate().enumerate() {}
|
||||
| ^
|
||||
|
||||
error: this ident consists of a single char
|
||||
--> $DIR/min_ident_chars.rs:62:16
|
||||
--> $DIR/min_ident_chars.rs:68:16
|
||||
|
|
||||
LL | while let (d, o, _i, n, g) = (true, true, false, false, true) {}
|
||||
| ^
|
||||
|
||||
error: this ident consists of a single char
|
||||
--> $DIR/min_ident_chars.rs:62:19
|
||||
--> $DIR/min_ident_chars.rs:68:19
|
||||
|
|
||||
LL | while let (d, o, _i, n, g) = (true, true, false, false, true) {}
|
||||
| ^
|
||||
|
||||
error: this ident consists of a single char
|
||||
--> $DIR/min_ident_chars.rs:62:29
|
||||
--> $DIR/min_ident_chars.rs:68:29
|
||||
|
|
||||
LL | while let (d, o, _i, n, g) = (true, true, false, false, true) {}
|
||||
| ^
|
||||
|
||||
error: this ident consists of a single char
|
||||
--> $DIR/min_ident_chars.rs:66:9
|
||||
--> $DIR/min_ident_chars.rs:72:9
|
||||
|
|
||||
LL | let o = 1;
|
||||
| ^
|
||||
|
||||
error: this ident consists of a single char
|
||||
--> $DIR/min_ident_chars.rs:67:9
|
||||
--> $DIR/min_ident_chars.rs:73:9
|
||||
|
|
||||
LL | let o = O { o };
|
||||
| ^
|
||||
|
||||
error: this ident consists of a single char
|
||||
--> $DIR/min_ident_chars.rs:81:4
|
||||
--> $DIR/min_ident_chars.rs:87:4
|
||||
|
|
||||
LL | fn b() {}
|
||||
| ^
|
||||
|
||||
error: this ident consists of a single char
|
||||
--> $DIR/min_ident_chars.rs:82:21
|
||||
--> $DIR/min_ident_chars.rs:88:21
|
||||
|
|
||||
LL | fn wrong_pythagoras(a: f32, b: f32) -> f32 {
|
||||
| ^
|
||||
|
||||
error: this ident consists of a single char
|
||||
--> $DIR/min_ident_chars.rs:82:29
|
||||
--> $DIR/min_ident_chars.rs:88:29
|
||||
|
|
||||
LL | fn wrong_pythagoras(a: f32, b: f32) -> f32 {
|
||||
| ^
|
||||
|
||||
error: aborting due to 29 previous errors
|
||||
error: aborting due to 32 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user