diff options
| author | Tyler Mandry <tmandry@gmail.com> | 2019-11-26 17:56:13 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-11-26 17:56:13 -0600 |
| commit | ac7e60476043899ce8eba40c3d92ccccdaa73c79 (patch) | |
| tree | 78fa123ff7a48be03093ca22194668afb3190798 | |
| parent | 7ef70054224162c8809cac8aa4eb34a2efc5594d (diff) | |
| parent | fdcf854bb9b03ff9f8c60c824f0c6709a38269d0 (diff) | |
Rollup merge of #66717 - dtolnay:tidy, r=Mark-Simulacrum
tidy: Accommodate rustfmt's preferred layout of stability attributes
Previously tidy would require that the `feature = "name_of_feature"` part of the stability attribute was on the same line as the `#[stable(` / `#[unstable(` opening part of the attribute, and that `)]` was on the same line as the last key-value pair.
That didn't work with rustfmt's preferred layout of long attributes, which is like:
```rust
#[unstable(
feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
all supported platforms",
issue = "44930"
)]
```
| -rw-r--r-- | src/tools/tidy/src/features.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index a824546d436..defe85ef46a 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -397,7 +397,8 @@ fn map_lib_features(base_src_path: &Path, } let mut becoming_feature: Option<(&str, Feature)> = None; - for (i, line) in contents.lines().enumerate() { + let mut iter_lines = contents.lines().enumerate().peekable(); + while let Some((i, line)) = iter_lines.next() { macro_rules! err { ($msg:expr) => {{ mf(Err($msg), file, i + 1); @@ -411,7 +412,7 @@ fn map_lib_features(base_src_path: &Path, } if line.ends_with(']') { mf(Ok((name, f.clone())), file, i + 1); - } else if !line.ends_with(',') && !line.ends_with('\\') { + } else if !line.ends_with(',') && !line.ends_with('\\') && !line.ends_with('"') { // We need to bail here because we might have missed the // end of a stability attribute above because the ']' // might not have been at the end of the line. @@ -450,7 +451,9 @@ fn map_lib_features(base_src_path: &Path, } else { continue; }; - let feature_name = match find_attr_val(line, "feature") { + let feature_name = match find_attr_val(line, "feature") + .or_else(|| iter_lines.peek().and_then(|next| find_attr_val(next.1, "feature"))) + { Some(name) => name, None => err!("malformed stability attribute: missing `feature` key"), }; |
