Skip to content

Commit 2d42013

Browse files
Rollup merge of rust-lang#42177 - est31:master, r=Mark-Simulacrum
Remove some needless // gate-test- comments Also, add detection to treat such comments as tidy errors. We also remove the found_lib_feature code because it was just repeating the found_feature code. Originally it was intended to allow for gate-test lines for lib features, but apparently nobody missed it.
2 parents d5403b9 + e860655 commit 2d42013

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

src/test/compile-fail-fulldeps/proc-macro/feature-gate-proc_macro.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
// aux-build:attr_proc_macro.rs
12-
// gate-test-proc_macro
1312
#![feature(use_extern_macros)]
1413

1514
extern crate attr_proc_macro;
@@ -21,4 +20,4 @@ struct Foo;
2120

2221
fn main() {
2322
let _ = Foo;
24-
}
23+
}

src/test/compile-fail/feature-gate-global_asm.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// gate-test-global_asm
12-
1311
global_asm!(""); //~ ERROR `global_asm!` is not stable
1412

1513
fn main() {}

src/tools/tidy/src/features.rs

+16-13
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub fn check(path: &Path, bad: &mut bool) {
7070
}
7171

7272
let filen_underscore = filename.replace("-","_").replace(".rs","");
73-
test_filen_gate(&filen_underscore, &mut features);
73+
let filename_is_gate_test = test_filen_gate(&filen_underscore, &mut features);
7474

7575
contents.truncate(0);
7676
t!(t!(File::open(&file), &file).read_to_string(&mut contents));
@@ -92,17 +92,20 @@ pub fn check(path: &Path, bad: &mut bool) {
9292
},
9393
None => continue,
9494
};
95-
let found_feature = features.get_mut(feature_name)
96-
.map(|v| { v.has_gate_test = true; () })
97-
.is_some();
98-
99-
let found_lib_feature = features.get_mut(feature_name)
100-
.map(|v| { v.has_gate_test = true; () })
101-
.is_some();
102-
103-
if !(found_feature || found_lib_feature) {
104-
err(&format!("gate-test test found referencing a nonexistent feature '{}'",
105-
feature_name));
95+
match features.get_mut(feature_name) {
96+
Some(f) => {
97+
if filename_is_gate_test {
98+
err(&format!("The file is already marked as gate test \
99+
through its name, no need for a \
100+
'gate-test-{}' comment",
101+
feature_name));
102+
}
103+
f.has_gate_test = true;
104+
}
105+
None => {
106+
err(&format!("gate-test test found referencing a nonexistent feature '{}'",
107+
feature_name));
108+
}
106109
}
107110
}
108111
});
@@ -265,4 +268,4 @@ pub fn collect_lib_features(base_src_path: &Path,
265268
}
266269
});
267270
lib_features
268-
}
271+
}

0 commit comments

Comments
 (0)