Skip to content

Commit a51759c

Browse files
committed
Moved checks into compile_options(), changed tests
1 parent f1d6a94 commit a51759c

File tree

12 files changed

+126
-197
lines changed

12 files changed

+126
-197
lines changed

src/bin/cargo/commands/bench.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ Compilation can be customized with the `bench` profile in the manifest.
7272

7373
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
7474
let ws = args.workspace(config)?;
75-
let mut compile_opts = args.compile_options(config, CompileMode::Bench)?;
76-
77-
args.check_optional_opts_all(&ws, &compile_opts)?;
75+
let mut compile_opts = args.compile_options(config, CompileMode::Bench, Some(&ws))?;
7876

7977
compile_opts.build_config.release = true;
8078

src/bin/cargo/commands/build.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ the --release flag will use the `release` profile instead.
4848

4949
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
5050
let ws = args.workspace(config)?;
51-
let mut compile_opts = args.compile_options(config, CompileMode::Build)?;
52-
53-
args.check_optional_opts_all(&ws, &compile_opts)?;
51+
let mut compile_opts = args.compile_options(config, CompileMode::Build, Some(&ws))?;
5452

5553
compile_opts.export_dir = args.value_of_path("out-dir", config);
5654
if compile_opts.export_dir.is_some() && !config.cli_unstable().unstable_options {

src/bin/cargo/commands/check.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
6868
}
6969
};
7070
let mode = CompileMode::Check { test };
71-
let compile_opts = args.compile_options(config, mode)?;
72-
73-
args.check_optional_opts_all(&ws, &compile_opts)?;
71+
let compile_opts = args.compile_options(config, mode, Some(&ws))?;
7472

7573
ops::compile(&ws, &compile_opts)?;
7674
Ok(())

src/bin/cargo/commands/doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
5050
let mode = CompileMode::Doc {
5151
deps: !args.is_present("no-deps"),
5252
};
53-
let mut compile_opts = args.compile_options(config, mode)?;
53+
let mut compile_opts = args.compile_options(config, mode, Some(&ws))?;
5454
compile_opts.local_rustdoc_args = if args.is_present("document-private-items") {
5555
Some(vec!["--document-private-items".to_string()])
5656
} else {

src/bin/cargo/commands/fix.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
122122

123123
// Unlike other commands default `cargo fix` to all targets to fix as much
124124
// code as we can.
125-
let mut opts = args.compile_options(config, mode)?;
126-
127-
args.check_optional_opts_all(&ws, &opts)?;
125+
let mut opts = args.compile_options(config, mode, Some(&ws))?;
128126

129127
if let CompileFilter::Default { .. } = opts.filter {
130128
opts.filter = CompileFilter::Only {

src/bin/cargo/commands/install.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,9 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
7878
let registry = args.registry(config)?;
7979

8080
config.reload_rooted_at_cargo_home()?;
81-
let mut compile_opts = args.compile_options(config, CompileMode::Build)?;
82-
83-
if let Ok(ws) = args.workspace(config) {
84-
args.check_optional_opts_example_and_bin(&ws, &compile_opts)?;
85-
}
81+
82+
let workspace = args.workspace(config).ok();
83+
let mut compile_opts = args.compile_options(config, CompileMode::Build, workspace.as_ref())?;
8684

8785
compile_opts.build_config.release = !args.is_present("debug");
8886

src/bin/cargo/commands/run.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ run. If you're passing arguments to both Cargo and the binary, the ones after
3939
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
4040
let ws = args.workspace(config)?;
4141

42-
let mut compile_opts = args.compile_options(config, CompileMode::Build)?;
43-
44-
args.check_optional_opts_example_and_bin(&ws, &compile_opts)?;
42+
let mut compile_opts = args.compile_options(config, CompileMode::Build, Some(&ws))?;
4543

4644
if !args.is_present("example") && !args.is_present("bin") {
4745
let default_runs: Vec<_> = compile_opts

src/bin/cargo/commands/rustc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
6262
return Err(CliError::new(err, 101));
6363
}
6464
};
65-
let mut compile_opts = args.compile_options_for_single_package(config, mode)?;
65+
let mut compile_opts = args.compile_options_for_single_package(config, mode, Some(&ws))?;
6666
let target_args = values(args, "args");
6767
compile_opts.target_rustc_args = if target_args.is_empty() {
6868
None

src/bin/cargo/commands/rustdoc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ the `cargo help pkgid` command.
5151
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
5252
let ws = args.workspace(config)?;
5353
let mut compile_opts =
54-
args.compile_options_for_single_package(config, CompileMode::Doc { deps: false })?;
54+
args.compile_options_for_single_package(config, CompileMode::Doc { deps: false }, Some(&ws))?;
5555
let target_args = values(args, "args");
5656
compile_opts.target_rustdoc_args = if target_args.is_empty() {
5757
None

src/bin/cargo/commands/test.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ To get the list of all options available for the test binaries use this:
9292
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
9393
let ws = args.workspace(config)?;
9494

95-
let mut compile_opts = args.compile_options(config, CompileMode::Test)?;
96-
97-
args.check_optional_opts_all(&ws, &compile_opts)?;
95+
let mut compile_opts = args.compile_options(config, CompileMode::Test, Some(&ws))?;
9896

9997
let doc = args.is_present("doc");
10098
if doc {

0 commit comments

Comments
 (0)