Skip to content

Commit a949e5d

Browse files
committed
feat: Expose 'rust_version' in the Summary
1 parent 693f21e commit a949e5d

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

src/cargo/core/resolver/version_prefs.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,15 @@ mod test {
100100
let pkg_id = pkgid(name, version);
101101
let config = Config::default().unwrap();
102102
let features = BTreeMap::new();
103-
Summary::new(&config, pkg_id, Vec::new(), &features, None::<&String>).unwrap()
103+
Summary::new(
104+
&config,
105+
pkg_id,
106+
Vec::new(),
107+
&features,
108+
None::<&String>,
109+
None::<&String>,
110+
)
111+
.unwrap()
104112
}
105113

106114
fn describe(summaries: &Vec<Summary>) -> String {

src/cargo/core/summary.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct Inner {
2525
features: Rc<FeatureMap>,
2626
checksum: Option<String>,
2727
links: Option<InternedString>,
28+
rust_version: Option<InternedString>,
2829
}
2930

3031
impl Summary {
@@ -34,6 +35,7 @@ impl Summary {
3435
dependencies: Vec<Dependency>,
3536
features: &BTreeMap<InternedString, Vec<InternedString>>,
3637
links: Option<impl Into<InternedString>>,
38+
rust_version: Option<impl Into<InternedString>>,
3739
) -> CargoResult<Summary> {
3840
// ****CAUTION**** If you change anything here that may raise a new
3941
// error, be sure to coordinate that change with either the index
@@ -55,6 +57,7 @@ impl Summary {
5557
features: Rc::new(feature_map),
5658
checksum: None,
5759
links: links.map(|l| l.into()),
60+
rust_version: rust_version.map(|l| l.into()),
5861
}),
5962
})
6063
}
@@ -85,6 +88,10 @@ impl Summary {
8588
self.inner.links
8689
}
8790

91+
pub fn rust_version(&self) -> Option<InternedString> {
92+
self.inner.rust_version
93+
}
94+
8895
pub fn override_id(mut self, id: PackageId) -> Summary {
8996
Rc::make_mut(&mut self.inner).package_id = id;
9097
self

src/cargo/sources/registry/index.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ impl IndexSummary {
814814
features2,
815815
yanked,
816816
links,
817-
rust_version: _,
817+
rust_version,
818818
v,
819819
} = serde_json::from_slice(line)?;
820820
let v = v.unwrap_or(1);
@@ -829,7 +829,7 @@ impl IndexSummary {
829829
features.entry(name).or_default().extend(values);
830830
}
831831
}
832-
let mut summary = Summary::new(config, pkgid, deps, &features, links)?;
832+
let mut summary = Summary::new(config, pkgid, deps, &features, links, rust_version)?;
833833
summary.set_checksum(cksum);
834834
Ok(IndexSummary {
835835
summary,

src/cargo/sources/registry/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ pub struct RegistryPackage<'a> {
293293
///
294294
/// Added in 2023 (see <https://github.com/rust-lang/crates.io/pull/6267>),
295295
/// can be `None` if published before then or if not set in the manifest.
296-
#[allow(dead_code)]
297296
rust_version: Option<InternedString>,
298297
/// The schema version for this entry.
299298
///

src/cargo/util/toml/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2367,6 +2367,7 @@ impl TomlManifest {
23672367
deps,
23682368
me.features.as_ref().unwrap_or(&empty_features),
23692369
package.links.as_deref(),
2370+
rust_version.as_deref().map(InternedString::new),
23702371
)?;
23712372

23722373
let metadata = ManifestMetadata {

0 commit comments

Comments
 (0)