Skip to content

Commit 3c40d61

Browse files
committed
Error when precise or aggressive without -p flag
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
1 parent 0a979d3 commit 3c40d61

File tree

2 files changed

+9
-24
lines changed

2 files changed

+9
-24
lines changed

src/bin/cargo/commands/update.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,21 @@ pub fn cli() -> Command {
99
.arg_quiet()
1010
.arg(flag("workspace", "Only update the workspace packages").short('w'))
1111
.arg_package_spec_simple("Package to update")
12-
.arg(flag(
13-
"aggressive",
14-
"Force updating all dependencies of SPEC as well when used with -p",
15-
))
12+
.arg(
13+
flag(
14+
"aggressive",
15+
"Force updating all dependencies of SPEC as well when used with -p",
16+
)
17+
.requires("package"),
18+
)
1619
.arg_dry_run("Don't actually write the lockfile")
1720
.arg(
1821
opt(
1922
"precise",
2023
"Update a single dependency to exactly PRECISE when used with -p",
2124
)
22-
.value_name("PRECISE"),
25+
.value_name("PRECISE")
26+
.requires("package"),
2327
)
2428
.arg_manifest_path()
2529
.after_help("Run `cargo help update` for more detailed information.\n")

src/cargo/ops/cargo_generate_lockfile.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,6 @@ pub fn generate_lockfile(ws: &Workspace<'_>) -> CargoResult<()> {
3636
}
3737

3838
pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoResult<()> {
39-
// Currently this is only a warning, but after a transition period this will become
40-
// a hard error.
41-
// See https://github.com/rust-lang/cargo/issues/10919#issuecomment-1214464756.
42-
// We should declare the `precise` and `aggressive` arguments
43-
// require the `package` argument in the clap.
44-
if opts.aggressive && opts.to_update.is_empty() {
45-
ws.config().shell().warn(
46-
"aggressive is only supported with \"--package <SPEC>\", \
47-
this will become a hard error in a future release.",
48-
)?;
49-
}
50-
51-
if opts.precise.is_some() && opts.to_update.is_empty() {
52-
ws.config().shell().warn(
53-
"precise is only supported with \"--package <SPEC>\", \
54-
this will become a hard error in a future release.",
55-
)?;
56-
}
57-
5839
if opts.aggressive && opts.precise.is_some() {
5940
anyhow::bail!("cannot specify both aggressive and precise simultaneously")
6041
}

0 commit comments

Comments
 (0)