Skip to content

Commit 35f6b7b

Browse files
Fix tidy
1 parent 372847d commit 35f6b7b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Diff for: src/tools/tidy/src/features.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub fn check(
112112
let file = entry.path();
113113
let filename = file.file_name().unwrap().to_string_lossy();
114114
let filen_underscore = filename.replace('-', "_").replace(".rs", "");
115-
let filename_is_gate_test = test_filen_gate(&filen_underscore, &mut features);
115+
let filename_gate = test_filen_gate(&filen_underscore, &mut features);
116116

117117
for (i, line) in contents.lines().enumerate() {
118118
let mut err = |msg: &str| {
@@ -128,7 +128,7 @@ pub fn check(
128128
};
129129
match features.get_mut(feature_name) {
130130
Some(f) => {
131-
if filename_is_gate_test {
131+
if filename_gate == Some(feature_name) {
132132
err(&format!(
133133
"The file is already marked as gate test \
134134
through its name, no need for a \
@@ -259,18 +259,18 @@ fn find_attr_val<'a>(line: &'a str, attr: &str) -> Option<&'a str> {
259259
r.captures(line).and_then(|c| c.get(1)).map(|m| m.as_str())
260260
}
261261

262-
fn test_filen_gate(filen_underscore: &str, features: &mut Features) -> bool {
262+
fn test_filen_gate<'f>(filen_underscore: &'f str, features: &mut Features) -> Option<&'f str> {
263263
let prefix = "feature_gate_";
264-
if filen_underscore.starts_with(prefix) {
264+
if let Some(suffix) = filen_underscore.strip_prefix(prefix) {
265265
for (n, f) in features.iter_mut() {
266266
// Equivalent to filen_underscore == format!("feature_gate_{n}")
267-
if &filen_underscore[prefix.len()..] == n {
267+
if suffix == n {
268268
f.has_gate_test = true;
269-
return true;
269+
return Some(suffix);
270270
}
271271
}
272272
}
273-
false
273+
None
274274
}
275275

276276
pub fn collect_lang_features(base_compiler_path: &Path, bad: &mut bool) -> Features {

0 commit comments

Comments
 (0)