File tree Expand file tree Collapse file tree 2 files changed +54
-6
lines changed Expand file tree Collapse file tree 2 files changed +54
-6
lines changed Original file line number Diff line number Diff line change @@ -76,12 +76,6 @@ impl OptVersionReq {
7676 }
7777
7878 pub fn update_precise ( & mut self , version : & Version ) {
79- assert ! (
80- self . matches( version) ,
81- "cannot update_precise {} to {}" ,
82- self ,
83- version
84- ) ;
8579 use OptVersionReq :: * ;
8680 let version = version. clone ( ) ;
8781 * self = match self {
Original file line number Diff line number Diff line change @@ -391,6 +391,60 @@ fn update_precise() {
391391 . run ( ) ;
392392}
393393
394+ #[ cargo_test]
395+ fn update_precise_mismatched ( ) {
396+ Package :: new ( "serde" , "1.2.0" ) . publish ( ) ;
397+ Package :: new ( "serde" , "1.2.1" ) . publish ( ) ;
398+ Package :: new ( "serde" , "1.6.0" ) . publish ( ) ;
399+
400+ let p = project ( )
401+ . file (
402+ "Cargo.toml" ,
403+ r#"
404+ [package]
405+ name = "bar"
406+ version = "0.0.1"
407+ authors = []
408+
409+ [dependencies]
410+ serde = "~1.2"
411+ "# ,
412+ )
413+ . file ( "src/lib.rs" , "" )
414+ . build ( ) ;
415+
416+ p. cargo ( "check" ) . run ( ) ;
417+
418+ // `1.6.0` does not match `"~1.2"`
419+ p. cargo ( "update serde:1.2 --precise 1.6.0" )
420+ . with_stderr (
421+ "\
422+ [UPDATING] `[..]` index
423+ [ERROR] failed to select a version for the requirement `serde = \" ~1.2\" `
424+ candidate versions found which didn't match: 1.6.0
425+ location searched: `[..]` index (which is replacing registry `crates-io`)
426+ required by package `bar v0.0.1 ([..]/foo)`
427+ perhaps a crate was updated and forgotten to be re-vendored?
428+ " ,
429+ )
430+ . with_status ( 101 )
431+ . run ( ) ;
432+
433+ // `1.9.0` does not exist
434+ p. cargo ( "update serde:1.2 --precise 1.9.0" )
435+ // This terrible error message has been the same for a long time. A fix is more than welcome!
436+ . with_stderr (
437+ "\
438+ [UPDATING] `[..]` index
439+ [ERROR] no matching package named `serde` found
440+ location searched: registry `crates-io`
441+ required by package `bar v0.0.1 ([..]/foo)`
442+ " ,
443+ )
444+ . with_status ( 101 )
445+ . run ( ) ;
446+ }
447+
394448#[ cargo_test]
395449fn update_precise_build_metadata ( ) {
396450 Package :: new ( "serde" , "0.0.1+first" ) . publish ( ) ;
You can’t perform that action at this time.
0 commit comments