Make lint work on all members of ast::Item_

This commit is contained in:
Philipp Hansch 2018-01-23 21:32:06 +01:00
parent 83909398d2
commit aade0d563e
No known key found for this signature in database
GPG key ID: 667C8F4B5A698A60
5 changed files with 50 additions and 5 deletions

View file

@ -203,7 +203,7 @@ fn is_relevant_item(tcx: TyCtxt, item: &Item) -> bool {
if let ItemFn(_, _, _, _, _, eid) = item.node {
is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.hir.body(eid).value)
} else {
false
true
}
}

View file

@ -24,6 +24,29 @@ fn with_one_newline() { assert!(true) }
fn with_two_newlines() { assert!(true) }
// This should produce a warning
#[crate_type = "lib"]
enum Baz {
One,
Two
}
// This should produce a warning
#[crate_type = "lib"]
struct Foo {
one: isize,
two: isize
}
// This should produce a warning
#[crate_type = "lib"]
mod foo {
}
// This should not produce a warning
#[allow(non_camel_case_types)]
#[allow(missing_docs)]

View file

@ -26,5 +26,29 @@ error: Found an empty line after an outer attribute. Perhaps you forgot to add a
25 | | fn with_two_newlines() { assert!(true) }
| |_
error: aborting due to 3 previous errors
error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute?
--> $DIR/empty_line_after_outer_attribute.rs:29:1
|
29 | / #[crate_type = "lib"]
30 | |
31 | | enum Baz {
| |_
error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute?
--> $DIR/empty_line_after_outer_attribute.rs:37:1
|
37 | / #[crate_type = "lib"]
38 | |
39 | | struct Foo {
| |_
error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute?
--> $DIR/empty_line_after_outer_attribute.rs:45:1
|
45 | / #[crate_type = "lib"]
46 | |
47 | | mod foo {
| |_
error: aborting due to 6 previous errors

View file

@ -11,7 +11,6 @@ trait Foo {
#[inline(always)]fn always_inline();
#[inline(never)]
fn never_inline();
#[inline]

View file

@ -19,8 +19,7 @@ error: use of `#[inline]` on trait method `never_inline` which has no body
|
13 | #[inline(never)]
| _____-^^^^^^^^^^^^^^^
14 | |
15 | | fn never_inline();
14 | | fn never_inline();
| |____- help: remove
error: aborting due to 3 previous errors