diff --git a/src/bin/cargo/commands/update.rs b/src/bin/cargo/commands/update.rs index da33e8d308d..bd3f3de4cbb 100644 --- a/src/bin/cargo/commands/update.rs +++ b/src/bin/cargo/commands/update.rs @@ -9,11 +9,13 @@ pub fn cli() -> Command { .arg_quiet() .arg(flag("workspace", "Only update the workspace packages").short('w')) .arg_package_spec_simple("Package to update") - .arg(flag( - "aggressive", - "Force updating all dependencies of SPEC as well when used with -p", - )) - .arg_dry_run("Don't actually write the lockfile") + .arg( + flag( + "aggressive", + "Force updating all dependencies of SPEC as well when used with -p", + ) + .conflicts_with("precise"), + ) .arg( opt( "precise", @@ -23,6 +25,7 @@ pub fn cli() -> Command { .requires("package"), ) .arg_manifest_path() + .arg_dry_run("Don't actually write the lockfile") .after_help("Run `cargo help update` for more detailed information.\n") } diff --git a/tests/testsuite/cargo_update/help/stdout.log b/tests/testsuite/cargo_update/help/stdout.log index 46b83f32a28..222914423f1 100644 --- a/tests/testsuite/cargo_update/help/stdout.log +++ b/tests/testsuite/cargo_update/help/stdout.log @@ -7,9 +7,9 @@ Options: -w, --workspace Only update the workspace packages -p, --package [] Package to update --aggressive Force updating all dependencies of SPEC as well when used with -p - --dry-run Don't actually write the lockfile --precise Update a single dependency to exactly PRECISE when used with -p --manifest-path Path to Cargo.toml + --dry-run Don't actually write the lockfile -h, --help Print help -v, --verbose... Use verbose output (-vv very verbose/build.rs output) --color Coloring: auto, always, never diff --git a/tests/testsuite/update.rs b/tests/testsuite/update.rs index 1d3ee05b702..d4234535578 100644 --- a/tests/testsuite/update.rs +++ b/tests/testsuite/update.rs @@ -464,6 +464,46 @@ fn update_aggressive() { .run(); } +#[cargo_test] +fn update_aggressive_conflicts_with_precise() { + Package::new("log", "0.1.0").publish(); + Package::new("serde", "0.2.1").dep("log", "0.1").publish(); + + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "bar" + version = "0.0.1" + authors = [] + + [dependencies] + serde = "0.2" + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("check").run(); + + Package::new("log", "0.1.1").publish(); + Package::new("serde", "0.2.2").dep("log", "0.1").publish(); + + p.cargo("update -p serde:0.2.1 --precise 0.2.2 --aggressive") + .with_status(1) + .with_stderr( + "\ +error: the argument '--precise ' cannot be used with '--aggressive' + +Usage: cargo[EXE] update --package [] --precise + +For more information, try '--help'. +", + ) + .run(); +} + // cargo update should respect its arguments even without a lockfile. // See issue "Running cargo update without a Cargo.lock ignores arguments" // at .