Skip to content

Commit

Permalink
Reorder code
Browse files Browse the repository at this point in the history
commit-id:7e15b5ed
  • Loading branch information
mkaput committed May 18, 2023
1 parent 73a1b84 commit 79fc465
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions scarb/src/core/manifest/toml_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,29 @@ impl TomlManifest {
Ok(targets)
}

fn check_unique_targets(targets: &[Target], package_name: &str) -> Result<()> {
let mut used = HashSet::with_capacity(targets.len());
for target in targets {
if !used.insert((target.kind.as_str(), target.name.as_str())) {
if target.name == package_name {
bail!(
"manifest contains duplicate target definitions `{}`, \
consider explicitly naming targets with the `name` field",
target.kind
)
} else {
bail!(
"manifest contains duplicate target definitions `{} ({})`, \
use different target names to resolve the conflict",
target.kind,
target.name
)
}
}
}
Ok(())
}

fn collect_profiles(&self) -> Result<Vec<Profile>> {
if let Some(toml_profiles) = &self.profile {
let mut result = Vec::new();
Expand Down Expand Up @@ -407,29 +430,6 @@ impl TomlManifest {
Ok(profile_definition.tool)
}
}

fn check_unique_targets(targets: &[Target], package_name: &str) -> Result<()> {
let mut used = HashSet::with_capacity(targets.len());
for target in targets {
if !used.insert((target.kind.as_str(), target.name.as_str())) {
if target.name == package_name {
bail!(
"manifest contains duplicate target definitions `{}`, \
consider explicitly naming targets with the `name` field",
target.kind
)
} else {
bail!(
"manifest contains duplicate target definitions `{} ({})`, \
use different target names to resolve the conflict",
target.kind,
target.name
)
}
}
}
Ok(())
}
}

impl TomlDependency {
Expand Down

0 comments on commit 79fc465

Please sign in to comment.