//! we'll be sure to update this documentation!
use std::env;
+use std::str::FromStr;
use util::errors::CargoResult;
+/// The epoch of the compiler (RFC 2052)
+#[derive(Clone, Copy, Debug, Hash, PartialOrd, Ord, Eq, PartialEq)]
+pub enum Epoch {
+ /// The 2015 epoch
+ Epoch2015,
+ /// The 2018 epoch
+ Epoch2018,
+}
+
+impl FromStr for Epoch {
+ type Err = ();
+ fn from_str(s: &str) -> Result<Self, ()> {
+ match s {
+ "2015" => Ok(Epoch::Epoch2015),
+ "2018" => Ok(Epoch::Epoch2018),
+ _ => Err(())
+ }
+ }
+}
+
enum Status {
Stable,
Unstable,
use url::Url;
use core::{Dependency, PackageId, Summary, SourceId, PackageIdSpec};
-use core::{WorkspaceConfig, Features, Feature};
+use core::{WorkspaceConfig, Epoch, Features, Feature};
use util::Config;
use util::toml::TomlManifest;
use util::errors::*;
workspace: WorkspaceConfig,
original: Rc<TomlManifest>,
features: Features,
+ epoch: Epoch,
im_a_teapot: Option<bool>,
}
patch: HashMap<Url, Vec<Dependency>>,
workspace: WorkspaceConfig,
features: Features,
+ epoch: Epoch,
im_a_teapot: Option<bool>,
original: Rc<TomlManifest>) -> Manifest {
Manifest {
patch: patch,
workspace: workspace,
features: features,
+ epoch: epoch,
original: original,
im_a_teapot: im_a_teapot,
}
pub use self::dependency::Dependency;
-pub use self::features::{Features, Feature, CliUnstable};
+pub use self::features::{Epoch, Features, Feature, CliUnstable};
pub use self::manifest::{EitherManifest, VirtualManifest};
pub use self::manifest::{Manifest, Target, TargetKind, Profile, LibKind, Profiles};
pub use self::package::{Package, PackageSet};
use core::{SourceId, Profiles, PackageIdSpec, GitReference, WorkspaceConfig, WorkspaceRootConfig};
use core::{Summary, Manifest, Target, Dependency, PackageId};
-use core::{EitherManifest, VirtualManifest, Features, Feature};
+use core::{EitherManifest, Epoch, VirtualManifest, Features, Feature};
use core::dependency::{Kind, Platform};
use core::manifest::{LibKind, Profile, ManifestMetadata, Lto};
use sources::CRATES_IO;
license_file: Option<String>,
repository: Option<String>,
metadata: Option<toml::Value>,
+ epoch: Option<String>,
}
#[derive(Debug, Deserialize, Serialize)]
Some(VecStringOrBool::Bool(false)) => Some(vec![]),
None | Some(VecStringOrBool::Bool(true)) => None,
};
+
+ let epoch = if let Some(ref epoch) = project.epoch {
+ if let Ok(epoch) = epoch.parse() {
+ epoch
+ } else {
+ bail!("the `epoch` key must be one of: `2015`, `2018`")
+ }
+ } else {
+ Epoch::Epoch2015
+ };
let mut manifest = Manifest::new(summary,
targets,
exclude,
patch,
workspace_config,
features,
+ epoch,
project.im_a_teapot,
Rc::clone(me));
if project.license_file.is_some() && project.license.is_some() {