Skip to content

Commit

Permalink
Auto merge of #12960 - epage:refactor, r=weihanglo
Browse files Browse the repository at this point in the history
refactor(toml): Consistently lead with 'Toml' prefix

### What does this PR try to resolve?

Like with #12954, I noticed this inconsistency while working towards #12801 and wanted to fix it.

### How should we test and review this PR?

### Additional information
  • Loading branch information
bors committed Nov 12, 2023
2 parents 984bd91 + 2c61a70 commit 3eb246c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ impl schema::TomlManifest {
Ok(d)
}
schema::MaybeWorkspace::Defined(schema::TomlDependency::Simple(s)) => {
Ok(schema::DetailedTomlDependency {
Ok(schema::TomlDetailedDependency {
version: Some(s.clone()),
..Default::default()
})
Expand Down Expand Up @@ -1626,7 +1626,7 @@ impl schema::TomlWorkspaceDependency {
default_features_msg(name, None, cx);
}
if self.optional.is_some() || self.features.is_some() || self.public.is_some() {
schema::TomlDependency::Detailed(schema::DetailedTomlDependency {
schema::TomlDependency::Detailed(schema::TomlDetailedDependency {
version: Some(s),
optional: self.optional,
features: self.features.clone(),
Expand Down Expand Up @@ -1715,7 +1715,7 @@ impl<P: ResolveToPath + Clone> schema::TomlDependency<P> {
kind: Option<DepKind>,
) -> CargoResult<Dependency> {
match *self {
schema::TomlDependency::Simple(ref version) => schema::DetailedTomlDependency::<P> {
schema::TomlDependency::Simple(ref version) => schema::TomlDetailedDependency::<P> {
version: Some(version.clone()),
..Default::default()
}
Expand All @@ -1725,7 +1725,7 @@ impl<P: ResolveToPath + Clone> schema::TomlDependency<P> {
}
}

impl schema::DetailedTomlDependency {
impl schema::TomlDetailedDependency {
fn add_features(&mut self, features: Option<Vec<String>>) {
self.features = match (self.features.clone(), features.clone()) {
(Some(dep_feat), Some(inherit_feat)) => Some(
Expand Down Expand Up @@ -1762,7 +1762,7 @@ impl schema::DetailedTomlDependency {
}
}

impl<P: ResolveToPath + Clone> schema::DetailedTomlDependency<P> {
impl<P: ResolveToPath + Clone> schema::TomlDetailedDependency<P> {
fn to_dependency(
&self,
name_in_toml: &str,
Expand Down
8 changes: 4 additions & 4 deletions src/cargo/util/toml/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ pub enum TomlDependency<P: Clone = String> {
/// The simple format is equivalent to a detailed dependency
/// specifying only a version, eg.
/// `package = { version = "<version>" }`
Detailed(DetailedTomlDependency<P>),
Detailed(TomlDetailedDependency<P>),
}

impl TomlDependency {
Expand Down Expand Up @@ -544,7 +544,7 @@ impl<'de, P: Deserialize<'de> + Clone> de::Deserialize<'de> for TomlDependency<P

#[derive(Deserialize, Serialize, Clone, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct DetailedTomlDependency<P: Clone = String> {
pub struct TomlDetailedDependency<P: Clone = String> {
pub version: Option<String>,
pub registry: Option<String>,
/// The URL of the `registry` field.
Expand Down Expand Up @@ -582,14 +582,14 @@ pub struct DetailedTomlDependency<P: Clone = String> {
pub _unused_keys: BTreeMap<String, toml::Value>,
}

impl<P: Clone> DetailedTomlDependency<P> {
impl<P: Clone> TomlDetailedDependency<P> {
pub fn default_features(&self) -> Option<bool> {
self.default_features.or(self.default_features2)
}
}

// Explicit implementation so we avoid pulling in P: Default
impl<P: Clone> Default for DetailedTomlDependency<P> {
impl<P: Clone> Default for TomlDetailedDependency<P> {
fn default() -> Self {
Self {
version: Default::default(),
Expand Down

0 comments on commit 3eb246c

Please sign in to comment.