File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,25 @@ pub fn generate_lockfile(ws: &Workspace<'_>) -> CargoResult<()> {
36
36
}
37
37
38
38
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
+
39
58
if opts. aggressive && opts. precise . is_some ( ) {
40
59
anyhow:: bail!( "cannot specify both aggressive and precise simultaneously" )
41
60
}
Original file line number Diff line number Diff line change @@ -392,6 +392,42 @@ fn update_precise() {
392
392
. run ( ) ;
393
393
}
394
394
395
+ #[ cargo_test]
396
+ fn update_precise_without_package ( ) {
397
+ Package :: new ( "serde" , "0.2.0" ) . publish ( ) ;
398
+
399
+ let p = project ( )
400
+ . file (
401
+ "Cargo.toml" ,
402
+ r#"
403
+ [package]
404
+ name = "bar"
405
+ version = "0.0.1"
406
+ authors = []
407
+
408
+ [dependencies]
409
+ serde = "0.2"
410
+ "# ,
411
+ )
412
+ . file ( "src/lib.rs" , "" )
413
+ . build ( ) ;
414
+
415
+ p. cargo ( "build" ) . run ( ) ;
416
+
417
+ Package :: new ( "serde" , "0.2.1" ) . publish ( ) ;
418
+ Package :: new ( "serde" , "0.3.0" ) . publish ( ) ;
419
+
420
+ p. cargo ( "update --precise 0.3.0" )
421
+ . with_stderr (
422
+ "\
423
+ [WARNING] precise is only supported with \" --package <SPEC>\" , this will become a hard error in a future release.
424
+ [UPDATING] `[..]` index
425
+ [UPDATING] serde v0.2.0 -> v0.2.1
426
+ " ,
427
+ )
428
+ . run ( ) ;
429
+ }
430
+
395
431
// cargo update should respect its arguments even without a lockfile.
396
432
// See issue "Running cargo update without a Cargo.lock ignores arguments"
397
433
// at <https://github.com/rust-lang/cargo/issues/6872>.
You can’t perform that action at this time.
0 commit comments