Skip to content

Commit 4045729

Browse files
committed
Use a whitelist and print nice hints
1 parent 3f6964e commit 4045729

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

src/tools/tidy/src/features.rs

+26-12
Original file line numberDiff line numberDiff line change
@@ -163,24 +163,38 @@ pub fn check(path: &Path, bad: &mut bool) {
163163
}
164164
});
165165

166+
// FIXME get this whitelist empty.
167+
let whitelist = vec![
168+
"abi_ptx", "simd", "safe_suggestion", "macro_reexport",
169+
"more_struct_aliases", "static_recursion", "reflect",
170+
"quote", "cfg_target_has_atomic", "custom_attribute",
171+
"default_type_parameter_fallback", "pushpop_unsafe",
172+
"use_extern_macros", "staged_api", "const_indexing",
173+
"unboxed_closures", "stmt_expr_attributes",
174+
"cfg_target_thread_local", "unwind_attributes",
175+
"inclusive_range_syntax"
176+
];
177+
166178
// Only check the number of lang features.
167179
// Obligatory testing for library features is dumb.
168180
let gate_untested = features.iter()
169181
.filter(|&(_, f)| f.level == Status::Unstable)
170182
.filter(|&(_, f)| !f.has_gate_test)
171-
.count();
183+
.filter(|&(n, _)| !whitelist.contains(&n.as_str()))
184+
.collect::<Vec<_>>();
172185

173-
// FIXME get this number down to zero.
174-
let gate_untested_expected = 94;
186+
for &(name, _) in gate_untested.iter() {
187+
println!("Expected a gate test for the feature '{}'.", name);
188+
println!("Hint: create a file named 'feature-gate-{}.rs' in the compile-fail\
189+
\n test suite, with its failures due to missing usage of\
190+
\n #![feature({})].", name, name);
191+
println!("Hint: If you already have such a test and don't want to rename it,\
192+
\n you can also add a // gate-test-{} line to the test file.",
193+
name);
194+
}
175195

176-
if gate_untested != gate_untested_expected {
177-
print!("Expected {} gate untested features, but found {}. ",
178-
gate_untested_expected, gate_untested);
179-
if gate_untested < gate_untested_expected {
180-
println!("Did you forget to reduce the expected number?");
181-
} else {
182-
println!("Did you forget to add a gate test for your new feature?");
183-
}
196+
if gate_untested.len() > 0 {
197+
println!("Found {} features without a gate test.", gate_untested.len());
184198
*bad = true;
185199
}
186200

@@ -189,7 +203,7 @@ pub fn check(path: &Path, bad: &mut bool) {
189203
}
190204

191205
let mut lines = Vec::new();
192-
for (name, feature) in features {
206+
for (name, feature) in features.iter() {
193207
lines.push(format!("{:<32} {:<8} {:<12} {:<8}",
194208
name,
195209
"lang",

0 commit comments

Comments
 (0)