rust/compiler/rustc_passes/src
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
..
liveness Use iter::zip in compiler/ 2021-03-26 09:32:31 -07:00
check_attr.rs feature gate doc(primitive) 2021-08-16 05:41:16 +00:00
check_const.rs Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
dead.rs rustc: Replace HirIds with LocalDefIds in AccessLevels tables 2021-07-31 19:31:29 +03:00
diagnostic_items.rs Merge the BTreeMap in hir::Crate. 2021-07-25 12:18:56 +02:00
entry.rs Auto merge of #87449 - matthiaskrgr:clippyy_v2, r=nagisa 2021-08-01 09:15:15 +00:00
hir_id_validator.rs GenericParam does not need to be a HIR owner. 2021-03-23 22:47:22 +01:00
hir_stats.rs ast/hir: Rename field-related structures 2021-03-16 11:41:24 +03:00
intrinsicck.rs Remove support for floating-point constants in asm! 2021-05-14 14:58:21 +01:00
lang_items.rs Rollup merge of #86726 - sexxi-goose:use-diagnostic-item-for-rfc2229-migration, r=nikomatsakis 2021-07-08 18:30:33 +02:00
layout_test.rs Only store a LocalDefId in hir::Item. 2021-02-15 19:32:10 +01:00
lib.rs deny using default function in impl const Trait 2021-06-23 19:21:57 +08:00
lib_features.rs Use () for lang items. 2021-05-12 13:58:45 +02:00
liveness.rs Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
loops.rs Do not suggest using a break label when one is already present 2021-01-21 21:43:29 -08:00
naked_functions.rs Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
reachable.rs Fix reachable_set for non-function items in non-library crates 2021-08-15 02:59:53 +08:00
region.rs Use correct drop scopes for if expressions 2021-08-15 16:05:25 -03:00
stability.rs rustc: Replace HirIds with LocalDefIds in AccessLevels tables 2021-07-31 19:31:29 +03:00
upvars.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
weak_lang_items.rs Rename all_crate_nums query to crates and remove useless wrapper 2021-07-01 16:51:11 +02:00