Skip to content

Commit

Permalink
Rollup merge of rust-lang#61496 - Mark-Simulacrum:tidy-unbalanced-par…
Browse files Browse the repository at this point in the history
…ens, r=varkor

Do not panic in tidy on unbalanced parentheses in cfg's

Fixes rust-lang#60505
  • Loading branch information
Centril authored Jun 4, 2019
2 parents 230345d + 242056c commit 2729d6b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/tools/tidy/src/pal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ fn parse_cfgs<'a>(contents: &'a str) -> Vec<(usize, &'a str)> {
succeeds_non_ident && preceeds_whitespace_and_paren
});

cfgs.map(|i| {
cfgs.flat_map(|i| {
let mut depth = 0;
let contents_from = &contents[i..];
for (j, byte) in contents_from.bytes().enumerate() {
Expand All @@ -215,13 +215,15 @@ fn parse_cfgs<'a>(contents: &'a str) -> Vec<(usize, &'a str)> {
b')' => {
depth -= 1;
if depth == 0 {
return (i, &contents_from[..=j]);
return Some((i, &contents_from[..=j]));
}
}
_ => { }
}
}

unreachable!()
// if the parentheses are unbalanced just ignore this cfg -- it'll be caught when attempting
// to run the compiler, and there's no real reason to lint it separately here
None
}).collect()
}

0 comments on commit 2729d6b

Please sign in to comment.