rust/compiler/rustc_span/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
..
analyze_source_file remove redundant closures (clippy::redundant_closure) 2021-01-03 13:34:24 +01:00
lev_distance Rework SESSION_GLOBALS API to prevent overwriting it 2021-07-08 16:16:28 +02:00
source_map Split span_to_string into span_to_diagnostic/embeddable_string 2021-05-11 00:04:12 +01:00
symbol Rework SESSION_GLOBALS API to prevent overwriting it 2021-07-08 16:16:28 +02:00
analyze_source_file.rs Fix some clippy lints 2020-12-03 17:08:19 -05:00
caching_source_map_view.rs rustc_span: add span_data_to_lines_and_cols to caching source map view 2020-12-03 18:36:34 -08:00
def_id.rs Encode ExpnId using ExpnHash for incr. comp. 2021-07-17 19:41:08 +02:00
edition.rs fix: wrong word 2021-03-10 09:09:37 +08:00
fatal_error.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
hygiene.rs Auto merge of #87225 - estebank:cleanup, r=oli-obk 2021-07-19 18:44:27 +00:00
lev_distance.rs Edit rustc_span documentation 2020-12-25 14:02:52 -08:00
lib.rs Make the CrateNum part of the ExpnId. 2021-07-17 19:35:33 +02:00
source_map.rs Avoid byte to char position conversions in is_multiline 2021-07-01 13:30:00 +02:00
span_encoding.rs Rework SESSION_GLOBALS API to prevent overwriting it 2021-07-08 16:16:28 +02:00
symbol.rs Auto merge of #87050 - jyn514:no-doc-primitive, r=manishearth 2021-08-16 15:36:44 +00:00
tests.rs Inline implementation of lookup_line 2021-07-08 23:30:53 +02:00