Use new_all_targets in cargo-fix when no target selection exists

This commit is contained in:
Weihang Lo 2022-01-20 11:41:12 +08:00
parent 0a73f8b9fd
commit ecbaec1a9f
No known key found for this signature in database
GPG key ID: D7DBF189825E82E7

View file

@ -1,6 +1,6 @@
use crate::command_prelude::*;
use cargo::ops::{self, CompileFilter, FilterRule, LibRule};
use cargo::ops;
pub fn cli() -> App {
subcommand("fix")
@ -76,15 +76,9 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
let mut opts =
args.compile_options(config, mode, Some(&ws), ProfileChecking::LegacyTestOnly)?;
if let CompileFilter::Default { .. } = opts.filter {
opts.filter = CompileFilter::Only {
all_targets: true,
lib: LibRule::Default,
bins: FilterRule::All,
examples: FilterRule::All,
benches: FilterRule::All,
tests: FilterRule::All,
}
if !opts.filter.is_specific() {
// cargo fix with no target selection implies `--all-targets`.
opts.filter = ops::CompileFilter::new_all_targets();
}
ops::fix(