diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-10-23 08:53:16 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-10-25 07:56:43 +1100 |
| commit | 40797eef5ea3f8d50c98fbb81b0c005f7a358539 (patch) | |
| tree | 2f78c0aa0c5912e72c35baac34c8c07cb6da2e37 /src/tools | |
| parent | b7bea6e46fa1f00d96a779cc75f5a652cf5cdc5d (diff) | |
| download | rust-40797eef5ea3f8d50c98fbb81b0c005f7a358539.tar.gz rust-40797eef5ea3f8d50c98fbb81b0c005f7a358539.zip | |
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.
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/tidy/src/alphabetical.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/tools/tidy/src/alphabetical.rs b/src/tools/tidy/src/alphabetical.rs index dde5bef5a5f..98a8f4a9980 100644 --- a/src/tools/tidy/src/alphabetical.rs +++ b/src/tools/tidy/src/alphabetical.rs @@ -10,9 +10,10 @@ //! ``` //! //! The following lines are ignored: +//! - Empty lines //! - Lines that are indented with more or less spaces than the first line -//! - Lines starting with `//`, `#[`, `)`, `]`, `}` if the comment has the same indentation as -//! the first line +//! - Lines starting with `//`, `#` (except those starting with `#!`), `)`, `]`, `}` if the comment +//! has the same indentation as the first line //! //! If a line ends with an opening bracket, the line is ignored and the next line will have //! its extra indentation ignored. @@ -43,6 +44,10 @@ fn check_section<'a>( let mut in_split_line = None; for (line_idx, line) in lines { + if line.is_empty() { + continue; + } + if line.contains(START_MARKER) { tidy_error!(bad, "{file}:{} found `{START_MARKER}` expecting `{END_MARKER}`", line_idx) } @@ -71,7 +76,7 @@ fn check_section<'a>( let trimmed_line = line.trim_start_matches(' '); if trimmed_line.starts_with("//") - || trimmed_line.starts_with("#[") + || (trimmed_line.starts_with("#") && !trimmed_line.starts_with("#!")) || trimmed_line.starts_with(is_close_bracket) { continue; |
