Skip to content

Commit 5da8b85

Browse files
authored
Fix unused workspace dependency for current dir (#691)
This fixes a bug where using the current dir '.' component would cause an incorrect unused-workspace-dependency lint to be triggered.
1 parent e399f29 commit 5da8b85

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
<!-- next-header -->
1010
## [Unreleased] - ReleaseDate
11+
### Fixed
12+
- [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.
13+
1114
## [0.16.0] - 2024-08-02
1215
### Removed
1316
- [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.

src/diag/krate_spans.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,9 @@ fn read_workspace_deps<'k>(
766766
// situations
767767
let dir = km.krate.manifest_path.parent()?;
768768
let path = crate::Path::new(path);
769-
if path.as_str().contains("..") {
769+
770+
// Handle cases of current '.' or parent '..' directories
771+
if path.as_str().contains('.') {
770772
let mut pb = krates.workspace_root().to_owned();
771773
for comp in path.components() {
772774
match comp {

tests/test_data/workspace/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spdx = "0.10"
1717
spdx-old = { version = "0.9", package = "spdx" }
1818
spdx-very-old = { version = "0.8", package = "spdx" }
1919
spdx-git = { git = "https://github.com/EmbarkStudios/spdx.git", tag = "0.7.0", package = "spdx" }
20-
member-one = { path = "crates/member-one" }
20+
member-one = { path = "./crates/member-one" }
2121
member-two = { path = "crates/member-two" }
2222
# Validates we can find workspace dependency sources from non-crates.io registries
2323
crate-two = { version = "0.1.0", registry = "embark-deny-git" }

0 commit comments

Comments
 (0)