mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-15 01:17:16 +00:00
d3d3d7d7be
This makes it so that the `empty_line_after_outer_attribute` lint only checks for newlines between the end of the attribute and the beginning of the following item. We need to check for the empty line count being bigger than 2 because now the snippet of valid code contains only `\n` and splitting it produces `["", ""]` Invalid code will contain more than 2 empty strings.
70 lines
1.2 KiB
Rust
70 lines
1.2 KiB
Rust
|
|
#![warn(empty_line_after_outer_attr)]
|
|
|
|
// This should produce a warning
|
|
#[crate_type = "lib"]
|
|
|
|
/// some comment
|
|
fn with_one_newline_and_comment() { assert!(true) }
|
|
|
|
// This should not produce a warning
|
|
#[crate_type = "lib"]
|
|
/// some comment
|
|
fn with_no_newline_and_comment() { assert!(true) }
|
|
|
|
|
|
// This should produce a warning
|
|
#[crate_type = "lib"]
|
|
|
|
fn with_one_newline() { assert!(true) }
|
|
|
|
// This should produce a warning, too
|
|
#[crate_type = "lib"]
|
|
|
|
|
|
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 doc comment should not produce a warning
|
|
|
|
/** This is also a doc comment and should not produce a warning
|
|
*/
|
|
|
|
// This should not produce a warning
|
|
#[allow(non_camel_case_types)]
|
|
#[allow(missing_docs)]
|
|
#[allow(missing_docs)]
|
|
fn three_attributes() { assert!(true) }
|
|
|
|
// This should not produce a warning
|
|
#[doc = "
|
|
Returns the escaped value of the textual representation of
|
|
|
|
"]
|
|
pub fn function() -> bool {
|
|
true
|
|
}
|
|
|
|
fn main() { }
|