Skip to content

Commit 40797ee

Browse files
committed
tidy: skip lines starting with # in alphabetical check.
These are comment lines in `Cargo.toml` files. But exclude lines starting with `#!` from the skipping, because we want to check them. (Rust `#![feature(...)]` lines.) Also allow empty lines, which are occasionally useful.
1 parent b7bea6e commit 40797ee

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/tools/tidy/src/alphabetical.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
//! ```
1111
//!
1212
//! The following lines are ignored:
13+
//! - Empty lines
1314
//! - Lines that are indented with more or less spaces than the first line
14-
//! - Lines starting with `//`, `#[`, `)`, `]`, `}` if the comment has the same indentation as
15-
//! the first line
15+
//! - Lines starting with `//`, `#` (except those starting with `#!`), `)`, `]`, `}` if the comment
16+
//! has the same indentation as the first line
1617
//!
1718
//! If a line ends with an opening bracket, the line is ignored and the next line will have
1819
//! its extra indentation ignored.
@@ -43,6 +44,10 @@ fn check_section<'a>(
4344
let mut in_split_line = None;
4445

4546
for (line_idx, line) in lines {
47+
if line.is_empty() {
48+
continue;
49+
}
50+
4651
if line.contains(START_MARKER) {
4752
tidy_error!(bad, "{file}:{} found `{START_MARKER}` expecting `{END_MARKER}`", line_idx)
4853
}
@@ -71,7 +76,7 @@ fn check_section<'a>(
7176
let trimmed_line = line.trim_start_matches(' ');
7277

7378
if trimmed_line.starts_with("//")
74-
|| trimmed_line.starts_with("#[")
79+
|| (trimmed_line.starts_with("#") && !trimmed_line.starts_with("#!"))
7580
|| trimmed_line.starts_with(is_close_bracket)
7681
{
7782
continue;

0 commit comments

Comments
 (0)