@@ -254,6 +254,36 @@ information, even if the diagnostics have been suppressed (such as with an
254
254
}
255
255
```
256
256
257
+ ## Unused Dependency Notifications
258
+
259
+ The options ` --json=unused-externs ` and ` --json=unused-externs-silent ` in
260
+ conjunction with the ` unused-crate-dependencies ` lint will emit JSON structures
261
+ reporting any crate dependencies (specified with ` --extern ` ) which never had any
262
+ symbols referenced. These are intended to be consumed by the build system which
263
+ can then emit diagnostics telling the user to remove the unused dependencies
264
+ from ` Cargo.toml ` (or whatever build-system file defines dependencies).
265
+
266
+ The JSON structure is:
267
+ ``` json
268
+ {
269
+ "lint_level" : " deny" , /* Level of the warning */
270
+ "unused_names" : [
271
+ " foo" /* Names of unused crates, as specified with --extern foo=libfoo.rlib */
272
+ ],
273
+ }
274
+ ```
275
+
276
+ The warn/deny/forbid lint level (as defined either on the command line or in the
277
+ source) dictates the ` lint_level ` in the JSON. With ` unused-externs ` , a
278
+ ` deny ` or ` forbid ` level diagnostic will also cause ` rustc ` to exit with a
279
+ failure exit code.
280
+
281
+ ` unused-externs-silent ` will report the diagnostic the same way, but will not
282
+ cause ` rustc ` to exit with failure - it's up to the consumer to flag failure
283
+ appropriately. (This is needed by Cargo which shares the same dependencies
284
+ across multiple build targets, so it should only report an unused dependency if
285
+ its not used by any of the targets.)
286
+
257
287
[ option-emit ] : command-line-arguments.md#option-emit
258
288
[ option-error-format ] : command-line-arguments.md#option-error-format
259
289
[ option-json ] : command-line-arguments.md#option-json
0 commit comments