Skip to content

Commit

Permalink
Add rust-version metadata
Browse files Browse the repository at this point in the history
Follow up to rust-lang/cargo#9967

This didn't make it into 1.56 with the rust-version stabilization, but
only into 1.58.
  • Loading branch information
flip1995 committed Oct 27, 2021
1 parent 7e41be6 commit 23853a3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ pub struct Package {
///
/// This is always `None` if running with a version of Cargo older than 1.39.
pub publish: Option<Vec<String>>,
/// Minimum Supported Rust Version
pub rust_version: Option<String>,
}

impl Package {
Expand Down
1 change: 1 addition & 0 deletions tests/all/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ homepage = "https://github.com/oli-obk/cargo_metadata/"
documentation = "https://docs.rs/cargo_metadata/"
links = "foo"
publish = false
rust-version = "1.58"

[package.metadata.docs.rs]
all-features = true
Expand Down
6 changes: 4 additions & 2 deletions tests/test_samples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ struct TestObject {

#[test]
fn all_the_fields() {
// All the fields currently generated as of 1.49. This tries to exercise as
// All the fields currently generated as of 1.58. This tries to exercise as
// much as possible.
let ver = cargo_version();
let minimum = semver::Version::parse("1.49.0").unwrap();
let minimum = semver::Version::parse("1.58.0").unwrap();
if ver < minimum {
// edition added in 1.30
// rename added in 1.31
Expand All @@ -170,6 +170,7 @@ fn all_the_fields() {
// homepage added in 1.49
// documentation added in 1.49
// path added in 1.51
// rust-version added in 1.58
eprintln!("Skipping all_the_fields test, cargo {} is too old.", ver);
return;
}
Expand Down Expand Up @@ -200,6 +201,7 @@ fn all_the_fields() {
assert!(all.license_file().unwrap().ends_with("tests/all/LICENSE"));
assert_eq!(all.publish, Some(vec![]));
assert_eq!(all.links, Some("foo".to_string()));
assert_eq!(all.rust_version, Some("1.58".to_string()));

assert_eq!(all.dependencies.len(), 8);
let bitflags = all
Expand Down

0 comments on commit 23853a3

Please sign in to comment.