Skip to content

Commit

Permalink
Fix unused workspace dependency for current dir (#691)
Browse files Browse the repository at this point in the history
This fixes a bug where using the current dir '.' component would cause
an incorrect unused-workspace-dependency lint to be triggered.
  • Loading branch information
Jake-Shadle authored Aug 5, 2024
1 parent e399f29 commit 5da8b85
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- next-header -->
## [Unreleased] - ReleaseDate
### Fixed
- [PR#691](https://github.com/EmbarkStudios/cargo-deny/pull/691) fixed an issue where workspace dependencies that used the current dir '.' path component would incorrectly trigger the `unused-workspace-dependency` lint.

## [0.16.0] - 2024-08-02
### Removed
- [PR#681](https://github.com/EmbarkStudios/cargo-deny/pull/681) finished the deprecation introduced in [PR#611](https://github.com/EmbarkStudios/cargo-deny/pull/611), making the usage of the deprecated fields into errors.
Expand Down
4 changes: 3 additions & 1 deletion src/diag/krate_spans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,9 @@ fn read_workspace_deps<'k>(
// situations
let dir = km.krate.manifest_path.parent()?;
let path = crate::Path::new(path);
if path.as_str().contains("..") {

// Handle cases of current '.' or parent '..' directories
if path.as_str().contains('.') {
let mut pb = krates.workspace_root().to_owned();
for comp in path.components() {
match comp {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_data/workspace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spdx = "0.10"
spdx-old = { version = "0.9", package = "spdx" }
spdx-very-old = { version = "0.8", package = "spdx" }
spdx-git = { git = "https://github.com/EmbarkStudios/spdx.git", tag = "0.7.0", package = "spdx" }
member-one = { path = "crates/member-one" }
member-one = { path = "./crates/member-one" }
member-two = { path = "crates/member-two" }
# Validates we can find workspace dependency sources from non-crates.io registries
crate-two = { version = "0.1.0", registry = "embark-deny-git" }
Expand Down

0 comments on commit 5da8b85

Please sign in to comment.