Skip to content

Commit d87b92c

Browse files
committed
refactor(toml): Let schema abstract over duplicate fields
1 parent 778dc4d commit d87b92c

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,17 +2333,6 @@ impl schema::TomlTarget {
23332333
}
23342334
}
23352335

2336-
fn proc_macro(&self) -> Option<bool> {
2337-
self.proc_macro_raw.or(self.proc_macro_raw2).or_else(|| {
2338-
if let Some(types) = self.crate_types() {
2339-
if types.contains(&"proc-macro".to_string()) {
2340-
return Some(true);
2341-
}
2342-
}
2343-
None
2344-
})
2345-
}
2346-
23472336
fn validate_crate_types(&self, target_kind_human: &str, warnings: &mut Vec<String>) {
23482337
if self.crate_type.is_some() && self.crate_type2.is_some() {
23492338
warn_on_deprecated(
@@ -2354,12 +2343,6 @@ impl schema::TomlTarget {
23542343
);
23552344
}
23562345
}
2357-
2358-
fn crate_types(&self) -> Option<&Vec<String>> {
2359-
self.crate_type
2360-
.as_ref()
2361-
.or_else(|| self.crate_type2.as_ref())
2362-
}
23632346
}
23642347

23652348
impl schema::MaybeWorkspaceLints {

src/cargo/util/toml/schema.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,23 @@ impl TomlTarget {
939939
pub fn new() -> TomlTarget {
940940
TomlTarget::default()
941941
}
942+
943+
pub fn proc_macro(&self) -> Option<bool> {
944+
self.proc_macro_raw.or(self.proc_macro_raw2).or_else(|| {
945+
if let Some(types) = self.crate_types() {
946+
if types.contains(&"proc-macro".to_string()) {
947+
return Some(true);
948+
}
949+
}
950+
None
951+
})
952+
}
953+
954+
pub fn crate_types(&self) -> Option<&Vec<String>> {
955+
self.crate_type
956+
.as_ref()
957+
.or_else(|| self.crate_type2.as_ref())
958+
}
942959
}
943960

944961
/// Corresponds to a `target` entry, but `TomlTarget` is already used.

0 commit comments

Comments
 (0)