Skip to content

Commit ff4221a

Browse files
committed
docs(lints): Provide solution for transitive pinning
1 parent b276acc commit ff4221a

3 files changed

Lines changed: 6 additions & 13 deletions

File tree

src/cargo/lints/rules/unused_dependencies.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ Examples:
5252
5353
There can be false positives when depending on a transitive dependency to activate a feature.
5454
55-
There an be false positives when pinning the version of a transitive dependency in `Cargo.toml`.
55+
For false positives from pinning the version of a transitive dependency in `Cargo.toml`,
56+
move the dependency to the `target."cfg(false)".dependencies` table.
5657
5758
### Example
5859

src/doc/src/reference/lints.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,8 @@ Examples:
450450

451451
There can be false positives when depending on a transitive dependency to activate a feature.
452452

453-
There an be false positives when pinning the version of a transitive dependency in `Cargo.toml`.
453+
For false positives from pinning the version of a transitive dependency in `Cargo.toml`,
454+
move the dependency to the `target."cfg(false)".dependencies` table.
454455

455456
### Example
456457

tests/testsuite/lints/unused_dependencies.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,8 @@ fn pinned_transitive_dep() {
12121212
12131213
[dependencies]
12141214
intermediate = "0.1.0"
1215+
1216+
[target."cfg(false)".dependencies]
12151217
transitive = "=0.1.1"
12161218
12171219
[lints.cargo]
@@ -1237,17 +1239,6 @@ fn pinned_transitive_dep() {
12371239
[CHECKING] transitive v0.1.1
12381240
[CHECKING] intermediate v0.1.0
12391241
[CHECKING] foo v0.1.0 ([ROOT]/foo)
1240-
[WARNING] unused dependency
1241-
--> Cargo.toml:10:13
1242-
|
1243-
10 | transitive = "=0.1.1"
1244-
| ^^^^^^^^^^^^^^^^^^^^^
1245-
|
1246-
= [NOTE] `cargo::unused_dependencies` is set to `warn` by default
1247-
[HELP] remove the dependency
1248-
|
1249-
10 - transitive = "=0.1.1"
1250-
|
12511242
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
12521243
12531244
"#]])

0 commit comments

Comments
 (0)