mirror of https://github.com/rust-lang/rust.git
Rollup merge of #61496 - Mark-Simulacrum:tidy-unbalanced-parens, r=varkor
Do not panic in tidy on unbalanced parentheses in cfg's Fixes #60505
This commit is contained in:
commit
6ad6ef2355
|
@ -204,7 +204,7 @@ fn parse_cfgs<'a>(contents: &'a str) -> Vec<(usize, &'a str)> {
|
||||||
succeeds_non_ident && preceeds_whitespace_and_paren
|
succeeds_non_ident && preceeds_whitespace_and_paren
|
||||||
});
|
});
|
||||||
|
|
||||||
cfgs.map(|i| {
|
cfgs.flat_map(|i| {
|
||||||
let mut depth = 0;
|
let mut depth = 0;
|
||||||
let contents_from = &contents[i..];
|
let contents_from = &contents[i..];
|
||||||
for (j, byte) in contents_from.bytes().enumerate() {
|
for (j, byte) in contents_from.bytes().enumerate() {
|
||||||
|
@ -215,13 +215,15 @@ fn parse_cfgs<'a>(contents: &'a str) -> Vec<(usize, &'a str)> {
|
||||||
b')' => {
|
b')' => {
|
||||||
depth -= 1;
|
depth -= 1;
|
||||||
if depth == 0 {
|
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()
|
}).collect()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue