Commit bc6f531
authored
Rollup merge of rust-lang#158468 - obi1kenobi:pg/default-body-stability, r=GuillaumeGomez
Include default-stability info in rustdoc JSON.
Add a `default_unstable` field on associated constants, associated types, and functions. The field is populated only when those items appear inside a trait, only when there's a default present, and when that default is not stable as designated by `#[rustc_default_body_unstable]`. In such a case, the field contains the name of the feature required to use the unstable default.
The purpose of this info is to allow `cargo-semver-checks` to lint the standard library for accidental breakage of stable APIs. Removing a stable default is an example of such breakage, while removing an _unstable_ default is not.
The field is boxed to minimize the size impact on its enclosing type, since for regular crates it will always be `None`.
I also updated `jsondoclint` to assert that it's an error to have a populated `default_unstable` when there's no function body, no default const value, or no default associated type. In the process, I noticed that `jsondoclint` and `jsondocck` are both on edition 2021 — I plan to upgrade them to 2024 in separate PRs.
r? @GuillaumeGomez
**AI disclosure:** This PR is the product of a combination of manual work and AI tools. I secured approval in advance from the designated reviewer. I stand behind the quality of the code I'm submitting, and I vouch it's as good or better compared to if I had written every line by my own hand.5 files changed
Lines changed: 364 additions & 17 deletions
File tree
- src
- librustdoc/json
- rustdoc-json-types
- tools/jsondoclint/src
- validator
- tests/rustdoc-json/attrs/stability
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
273 | 285 | | |
274 | 286 | | |
275 | 287 | | |
| |||
353 | 365 | | |
354 | 366 | | |
355 | 367 | | |
356 | | - | |
| 368 | + | |
357 | 369 | | |
358 | 370 | | |
359 | | - | |
| 371 | + | |
360 | 372 | | |
361 | 373 | | |
362 | 374 | | |
363 | | - | |
364 | | - | |
365 | | - | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
366 | 383 | | |
367 | | - | |
| 384 | + | |
368 | 385 | | |
369 | 386 | | |
370 | 387 | | |
| |||
385 | 402 | | |
386 | 403 | | |
387 | 404 | | |
388 | | - | |
389 | | - | |
390 | | - | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
391 | 410 | | |
392 | | - | |
| 411 | + | |
393 | 412 | | |
394 | 413 | | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
395 | 424 | | |
396 | 425 | | |
397 | 426 | | |
398 | 427 | | |
399 | 428 | | |
| 429 | + | |
400 | 430 | | |
401 | 431 | | |
402 | 432 | | |
403 | 433 | | |
404 | 434 | | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
405 | 440 | | |
406 | 441 | | |
407 | 442 | | |
| |||
815 | 850 | | |
816 | 851 | | |
817 | 852 | | |
| 853 | + | |
818 | 854 | | |
819 | 855 | | |
820 | 856 | | |
| |||
823 | 859 | | |
824 | 860 | | |
825 | 861 | | |
| 862 | + | |
826 | 863 | | |
827 | 864 | | |
828 | 865 | | |
| |||
972 | 1009 | | |
973 | 1010 | | |
974 | 1011 | | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
975 | 1023 | | |
976 | 1024 | | |
977 | 1025 | | |
| |||
1040 | 1088 | | |
1041 | 1089 | | |
1042 | 1090 | | |
| 1091 | + | |
1043 | 1092 | | |
1044 | 1093 | | |
1045 | 1094 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
118 | | - | |
| 117 | + | |
| 118 | + | |
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
291 | 294 | | |
292 | 295 | | |
293 | 296 | | |
| |||
367 | 370 | | |
368 | 371 | | |
369 | 372 | | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
370 | 386 | | |
371 | 387 | | |
372 | 388 | | |
| |||
379 | 395 | | |
380 | 396 | | |
381 | 397 | | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
382 | 401 | | |
383 | 402 | | |
384 | 403 | | |
| |||
875 | 894 | | |
876 | 895 | | |
877 | 896 | | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
878 | 902 | | |
879 | 903 | | |
880 | 904 | | |
| |||
899 | 923 | | |
900 | 924 | | |
901 | 925 | | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
902 | 931 | | |
903 | 932 | | |
904 | 933 | | |
| |||
1188 | 1217 | | |
1189 | 1218 | | |
1190 | 1219 | | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
1191 | 1226 | | |
1192 | 1227 | | |
1193 | 1228 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
118 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
119 | 133 | | |
120 | 134 | | |
121 | 135 | | |
122 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
123 | 146 | | |
124 | 147 | | |
125 | 148 | | |
| |||
194 | 217 | | |
195 | 218 | | |
196 | 219 | | |
197 | | - | |
| 220 | + | |
198 | 221 | | |
199 | 222 | | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
200 | 235 | | |
201 | 236 | | |
202 | 237 | | |
| |||
0 commit comments