Skip to content

Commit

Permalink
Rollup merge of rust-lang#84531 - Smittyvb:foo-not-feature, r=Mark-Si…
Browse files Browse the repository at this point in the history
…mulacrum

Ignore commented out lines when finding features

This fixes rust-lang#76246, where commented out lines were being detected as features by `tidy`, by ignoring those lines when looking for features. It's still not perfect, since it can be fooled by things like:
```rust
/*
#[unstable(feature = "foo", issue = "1234")]
*/
```
But luckily that never happens in `rustc`, so `foo` now ceases to appear in the unstable book.
  • Loading branch information
jackh726 committed Apr 29, 2021
2 parents 13c3091 + a7e23f4 commit d6a8458
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/tools/tidy/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,15 @@ fn map_lib_features(
continue;
}};
}

lazy_static::lazy_static! {
static ref COMMENT_LINE: Regex = Regex::new(r"^\s*//").unwrap();
}
// exclude commented out lines
if COMMENT_LINE.is_match(line) {
continue;
}

if let Some((ref name, ref mut f)) = becoming_feature {
if f.tracking_issue.is_none() {
f.tracking_issue = find_attr_val(line, "issue").and_then(handle_issue_none);
Expand Down

0 comments on commit d6a8458

Please sign in to comment.