Commit dede9f5
authored
refactor(compile): Log all ignored unused externs (#16920)
### What does this PR try to resolve?
Shoring up the logging we do for unused dependency lints to help with
debugging and profiling.
This could also be useful for users to get more insight on things we
can't or won't show, like helping hunt down features to deactivate to
reduce unused dependencies (e.g. `cli` on `pulldown-cmark`) or removing
transitively unused dependencies.
### How to test and review this PR?
Running this on `cargo` itself:
```console
$ CARGO_LOG=cargo::core::compiler::unused_deps=debug nargo check
...
2.537113285s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg crypto-common v0.1.6 (normal): ignoring unused extern `typenum`, untracked dependent
2.537569241s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg heapless v0.8.0 (normal): ignoring unused extern `stable_deref_trait`, untracked dependent
2.537758659s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg faster-hex v0.10.0 (normal): ignoring unused extern `heapless`, untracked dependent
2.537984665s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg gix-date v0.15.1 (normal): ignoring unused extern `bstr`, untracked dependent
2.538312867s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg gix-object v0.58.0 (normal): ignoring unused extern `gix_hashtable`, untracked dependent
2.538704975s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg gix-tempfile v21.0.2 (normal): ignoring unused extern `libc`, untracked dependent
2.538762374s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg gix-tempfile v21.0.2 (normal): ignoring unused extern `parking_lot`, untracked dependent
2.539010269s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg gix-commitgraph v0.35.0 (normal): ignoring unused extern `bstr`, untracked dependent
2.539205527s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg libnghttp2-sys v0.1.13+1.68.1 (normal): ignoring unused extern `libc`, untracked dependent
2.539597903s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg curl-sys v0.4.87+curl-8.19.0 (normal): ignoring unused extern `libnghttp2_sys`, untracked dependent
2.539654548s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg curl-sys v0.4.87+curl-8.19.0 (normal): ignoring unused extern `libz_sys`, untracked dependent
2.539711192s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg curl-sys v0.4.87+curl-8.19.0 (normal): ignoring unused extern `openssl_sys`, untracked dependent
2.540319246s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg curl v0.4.49 (normal): ignoring unused extern `openssl_probe`, untracked dependent
2.540373049s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg curl v0.4.49 (normal): ignoring unused extern `openssl_sys`, untracked dependent
2.540811522s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg gix-index v0.49.0 (normal): ignoring unused extern `gix_fs`, untracked dependent
2.541504178s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg gix-revision v0.43.0 (normal): ignoring unused extern `gix_commitgraph`, untracked dependent
2.541560742s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg gix-revision v0.43.0 (normal): ignoring unused extern `nonempty`, untracked dependent
2.541873702s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg nix v0.30.1 (normal): ignoring unused extern `bitflags`, lint is allowed
2.542548816s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg nom v7.1.3 (normal): ignoring unused extern `minimal_lexical`, lint is allowed
2.542935941s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg gix-negotiate v0.29.0 (normal): ignoring unused extern `gix_commitgraph`, untracked dependent
2.542989018s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg gix-negotiate v0.29.0 (normal): ignoring unused extern `gix_object`, untracked dependent
2.543198046s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg tracing-subscriber v0.3.23 (normal): ignoring unused extern `once_cell`, lint is allowed
2.543249959s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg tracing-subscriber v0.3.23 (normal): ignoring unused extern `regex_automata`, lint is allowed
2.543640436s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg git2 v0.20.4 (normal): ignoring unused extern `openssl_sys`, untracked dependent
2.544004330s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg regex v1.12.3 (normal): ignoring unused extern `aho_corasick`, lint is allowed
2.544419766s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg futures v0.3.32 (normal): ignoring unused extern `futures_task`, lint is allowed
2.544564859s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg gix v0.81.0 (normal): ignoring unused extern `gix_revision`, untracked dependent
2.544617049s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg gix v0.81.0 (normal): ignoring unused extern `prodash`, untracked dependent
2.544779907s debug emit_unused_warnings: cargo::core::compiler::unused_deps: pkg rustfix v0.9.6 (normal): ignoring unused extern `tracing`, untracked dependent
Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.54s
```
Doesn't work too well for `--all-targets` because we don't support dev
targets at the moment, so we don't track which externs came from
dependencies vs dev-dependencies.
Also, of note that I found while doing this that confused me at first is
that we don't fingerprint `-Zcargo-lints`, so users can have stale
caches with no unused externs "reported" by rustc to cargo.1 file changed
Lines changed: 55 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | 35 | | |
39 | 36 | | |
| 37 | + | |
40 | 38 | | |
41 | 39 | | |
42 | 40 | | |
| |||
62 | 60 | | |
63 | 61 | | |
64 | 62 | | |
| 63 | + | |
65 | 64 | | |
66 | 65 | | |
67 | 66 | | |
| |||
85 | 84 | | |
86 | 85 | | |
87 | 86 | | |
88 | | - | |
| 87 | + | |
89 | 88 | | |
90 | 89 | | |
91 | 90 | | |
| |||
108 | 107 | | |
109 | 108 | | |
110 | 109 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
119 | 127 | | |
120 | 128 | | |
| 129 | + | |
121 | 130 | | |
122 | 131 | | |
123 | 132 | | |
| |||
146 | 155 | | |
147 | 156 | | |
148 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
149 | 167 | | |
150 | 168 | | |
151 | 169 | | |
| |||
169 | 187 | | |
170 | 188 | | |
171 | 189 | | |
172 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
173 | 202 | | |
174 | 203 | | |
175 | 204 | | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
182 | 213 | | |
183 | 214 | | |
184 | 215 | | |
| |||
205 | 236 | | |
206 | 237 | | |
207 | 238 | | |
208 | | - | |
209 | | - | |
| 239 | + | |
| 240 | + | |
210 | 241 | | |
211 | 242 | | |
212 | | - | |
213 | 243 | | |
214 | 244 | | |
215 | 245 | | |
| |||
293 | 323 | | |
294 | 324 | | |
295 | 325 | | |
296 | | - | |
| 326 | + | |
297 | 327 | | |
298 | 328 | | |
299 | 329 | | |
| |||
0 commit comments