Skip to content

Commit

Permalink
[meta] updates for Rust 1.73
Browse files Browse the repository at this point in the history
Consists of a few clippy warnings, and also the ability to parse the new
test panic messages produced by Rust 1.73.
  • Loading branch information
sunshowers committed Sep 27, 2023
1 parent d0e897b commit 6d4b1b7
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 34 deletions.
30 changes: 16 additions & 14 deletions nextest-runner/src/cargo_config/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,17 @@ impl CargoConfigs {
//
// 2 and 3 used to be reversed in older versions of Rust, but this has been fixed as of Rust
// 1.68 (https://github.com/rust-lang/cargo/pull/11077).
let cli_option_iter = self.cli_configs.iter().filter_map(|(source, config)| {
matches!(source, CargoConfigSource::CliOption)
.then(|| DiscoveredConfig::CliOption { config, source })
});
let cli_option_iter = self
.cli_configs
.iter()
.filter(|(source, _)| matches!(source, CargoConfigSource::CliOption))
.map(|(source, config)| DiscoveredConfig::CliOption { config, source });

let cli_file_iter = self.cli_configs.iter().filter_map(|(source, config)| {
matches!(source, CargoConfigSource::File(_))
.then(|| DiscoveredConfig::File { config, source })
});
let cli_file_iter = self
.cli_configs
.iter()
.filter(|(source, _)| matches!(source, CargoConfigSource::File(_)))
.map(|(source, config)| DiscoveredConfig::File { config, source });

let cargo_config_file_iter = self
.discovered
Expand Down Expand Up @@ -222,22 +224,22 @@ fn parse_cli_config(config_str: &str) -> Result<CargoConfig, CargoConfigError> {
return Err(CargoConfigError::InvalidCliConfig {
config_str: config_str.to_owned(),
reason: InvalidCargoCliConfigReason::IncludesNonWhitespaceDecoration,
})?;
});
}
table = nt;
}
Item::Value(v) if v.is_inline_table() => {
return Err(CargoConfigError::InvalidCliConfig {
config_str: config_str.to_owned(),
reason: InvalidCargoCliConfigReason::SetsValueToInlineTable,
})?;
});
}
Item::Value(v) => {
if non_empty_decor(v.decor()) {
return Err(CargoConfigError::InvalidCliConfig {
config_str: config_str.to_owned(),
reason: InvalidCargoCliConfigReason::IncludesNonWhitespaceDecoration,
})?;
});
}
got_to_value = true;
break;
Expand All @@ -246,13 +248,13 @@ fn parse_cli_config(config_str: &str) -> Result<CargoConfig, CargoConfigError> {
return Err(CargoConfigError::InvalidCliConfig {
config_str: config_str.to_owned(),
reason: InvalidCargoCliConfigReason::SetsValueToArrayOfTables,
})?;
});
}
Item::None => {
return Err(CargoConfigError::InvalidCliConfig {
config_str: config_str.to_owned(),
reason: InvalidCargoCliConfigReason::DoesntProvideValue,
})?;
});
}
}
}
Expand All @@ -262,7 +264,7 @@ fn parse_cli_config(config_str: &str) -> Result<CargoConfig, CargoConfigError> {
return Err(CargoConfigError::InvalidCliConfig {
config_str: config_str.to_owned(),
reason: InvalidCargoCliConfigReason::NotDottedKv,
})?;
});
}

let cargo_config: CargoConfig =
Expand Down
6 changes: 3 additions & 3 deletions nextest-runner/src/config/nextest_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl VersionOnlyConfig {
) -> Result<VersionOnlyDeserialize, ConfigParseError> {
let toml_str = std::fs::read_to_string(config_file.as_str()).map_err(|error| {
ConfigParseError::new(
config_file.clone(),
config_file,
tool,
ConfigParseErrorKind::VersionOnlyReadError(error),
)
Expand All @@ -123,14 +123,14 @@ impl VersionOnlyConfig {
let v: VersionOnlyDeserialize =
serde_path_to_error::deserialize(toml_de).map_err(|error| {
ConfigParseError::new(
config_file.clone(),
config_file,
tool,
ConfigParseErrorKind::VersionOnlyDeserializeError(Box::new(error)),
)
})?;
if tool.is_some() && !v.experimental.is_empty() {
return Err(ConfigParseError::new(
config_file.clone(),
config_file,
tool,
ConfigParseErrorKind::ExperimentalFeaturesInToolConfig {
features: v.experimental,
Expand Down
10 changes: 4 additions & 6 deletions nextest-runner/src/config/scripts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ impl<'profile> SetupScripts<'profile> {
) -> Self {
Self::new_with_queries(
profile,
test_list.iter_tests().filter_map(|test| {
test.test_info
.filter_match
.is_match()
.then(|| test.to_test_query())
}),
test_list
.iter_tests()
.filter(|test| test.test_info.filter_match.is_match())
.map(|test| test.to_test_query()),
)
}

Expand Down
5 changes: 2 additions & 3 deletions nextest-runner/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1333,9 +1333,8 @@ mod self_update_errors {

let display_versions: Vec<_> = versions
.iter()
.filter_map(|(v, status)| {
(v.pre.is_empty() && *status == ReleaseStatus::Active).then(|| v.to_string())
})
.filter(|(v, status)| v.pre.is_empty() && *status == ReleaseStatus::Active)
.map(|(v, _)| v.to_string())
.take(DISPLAY_COUNT)
.collect();
let mut display_str = display_versions.join(", ");
Expand Down
13 changes: 7 additions & 6 deletions nextest-runner/src/list/test_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,14 @@ impl<'g> RustTestArtifact<'g> {
match rust_build_meta.non_test_binaries.get(package_id.repr()) {
Some(binaries) => binaries
.iter()
.filter_map(|binary| {
.filter(|binary| {
// Only expose BIN_EXE non-test files.
(binary.kind == RustNonTestBinaryKind::BIN_EXE).then(|| {
// Convert relative paths to absolute ones by joining with the target directory.
let abs_path = rust_build_meta.target_directory.join(&binary.path);
(binary.name.clone(), abs_path)
})
binary.kind == RustNonTestBinaryKind::BIN_EXE
})
.map(|binary| {
// Convert relative paths to absolute ones by joining with the target directory.
let abs_path = rust_build_meta.target_directory.join(&binary.path);
(binary.name.clone(), abs_path)
})
.collect(),
None => BTreeSet::new(),
Expand Down
2 changes: 1 addition & 1 deletion nextest-runner/src/reporter/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ fn to_datetime(system_time: SystemTime) -> DateTime<FixedOffset> {

// This regex works for the default panic handler for Rust -- other panic handlers may not work,
// which is why this is heuristic.
static PANICKED_AT_REGEX_STR: &str = "^thread '([^']+)' panicked at '";
static PANICKED_AT_REGEX_STR: &str = "^thread '([^']+)' panicked at ";
static PANICKED_AT_REGEX: Lazy<Regex> = Lazy::new(|| {
let mut builder = RegexBuilder::new(PANICKED_AT_REGEX_STR);
builder.multi_line(true);
Expand Down
3 changes: 2 additions & 1 deletion nextest-runner/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ impl NextestReleases {
let known_triples = version_data
.locations
.iter()
.filter_map(|data| (data.format == TAR_GZ_SUFFIX).then(|| data.target.clone()))
.filter(|data| data.format == TAR_GZ_SUFFIX)
.map(|data| data.target.clone())
.collect();
UpdateError::NoTargetData {
version: version.clone(),
Expand Down

0 comments on commit 6d4b1b7

Please sign in to comment.