Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tidy: Accommodate rustfmt's preferred layout of stability attributes #66717

Merged
merged 1 commit into from
Nov 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/tools/tidy/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.
Expand Down Expand Up @@ -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"),
};
Expand Down