rust/compiler
bors 0035d9dcec Auto merge of #87050 - jyn514:no-doc-primitive, r=manishearth
Add future-incompat lint for `doc(primitive)`

## What is `doc(primitive)`?

`doc(primitive)` is an attribute recognized by rustdoc which adds documentation for the built-in primitive types, such as `usize` and `()`. It has been stable since Rust 1.0.

## Why change anything?

`doc(primitive)` is useless for anyone outside the standard library. Since rustdoc provides no way to combine the documentation on two different primitive items, you can only replace the docs, and since the standard library already provides extensive documentation there is no reason to do so.

While fixing rustdoc's handling of primitive items (https://github.com/rust-lang/rust/pull/87073) I discovered that even rustdoc's existing handling of primitive items was broken if you had more than two crates using it (it would pick randomly between them). That meant both:
- Keeping rustdoc's existing treatment was nigh-impossible, because it was random.
- doc(primitive) was even more useless than it would otherwise be.

The only use-case for this outside the standard library is for no-std libraries which want to link to primitives (https://github.com/rust-lang/rust/issues/73423) which is being fixed in https://github.com/rust-lang/rust/pull/87073.

https://github.com/rust-lang/rust/pull/87073 makes various breaking changes to `doc(primitive)` (breaking in the sense that they change the semantics, not in that they cause code to fail to compile). It's not possible to avoid these and still fix rustdoc's issues.

## What can we do about it?

As shown by the crater run (https://github.com/rust-lang/rust/pull/87050#issuecomment-886166706), no one is actually using doc(primitive), there wasn't a single true regression in the whole run. We can either:
1. Feature gate it completely, breaking anyone who crater missed. They can easily fix the breakage just by removing the attribute.
2. add it to the `INVALID_DOC_ATTRIBUTES` future-incompat lint, and at the same time make it a no-op unless you add a feature gate. That would mean rustdoc has to look at the features of dependent crates, because it needs to know where primitives are defined in order to link to them.
3. add it to `INVALID_DOC_ATTRIBUTES`, but still use it to determine where primitives come from
4. do nothing; the behavior will silently change in https://github.com/rust-lang/rust/pull/87073.

My preference is for 2, but I would also be happy with 1 or 3. I don't think we should silently change the behavior.

This PR currently implements 3.
2021-08-16 15:36:44 +00:00
..
rustc
rustc_apfloat
rustc_arena
rustc_ast Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
rustc_ast_lowering Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
rustc_ast_passes Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
rustc_ast_pretty Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
rustc_attr
rustc_builtin_macros Auto merge of #87581 - Amanieu:asm_clobber_abi, r=nagisa 2021-08-14 22:29:27 +00:00
rustc_codegen_cranelift Implement black_box using intrinsic 2021-08-12 16:16:57 +01:00
rustc_codegen_llvm Auto merge of #87581 - Amanieu:asm_clobber_abi, r=nagisa 2021-08-14 22:29:27 +00:00
rustc_codegen_ssa Replace #[plugin_registrar] with exporting __rustc_plugin_registrar 2021-08-10 14:20:48 +02:00
rustc_data_structures Remove duplicate trait bounds in rustc_data_structures::graph 2021-08-09 08:52:04 -05:00
rustc_driver Reduce verbosity of RUSTC_LOG 2021-08-09 21:39:39 -04:00
rustc_error_codes Rollup merge of #87700 - kornelski:e530text, r=oli-obk 2021-08-11 04:18:36 +09:00
rustc_errors Modify structured suggestion output 2021-08-11 09:46:24 +00:00
rustc_expand Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
rustc_feature feature gate doc(primitive) 2021-08-16 05:41:16 +00:00
rustc_fs_util
rustc_graphviz
rustc_hir Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
rustc_hir_pretty Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
rustc_incremental
rustc_index
rustc_infer Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
rustc_interface Replace #[plugin_registrar] with exporting __rustc_plugin_registrar 2021-08-10 14:20:48 +02:00
rustc_lexer Renamed variable str -> tail for clarity 2021-08-11 13:57:28 +02:00
rustc_lint Auto merge of #84039 - jyn514:uplift-atomic-ordering, r=wesleywiser 2021-08-16 06:36:13 +00:00
rustc_lint_defs Auto merge of #87324 - asquared31415:named-asm-labels, r=Amanieu 2021-08-14 17:33:38 +00:00
rustc_llvm Auto merge of #87798 - durin42:llvm-14, r=nikic 2021-08-08 04:33:22 +00:00
rustc_macros
rustc_metadata Auto merge of #85296 - bjorn3:plugin_cleanup, r=petrochenkov 2021-08-12 04:30:41 +00:00
rustc_middle Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
rustc_mir Auto merge of #83417 - erikdesjardins:enableremovezsts, r=oli-obk 2021-08-14 19:59:08 +00:00
rustc_mir_build Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
rustc_parse Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
rustc_parse_format
rustc_passes Auto merge of #87050 - jyn514:no-doc-primitive, r=manishearth 2021-08-16 15:36:44 +00:00
rustc_plugin_impl Replace #[plugin_registrar] with exporting __rustc_plugin_registrar 2021-08-10 14:20:48 +02:00
rustc_privacy move Constness into TraitPredicate 2021-08-13 09:26:33 +00:00
rustc_query_impl
rustc_query_system
rustc_resolve Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
rustc_save_analysis
rustc_serialize
rustc_session Auto merge of #85296 - bjorn3:plugin_cleanup, r=petrochenkov 2021-08-12 04:30:41 +00:00
rustc_span Auto merge of #87050 - jyn514:no-doc-primitive, r=manishearth 2021-08-16 15:36:44 +00:00
rustc_symbol_mangling Auto merge of #85296 - bjorn3:plugin_cleanup, r=petrochenkov 2021-08-12 04:30:41 +00:00
rustc_target Auto merge of #87581 - Amanieu:asm_clobber_abi, r=nagisa 2021-08-14 22:29:27 +00:00
rustc_trait_selection make check less conservative and add explanation 2021-08-13 09:28:52 +00:00
rustc_traits Try to fix problem 2021-08-13 09:28:50 +00:00
rustc_ty_utils
rustc_type_ir
rustc_typeck Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00