Skip to content

Commit

Permalink
Warn on version req with metadata.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Apr 1, 2019
1 parent ede459e commit 70e4e87
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,17 @@ impl DetailedTomlDependency {
cx.warnings.push(msg);
}

if let Some(version) = &self.version {
if version.contains('+') {
cx.warnings.push(format!(
"version requirement `{}` for dependency `{}` \
includes semver metadata which will be ignored, removing the \
metadata is recommended to avoid confusion",
version, name_in_toml
));
}
}

if self.git.is_none() {
let git_only_keys = [
(&self.branch, "branch"),
Expand Down
22 changes: 22 additions & 0 deletions tests/testsuite/bad_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1280,3 +1280,25 @@ Caused by:
)
.run();
}

#[test]
fn warn_semver_metadata() {
Package::new("bar", "1.0.0").publish();
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "1.0.0"
[dependencies]
bar = "1.0.0+1234"
"#,
)
.file("src/lib.rs", "")
.build();
p.cargo("check")
.with_stderr_contains("[WARNING] version requirement `1.0.0+1234` for dependency `bar`[..]")
.run();
}

0 comments on commit 70e4e87

Please sign in to comment.