message: Make cargo-the-binary version the same as the Rust version
  Closes
diff: @@ -72,9 +72,9 @@ pub struct CfgInfo {
  }
  pub struct VersionInfo {
  - pub major: String,
  - pub minor: String,
  - pub patch: String,
  + pub major: u8,
  + pub minor: u8,
  + pub patch: u8,
  pub pre_release: Option<String>,
  // Information that's only available when we were built with
  // configure/make, rather than cargo itself.
  @@ -192,12 +192,28 @@ fn handle_cause(cargo_err: &Error, shell: &mut Shell) -> bool {
  }
  pub fn version() -> VersionInfo {
  - macro_rules! env_str {
  - ($name:expr) => { env!($name).to_string() }
  - }
  macro_rules! option_env_str {
  ($name:expr) => { option_env!($name).map(|s| s.to_string()) }
  }
  +
  + // So this is pretty horrible...
  + // There are two versions at play here:
  + // - version of cargo-the-binary, which you see when you type `cargo --version`
  + // - version of cargo-the-library, which you download from crates.io for use
  + // in your projects.
  + //
  + // We want to make the `binary` version the same as the corresponding Rust/rustc release.
  + // At the same time, we want to keep the library version at `0.x`, because Cargo as
  + // a library is (and probably will always be) unstable.
  + //
  + // Historically, Cargo used the same version number for both the binary and the library.
  + // Specifically, rustc 1.x.z was paired with cargo 0.x+1.w.
  + // We continue to use this scheme for the library, but transform it to 1.x.w for the purposes
  + // of `cargo --version`.
  + let major = 1;
  + let minor = env!("CARGO_PKG_VERSION_MINOR").parse::<u8>().unwrap() - 1;
  + let patch = env!("CARGO_PKG_VERSION_PATCH").parse::<u8>().unwrap();
  +
  match option_env!("CFG_RELEASE_CHANNEL") {
  // We have environment variables set up from configure/make.
  Some(_) => {
  @@ -210,9 +226,9 @@ pub fn version() -> VersionInfo {
  }
  });
  VersionInfo {
  - major: env_str!("CARGO_PKG_VERSION_MAJOR"),
  - minor: env_str!("CARGO_PKG_VERSION_MINOR"),
  - patch: env_str!("CARGO_PKG_VERSION_PATCH"),
  + major,
  + minor,
  + patch,
  pre_release: option_env_str!("CARGO_PKG_VERSION_PRE"),
  cfg_info: Some(CfgInfo {
  release_channel: option_env_str!("CFG_RELEASE_CHANNEL").unwrap(),
  @@ -223,9 +239,9 @@ pub fn version() -> VersionInfo {
  // We are being compiled by Cargo itself.
  None => {
  VersionInfo {
  - major: env_str!("CARGO_PKG_VERSION_MAJOR"),
  - minor: env_str!("CARGO_PKG_VERSION_MINOR"),
  - patch: env_str!("CARGO_PKG_VERSION_PATCH"),
  + major,
  + minor,
  + patch,
  pre_release: option_env_str!("CARGO_PKG_VERSION_PRE"),
  cfg_info: None,
  }
  