Skip to content

Commit

Permalink
fix: allow the stable toolchain to build the cargo-difftests library
Browse files Browse the repository at this point in the history
  • Loading branch information
dnbln committed May 19, 2024
1 parent c690c3b commit 9f16064
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 33 deletions.
68 changes: 37 additions & 31 deletions cargo-difftests/src/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,39 +503,45 @@ impl<'r> AnalysisContext<'r> {
error_on_invalid_config,
} = config;

let dirty_algorithm = if let AnalysisContextInternal::IndexData { index } = &self.internal
&& index.regions.is_empty()
&& let DirtyAlgorithm::GitDiff {
strategy: GitDiffStrategy::Hunks,
commit,
} = &config.dirty_algorithm
{
let lvl = if *error_on_invalid_config {
log::Level::Error
} else {
log::Level::Warn
};
log::log!(
lvl,
"cannot use GitDiff with strategy hunks on a test index with no regions"
);
log::log!(
lvl,
"hint: you might want to pass the --full-index flag to cargo-difftests"
);
log::log!(lvl, "when compiling the index");

if *error_on_invalid_config {
return Err(DifftestsError::InvalidConfig(
InvalidConfigError::GitDiffHunksOnTestIndexWithNoRegions,
));
}
let dirty_algorithm = if let AnalysisContextInternal::IndexData { index } = &self.internal {
if index.regions.is_empty() {
if let DirtyAlgorithm::GitDiff {
strategy: GitDiffStrategy::Hunks,
commit,
} = &config.dirty_algorithm
{
let lvl = if *error_on_invalid_config {
log::Level::Error
} else {
log::Level::Warn
};
log::log!(
lvl,
"cannot use GitDiff with strategy hunks on a test index with no regions"
);
log::log!(
lvl,
"hint: you might want to pass the --full-index flag to cargo-difftests"
);
log::log!(lvl, "when compiling the index");

if *error_on_invalid_config {
return Err(DifftestsError::InvalidConfig(
InvalidConfigError::GitDiffHunksOnTestIndexWithNoRegions,
));
}

warn!("failling back to GitDiff with FilesOnly");
warn!("failling back to GitDiff with FilesOnly");

DirtyAlgorithm::GitDiff {
strategy: GitDiffStrategy::FilesOnly,
commit: *commit,
DirtyAlgorithm::GitDiff {
strategy: GitDiffStrategy::FilesOnly,
commit: *commit,
}
} else {
dirty_algorithm.clone()
}
} else {
dirty_algorithm.clone()
}
} else {
dirty_algorithm.clone()
Expand Down
2 changes: 0 additions & 2 deletions cargo-difftests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

#![feature(let_chains)]

use std::collections::BTreeSet;
use std::path::PathBuf;

Expand Down

0 comments on commit 9f16064

Please sign in to comment.