File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -523,8 +523,16 @@ impl SourceId {
523523 version : semver:: Version ,
524524 precise : & str ,
525525 ) -> CargoResult < SourceId > {
526- let precise = semver:: Version :: parse ( precise)
527- . with_context ( || format ! ( "invalid version format for precise version `{precise}`" ) ) ?;
526+ let precise = semver:: Version :: parse ( precise) . with_context ( || {
527+ if let Some ( stripped) = precise. strip_prefix ( "v" ) {
528+ return format ! (
529+ "the version provided, `{precise}` is not a \
530+ valid SemVer version\n \n \
531+ help: try changing the version to `{stripped}`",
532+ ) ;
533+ }
534+ format ! ( "invalid version format for precise version `{precise}`" )
535+ } ) ?;
528536
529537 Ok ( SourceId :: wrap ( SourceIdInner {
530538 precise : Some ( Precise :: Updated {
Original file line number Diff line number Diff line change @@ -2737,7 +2737,9 @@ fn prefixed_v_in_version() {
27372737 p. cargo ( "update bar --precise v1.0.1" )
27382738 . with_status ( 101 )
27392739 . with_stderr_data ( str![ [ r#"
2740- [ERROR] invalid version format for precise version `v1.0.1`
2740+ [ERROR] the version provided, `v1.0.1` is not a valid SemVer version
2741+
2742+ [HELP] try changing the version to `1.0.1`
27412743
27422744Caused by:
27432745 unexpected character 'v' while parsing major version number
You can’t perform that action at this time.
0 commit comments