1
Fork 0

Review feedback

* Use a match statement.
* Clarify why we can't use `file_stem()`.
* Error if the `:` is missing for Tidy error codes, rather than no-oping.
This commit is contained in:
Eric Arellano 2020-12-08 12:50:52 -07:00
parent a3174de9ff
commit 989edf4a5f
3 changed files with 49 additions and 36 deletions

View file

@ -152,38 +152,42 @@ impl DebugOptions {
None => (setting_str, None), None => (setting_str, None),
Some((k, v)) => (k, Some(v)), Some((k, v)) => (k, Some(v)),
}; };
if option == "allow_unused_expressions" { match option {
allow_unused_expressions = bool_option_val(option, value); "allow_unused_expressions" => {
debug!( allow_unused_expressions = bool_option_val(option, value);
"{} env option `allow_unused_expressions` is set to {}", debug!(
RUSTC_COVERAGE_DEBUG_OPTIONS, allow_unused_expressions "{} env option `allow_unused_expressions` is set to {}",
); RUSTC_COVERAGE_DEBUG_OPTIONS, allow_unused_expressions
} else if option == "counter_format" { );
match value { }
None => { "counter_format" => {
bug!( match value {
"`{}` option in environment variable {} requires one or more \ None => {
plus-separated choices (a non-empty subset of \ bug!(
`id+block+operation`)", "`{}` option in environment variable {} requires one or more \
option, plus-separated choices (a non-empty subset of \
RUSTC_COVERAGE_DEBUG_OPTIONS `id+block+operation`)",
); option,
} RUSTC_COVERAGE_DEBUG_OPTIONS
Some(val) => { );
counter_format = counter_format_option_val(val); }
debug!( Some(val) => {
"{} env option `counter_format` is set to {:?}", counter_format = counter_format_option_val(val);
RUSTC_COVERAGE_DEBUG_OPTIONS, counter_format debug!(
); "{} env option `counter_format` is set to {:?}",
} RUSTC_COVERAGE_DEBUG_OPTIONS, counter_format
}; );
} else { }
bug!( };
"Unsupported setting `{}` in environment variable {}", }
option, _ => {
RUSTC_COVERAGE_DEBUG_OPTIONS bug!(
) "Unsupported setting `{}` in environment variable {}",
} option,
RUSTC_COVERAGE_DEBUG_OPTIONS
)
}
};
} }
} }

View file

@ -85,10 +85,16 @@ fn extract_error_codes(
for line in f.lines() { for line in f.lines() {
let s = line.trim(); let s = line.trim();
if !reached_no_explanation && s.starts_with('E') && s.contains("include_str!(\"") { if !reached_no_explanation && s.starts_with('E') && s.contains("include_str!(\"") {
let err_code = match s.split_once(':') { let err_code = s
None => continue, .split_once(':')
Some((err_code, _)) => err_code.to_owned(), .expect(
}; format!(
"Expected a line with the format `E0xxx: include_str!(\"..\")`, but got {} without a `:` delimiter",
s,
).as_str()
)
.0
.to_owned();
if !error_codes.contains_key(&err_code) { if !error_codes.contains_key(&err_code) {
error_codes.insert(err_code.clone(), false); error_codes.insert(err_code.clone(), false);
} }

View file

@ -19,6 +19,9 @@ pub fn check(path: &Path, bad: &mut bool) {
// //
// For now, just make sure that there is a corresponding // For now, just make sure that there is a corresponding
// `$testname.rs` file. // `$testname.rs` file.
//
// NB: We do not use file_stem() as some file names have multiple `.`s and we
// must strip all of them.
let testname = let testname =
file_path.file_name().unwrap().to_str().unwrap().split_once('.').unwrap().0; file_path.file_name().unwrap().to_str().unwrap().split_once('.').unwrap().0;
if !file_path.with_file_name(testname).with_extension("rs").exists() { if !file_path.with_file_name(testname).with_extension("rs").exists() {