From a8a40ea9a4947a7b46421564517ee2aa4e3711f0 Mon Sep 17 00:00:00 2001 From: Mukund Lakshman Date: Fri, 1 Oct 2021 06:17:15 -0400 Subject: [PATCH 1/8] librustdoc: Use correct heading levels. - Avoid multiple

s on a page. - The tags should follow a semantic hierarchy. - Cap at h6 (no h7) --- .../src/error_codes/E0001.md | 2 +- .../src/error_codes/E0002.md | 2 +- .../src/error_codes/E0007.md | 2 +- .../src/error_codes/E0009.md | 2 +- .../src/error_codes/E0014.md | 2 +- .../src/error_codes/E0073.md | 2 +- .../src/error_codes/E0074.md | 2 +- .../src/error_codes/E0087.md | 2 +- .../src/error_codes/E0088.md | 2 +- .../src/error_codes/E0089.md | 2 +- .../src/error_codes/E0090.md | 2 +- .../src/error_codes/E0110.md | 2 +- .../src/error_codes/E0136.md | 2 +- .../src/error_codes/E0137.md | 2 +- .../src/error_codes/E0139.md | 2 +- .../src/error_codes/E0154.md | 2 +- .../src/error_codes/E0162.md | 2 +- .../src/error_codes/E0165.md | 2 +- .../src/error_codes/E0193.md | 2 +- .../src/error_codes/E0205.md | 2 +- .../src/error_codes/E0211.md | 2 +- .../src/error_codes/E0243.md | 2 +- .../src/error_codes/E0244.md | 2 +- .../src/error_codes/E0251.md | 2 +- .../src/error_codes/E0256.md | 2 +- .../src/error_codes/E0281.md | 2 +- .../src/error_codes/E0297.md | 2 +- .../src/error_codes/E0301.md | 2 +- .../src/error_codes/E0302.md | 2 +- .../src/error_codes/E0303.md | 2 +- .../src/error_codes/E0329.md | 2 +- .../src/error_codes/E0383.md | 2 +- .../src/error_codes/E0386.md | 2 +- .../src/error_codes/E0387.md | 2 +- .../src/error_codes/E0388.md | 2 +- .../src/error_codes/E0389.md | 2 +- .../src/error_codes/E0398.md | 2 +- .../src/error_codes/E0399.md | 2 +- .../src/error_codes/E0439.md | 2 +- .../src/error_codes/E0447.md | 2 +- .../src/error_codes/E0448.md | 2 +- .../src/error_codes/E0497.md | 2 +- .../src/error_codes/E0504.md | 2 +- .../src/error_codes/E0595.md | 2 +- .../src/error_codes/E0619.md | 2 +- .../src/error_codes/E0633.md | 2 +- .../src/error_codes/E0665.md | 2 +- .../src/error_codes/E0671.md | 2 +- src/librustdoc/externalfiles.rs | 4 +- src/librustdoc/html/markdown.rs | 21 +++++--- src/librustdoc/html/markdown/tests.rs | 32 ++++++------ src/librustdoc/html/render/mod.rs | 52 ++++++++++++++----- src/librustdoc/html/render/print_item.rs | 10 ++-- src/librustdoc/html/static/css/rustdoc.css | 19 ++++--- src/librustdoc/html/static/css/themes/ayu.css | 2 +- .../html/static/css/themes/dark.css | 2 +- .../html/static/css/themes/light.css | 2 +- src/librustdoc/markdown.rs | 2 +- src/test/rustdoc/external-cross.rs | 2 +- src/test/rustdoc/external-doc.rs | 6 +-- src/test/rustdoc/issue-42760.rs | 2 +- src/test/rustdoc/short-docblock.rs | 4 +- src/test/rustdoc/smart-punct.rs | 2 +- src/tools/error_index_generator/main.rs | 3 +- src/tools/tidy/src/error_codes_check.rs | 4 +- 65 files changed, 147 insertions(+), 118 deletions(-) diff --git a/compiler/rustc_error_codes/src/error_codes/E0001.md b/compiler/rustc_error_codes/src/error_codes/E0001.md index 90756780d1502..cd6e15f581f3b 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0001.md +++ b/compiler/rustc_error_codes/src/error_codes/E0001.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. This error suggests that the expression arm corresponding to the noted pattern will never be reached as for all possible values of the expression being diff --git a/compiler/rustc_error_codes/src/error_codes/E0002.md b/compiler/rustc_error_codes/src/error_codes/E0002.md index 5cb59da10e00b..4e7aa7fb9ed81 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0002.md +++ b/compiler/rustc_error_codes/src/error_codes/E0002.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. This error indicates that an empty match expression is invalid because the type it is matching on is non-empty (there exist values of this type). In safe code diff --git a/compiler/rustc_error_codes/src/error_codes/E0007.md b/compiler/rustc_error_codes/src/error_codes/E0007.md index 2c22b86af9246..d30de4af0eb37 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0007.md +++ b/compiler/rustc_error_codes/src/error_codes/E0007.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. This error indicates that the bindings in a match arm would require a value to be moved into more than one location, thus violating unique ownership. Code diff --git a/compiler/rustc_error_codes/src/error_codes/E0009.md b/compiler/rustc_error_codes/src/error_codes/E0009.md index aaabba0434993..6aab44cb4d6ec 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0009.md +++ b/compiler/rustc_error_codes/src/error_codes/E0009.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. In a pattern, all values that don't implement the `Copy` trait have to be bound the same way. The goal here is to avoid binding simultaneously by-move and diff --git a/compiler/rustc_error_codes/src/error_codes/E0014.md b/compiler/rustc_error_codes/src/error_codes/E0014.md index 2c69957e9f642..27ae8f098987a 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0014.md +++ b/compiler/rustc_error_codes/src/error_codes/E0014.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. Constants can only be initialized by a constant value or, in a future version of Rust, a call to a const function. This error indicates the use diff --git a/compiler/rustc_error_codes/src/error_codes/E0073.md b/compiler/rustc_error_codes/src/error_codes/E0073.md index a5aea86ff2d9d..39c16bc438fea 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0073.md +++ b/compiler/rustc_error_codes/src/error_codes/E0073.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. You cannot define a struct (or enum) `Foo` that requires an instance of `Foo` in order to make a new `Foo` value. This is because there would be no way a diff --git a/compiler/rustc_error_codes/src/error_codes/E0074.md b/compiler/rustc_error_codes/src/error_codes/E0074.md index 785d6de226d3d..026acac99e74f 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0074.md +++ b/compiler/rustc_error_codes/src/error_codes/E0074.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. When using the `#[simd]` attribute on a tuple struct, the components of the tuple struct must all be of a concrete, nongeneric type so the compiler can diff --git a/compiler/rustc_error_codes/src/error_codes/E0087.md b/compiler/rustc_error_codes/src/error_codes/E0087.md index 9d292186f0fa5..cd2da0469bb63 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0087.md +++ b/compiler/rustc_error_codes/src/error_codes/E0087.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. Too many type arguments were supplied for a function. For example: diff --git a/compiler/rustc_error_codes/src/error_codes/E0088.md b/compiler/rustc_error_codes/src/error_codes/E0088.md index 7780ad5b56e03..6b565507ce4a3 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0088.md +++ b/compiler/rustc_error_codes/src/error_codes/E0088.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. You gave too many lifetime arguments. Erroneous code example: diff --git a/compiler/rustc_error_codes/src/error_codes/E0089.md b/compiler/rustc_error_codes/src/error_codes/E0089.md index 504fbc7b96a98..b78f95f266c19 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0089.md +++ b/compiler/rustc_error_codes/src/error_codes/E0089.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. Too few type arguments were supplied for a function. For example: diff --git a/compiler/rustc_error_codes/src/error_codes/E0090.md b/compiler/rustc_error_codes/src/error_codes/E0090.md index e091bb6c9f2f7..7b07a86dc25a4 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0090.md +++ b/compiler/rustc_error_codes/src/error_codes/E0090.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. You gave too few lifetime arguments. Example: diff --git a/compiler/rustc_error_codes/src/error_codes/E0110.md b/compiler/rustc_error_codes/src/error_codes/E0110.md index b9fe406ffb9bd..91f599ff1dcfb 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0110.md +++ b/compiler/rustc_error_codes/src/error_codes/E0110.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. You tried to provide a lifetime to a type which doesn't need it. See `E0109` for more details. diff --git a/compiler/rustc_error_codes/src/error_codes/E0136.md b/compiler/rustc_error_codes/src/error_codes/E0136.md index 15cf09a18cbde..0a74558e75b05 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0136.md +++ b/compiler/rustc_error_codes/src/error_codes/E0136.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. More than one `main` function was found. diff --git a/compiler/rustc_error_codes/src/error_codes/E0137.md b/compiler/rustc_error_codes/src/error_codes/E0137.md index d4e19170f3f7b..ba6f02add9494 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0137.md +++ b/compiler/rustc_error_codes/src/error_codes/E0137.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. More than one function was declared with the `#[main]` attribute. diff --git a/compiler/rustc_error_codes/src/error_codes/E0139.md b/compiler/rustc_error_codes/src/error_codes/E0139.md index a116cf29395fa..e7ad2a6f44dc1 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0139.md +++ b/compiler/rustc_error_codes/src/error_codes/E0139.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. There are various restrictions on transmuting between types in Rust; for example types being transmuted must have the same size. To apply all these restrictions, diff --git a/compiler/rustc_error_codes/src/error_codes/E0154.md b/compiler/rustc_error_codes/src/error_codes/E0154.md index e437a71897c66..9c954839eee6b 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0154.md +++ b/compiler/rustc_error_codes/src/error_codes/E0154.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. Imports (`use` statements) are not allowed after non-item statements, such as variable declarations and expression statements. diff --git a/compiler/rustc_error_codes/src/error_codes/E0162.md b/compiler/rustc_error_codes/src/error_codes/E0162.md index 0161c9325c211..2e0f387e3521f 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0162.md +++ b/compiler/rustc_error_codes/src/error_codes/E0162.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. An `if let` pattern attempts to match the pattern, and enters the body if the match was successful. If the match is irrefutable (when it cannot fail to diff --git a/compiler/rustc_error_codes/src/error_codes/E0165.md b/compiler/rustc_error_codes/src/error_codes/E0165.md index 7bcd6c0cbf379..3222b7a87eb65 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0165.md +++ b/compiler/rustc_error_codes/src/error_codes/E0165.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. A `while let` pattern attempts to match the pattern, and enters the body if the match was successful. If the match is irrefutable (when it cannot fail to diff --git a/compiler/rustc_error_codes/src/error_codes/E0193.md b/compiler/rustc_error_codes/src/error_codes/E0193.md index e29a949ffba91..6e7ebbaddf921 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0193.md +++ b/compiler/rustc_error_codes/src/error_codes/E0193.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. `where` clauses must use generic type parameters: it does not make sense to use them otherwise. An example causing this error: diff --git a/compiler/rustc_error_codes/src/error_codes/E0205.md b/compiler/rustc_error_codes/src/error_codes/E0205.md index 7916f53ad3b41..07bbd1f68347b 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0205.md +++ b/compiler/rustc_error_codes/src/error_codes/E0205.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. An attempt to implement the `Copy` trait for an enum failed because one of the variants does not implement `Copy`. To fix this, you must implement `Copy` for diff --git a/compiler/rustc_error_codes/src/error_codes/E0211.md b/compiler/rustc_error_codes/src/error_codes/E0211.md index 77289f019005e..2485367e09712 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0211.md +++ b/compiler/rustc_error_codes/src/error_codes/E0211.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. You used a function or type which doesn't fit the requirements for where it was used. Erroneous code examples: diff --git a/compiler/rustc_error_codes/src/error_codes/E0243.md b/compiler/rustc_error_codes/src/error_codes/E0243.md index 5d3d1828bf59b..ef4a837ec2172 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0243.md +++ b/compiler/rustc_error_codes/src/error_codes/E0243.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. This error indicates that not enough type parameters were found in a type or trait. diff --git a/compiler/rustc_error_codes/src/error_codes/E0244.md b/compiler/rustc_error_codes/src/error_codes/E0244.md index 5187b7b05d2c1..31c5b4542e28f 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0244.md +++ b/compiler/rustc_error_codes/src/error_codes/E0244.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. This error indicates that too many type parameters were found in a type or trait. diff --git a/compiler/rustc_error_codes/src/error_codes/E0251.md b/compiler/rustc_error_codes/src/error_codes/E0251.md index 4121dd27877a0..7b048db5ece3e 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0251.md +++ b/compiler/rustc_error_codes/src/error_codes/E0251.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. Two items of the same name cannot be imported without rebinding one of the items under a new local name. diff --git a/compiler/rustc_error_codes/src/error_codes/E0256.md b/compiler/rustc_error_codes/src/error_codes/E0256.md index 385376cdade91..1b518b1615b64 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0256.md +++ b/compiler/rustc_error_codes/src/error_codes/E0256.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. You can't import a type or module when the name of the item being imported is the same as another type or submodule defined in the module. diff --git a/compiler/rustc_error_codes/src/error_codes/E0281.md b/compiler/rustc_error_codes/src/error_codes/E0281.md index 1d7904b67ddb4..2d8ead0b0181c 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0281.md +++ b/compiler/rustc_error_codes/src/error_codes/E0281.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. You tried to supply a type which doesn't implement some trait in a location which expected that trait. This error typically occurs when working with diff --git a/compiler/rustc_error_codes/src/error_codes/E0297.md b/compiler/rustc_error_codes/src/error_codes/E0297.md index 66c31376d8b28..001e0f3089e15 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0297.md +++ b/compiler/rustc_error_codes/src/error_codes/E0297.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. Patterns used to bind names must be irrefutable. That is, they must guarantee that a name will be extracted in all cases. Instead of pattern matching the diff --git a/compiler/rustc_error_codes/src/error_codes/E0301.md b/compiler/rustc_error_codes/src/error_codes/E0301.md index 485e19fbb8d9c..7b1e02051dc4e 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0301.md +++ b/compiler/rustc_error_codes/src/error_codes/E0301.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. Mutable borrows are not allowed in pattern guards, because matching cannot have side effects. Side effects could alter the matched object or the environment diff --git a/compiler/rustc_error_codes/src/error_codes/E0302.md b/compiler/rustc_error_codes/src/error_codes/E0302.md index e6ac9d590c88f..c56500fcebce8 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0302.md +++ b/compiler/rustc_error_codes/src/error_codes/E0302.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. Assignments are not allowed in pattern guards, because matching cannot have side effects. Side effects could alter the matched object or the environment diff --git a/compiler/rustc_error_codes/src/error_codes/E0303.md b/compiler/rustc_error_codes/src/error_codes/E0303.md index 459906047cc87..750b766f5bfdf 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0303.md +++ b/compiler/rustc_error_codes/src/error_codes/E0303.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. Sub-bindings, e.g. `ref x @ Some(ref y)` are now allowed under `#![feature(bindings_after_at)]` and checked to make sure that diff --git a/compiler/rustc_error_codes/src/error_codes/E0329.md b/compiler/rustc_error_codes/src/error_codes/E0329.md index 37d84a1a89bfe..36114316e8803 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0329.md +++ b/compiler/rustc_error_codes/src/error_codes/E0329.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. An attempt was made to access an associated constant through either a generic type parameter or `Self`. This is not supported yet. An example causing this diff --git a/compiler/rustc_error_codes/src/error_codes/E0383.md b/compiler/rustc_error_codes/src/error_codes/E0383.md index fd2b0b08fb007..309eb2b59eb97 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0383.md +++ b/compiler/rustc_error_codes/src/error_codes/E0383.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. This error occurs when an attempt is made to partially reinitialize a structure that is currently uninitialized. diff --git a/compiler/rustc_error_codes/src/error_codes/E0386.md b/compiler/rustc_error_codes/src/error_codes/E0386.md index de3b468b6e4ac..5e45a2b40cefa 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0386.md +++ b/compiler/rustc_error_codes/src/error_codes/E0386.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. This error occurs when an attempt is made to mutate the target of a mutable reference stored inside an immutable container. diff --git a/compiler/rustc_error_codes/src/error_codes/E0387.md b/compiler/rustc_error_codes/src/error_codes/E0387.md index 38ad19bd6aa9a..ddc838bdca1b3 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0387.md +++ b/compiler/rustc_error_codes/src/error_codes/E0387.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. This error occurs when an attempt is made to mutate or mutably reference data that a closure has captured immutably. diff --git a/compiler/rustc_error_codes/src/error_codes/E0388.md b/compiler/rustc_error_codes/src/error_codes/E0388.md index 512fb42e6ecb5..13ef94a48553b 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0388.md +++ b/compiler/rustc_error_codes/src/error_codes/E0388.md @@ -1 +1 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. diff --git a/compiler/rustc_error_codes/src/error_codes/E0389.md b/compiler/rustc_error_codes/src/error_codes/E0389.md index 9f064e44c8209..19bb6ec408131 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0389.md +++ b/compiler/rustc_error_codes/src/error_codes/E0389.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. An attempt was made to mutate data using a non-mutable reference. This commonly occurs when attempting to assign to a non-mutable reference of a diff --git a/compiler/rustc_error_codes/src/error_codes/E0398.md b/compiler/rustc_error_codes/src/error_codes/E0398.md index 75d86979e3c87..12e0eb1a5d5dd 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0398.md +++ b/compiler/rustc_error_codes/src/error_codes/E0398.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. In Rust 1.3, the default object lifetime bounds are expected to change, as described in [RFC 1156]. You are getting a warning because the compiler diff --git a/compiler/rustc_error_codes/src/error_codes/E0399.md b/compiler/rustc_error_codes/src/error_codes/E0399.md index 6ea6054b41779..c3e9616c60698 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0399.md +++ b/compiler/rustc_error_codes/src/error_codes/E0399.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler +### Note: this error code is no longer emitted by the compiler You implemented a trait, overriding one or more of its associated types but did not reimplement its default methods. diff --git a/compiler/rustc_error_codes/src/error_codes/E0439.md b/compiler/rustc_error_codes/src/error_codes/E0439.md index 24268aef2222a..85e965c4eee62 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0439.md +++ b/compiler/rustc_error_codes/src/error_codes/E0439.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. The length of the platform-intrinsic function `simd_shuffle` wasn't specified. diff --git a/compiler/rustc_error_codes/src/error_codes/E0447.md b/compiler/rustc_error_codes/src/error_codes/E0447.md index af8cd8d6d5202..e880ff4637da7 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0447.md +++ b/compiler/rustc_error_codes/src/error_codes/E0447.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. The `pub` keyword was used inside a function. diff --git a/compiler/rustc_error_codes/src/error_codes/E0448.md b/compiler/rustc_error_codes/src/error_codes/E0448.md index ba096f9e984ae..f4bd184188824 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0448.md +++ b/compiler/rustc_error_codes/src/error_codes/E0448.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. The `pub` keyword was used inside a public enum. diff --git a/compiler/rustc_error_codes/src/error_codes/E0497.md b/compiler/rustc_error_codes/src/error_codes/E0497.md index ef2882415d24a..12004996384a2 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0497.md +++ b/compiler/rustc_error_codes/src/error_codes/E0497.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. A stability attribute was used outside of the standard library. diff --git a/compiler/rustc_error_codes/src/error_codes/E0504.md b/compiler/rustc_error_codes/src/error_codes/E0504.md index bcbd00a8690a4..640cfad656f71 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0504.md +++ b/compiler/rustc_error_codes/src/error_codes/E0504.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. This error occurs when an attempt is made to move a borrowed variable into a closure. diff --git a/compiler/rustc_error_codes/src/error_codes/E0595.md b/compiler/rustc_error_codes/src/error_codes/E0595.md index e6729013243f6..96fbb5e410ae7 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0595.md +++ b/compiler/rustc_error_codes/src/error_codes/E0595.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. Closures cannot mutate immutable captured variables. diff --git a/compiler/rustc_error_codes/src/error_codes/E0619.md b/compiler/rustc_error_codes/src/error_codes/E0619.md index f516de43095bd..d33154058dd37 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0619.md +++ b/compiler/rustc_error_codes/src/error_codes/E0619.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. The type-checker needed to know the type of an expression, but that type had not yet been inferred. diff --git a/compiler/rustc_error_codes/src/error_codes/E0633.md b/compiler/rustc_error_codes/src/error_codes/E0633.md index 5b6c15c82eb63..f6e8a4042ed35 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0633.md +++ b/compiler/rustc_error_codes/src/error_codes/E0633.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. The `unwind` attribute was malformed. diff --git a/compiler/rustc_error_codes/src/error_codes/E0665.md b/compiler/rustc_error_codes/src/error_codes/E0665.md index ae54d6d15798d..db5e088cc501e 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0665.md +++ b/compiler/rustc_error_codes/src/error_codes/E0665.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. The `Default` trait was derived on an enum. diff --git a/compiler/rustc_error_codes/src/error_codes/E0671.md b/compiler/rustc_error_codes/src/error_codes/E0671.md index d4dbfb7a5d8e6..a68273f752e73 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0671.md +++ b/compiler/rustc_error_codes/src/error_codes/E0671.md @@ -1,4 +1,4 @@ -#### Note: this error code is no longer emitted by the compiler. +### Note: this error code is no longer emitted by the compiler. Const parameters cannot depend on type parameters. The following is therefore invalid: diff --git a/src/librustdoc/externalfiles.rs b/src/librustdoc/externalfiles.rs index 56d2ca57218c5..1fd5e2d5ef67e 100644 --- a/src/librustdoc/externalfiles.rs +++ b/src/librustdoc/externalfiles.rs @@ -39,14 +39,14 @@ impl ExternalHtml { let bc = format!( "{}{}", bc, - Markdown(&m_bc, &[], id_map, codes, edition, playground).into_string() + Markdown(&m_bc, &[], id_map, codes, edition, playground, 0).into_string() ); let ac = load_external_files(after_content, diag)?; let m_ac = load_external_files(md_after_content, diag)?; let ac = format!( "{}{}", ac, - Markdown(&m_ac, &[], id_map, codes, edition, playground).into_string() + Markdown(&m_ac, &[], id_map, codes, edition, playground, 0).into_string() ); Some(ExternalHtml { in_header: ih, before_content: bc, after_content: ac }) } diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index fda2512a05036..56b580a05188c 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -12,7 +12,7 @@ //! //! let s = "My *markdown* _text_"; //! let mut id_map = IdMap::new(); -//! let md = Markdown(s, &[], &mut id_map, ErrorCodes::Yes, Edition::Edition2015, &None); +//! let md = Markdown(s, &[], &mut id_map, ErrorCodes::Yes, Edition::Edition2015, &None, 0); //! let html = md.into_string(); //! // ... something using html //! ``` @@ -47,6 +47,8 @@ use pulldown_cmark::{ #[cfg(test)] mod tests; +const MAX_HEADER_LEVEL: u32 = 6; + /// Options for rendering Markdown in the main body of documentation. pub(crate) fn main_body_opts() -> Options { Options::ENABLE_TABLES @@ -78,6 +80,7 @@ pub struct Markdown<'a>( /// Default edition to use when parsing doctests (to add a `fn main`). pub Edition, pub &'a Option, + pub u32, ); /// A tuple struct like `Markdown` that renders the markdown with a table of contents. crate struct MarkdownWithToc<'a>( @@ -489,11 +492,12 @@ struct HeadingLinks<'a, 'b, 'ids, I> { toc: Option<&'b mut TocBuilder>, buf: VecDeque>, id_map: &'ids mut IdMap, + level: u32, } impl<'a, 'b, 'ids, I> HeadingLinks<'a, 'b, 'ids, I> { - fn new(iter: I, toc: Option<&'b mut TocBuilder>, ids: &'ids mut IdMap) -> Self { - HeadingLinks { inner: iter, toc, buf: VecDeque::new(), id_map: ids } + fn new(iter: I, toc: Option<&'b mut TocBuilder>, ids: &'ids mut IdMap, level: u32) -> Self { + HeadingLinks { inner: iter, toc, buf: VecDeque::new(), id_map: ids, level } } } @@ -530,6 +534,7 @@ impl<'a, 'b, 'ids, I: Iterator>> Iterator self.buf.push_front((Event::Html(format!("{} ", sec).into()), 0..0)); } + let level = std::cmp::min(level + self.level + 1, MAX_HEADER_LEVEL); self.buf.push_back((Event::Html(format!("", level).into()), 0..0)); let start_tags = format!( @@ -1005,7 +1010,7 @@ impl LangString { impl Markdown<'_> { pub fn into_string(self) -> String { - let Markdown(md, links, mut ids, codes, edition, playground) = self; + let Markdown(md, links, mut ids, codes, edition, playground, level) = self; // This is actually common enough to special-case if md.is_empty() { @@ -1026,7 +1031,7 @@ impl Markdown<'_> { let mut s = String::with_capacity(md.len() * 3 / 2); - let p = HeadingLinks::new(p, None, &mut ids); + let p = HeadingLinks::new(p, None, &mut ids, level); let p = Footnotes::new(p); let p = LinkReplacer::new(p.map(|(ev, _)| ev), links); let p = TableWrapper::new(p); @@ -1048,7 +1053,7 @@ impl MarkdownWithToc<'_> { let mut toc = TocBuilder::new(); { - let p = HeadingLinks::new(p, Some(&mut toc), &mut ids); + let p = HeadingLinks::new(p, Some(&mut toc), &mut ids, 0); let p = Footnotes::new(p); let p = TableWrapper::new(p.map(|(ev, _)| ev)); let p = CodeBlocks::new(p, codes, edition, playground); @@ -1077,7 +1082,7 @@ impl MarkdownHtml<'_> { let mut s = String::with_capacity(md.len() * 3 / 2); - let p = HeadingLinks::new(p, None, &mut ids); + let p = HeadingLinks::new(p, None, &mut ids, 0); let p = Footnotes::new(p); let p = TableWrapper::new(p.map(|(ev, _)| ev)); let p = CodeBlocks::new(p, codes, edition, playground); @@ -1295,7 +1300,7 @@ crate fn markdown_links(md: &str) -> Vec { // There's no need to thread an IdMap through to here because // the IDs generated aren't going to be emitted anywhere. let mut ids = IdMap::new(); - let iter = Footnotes::new(HeadingLinks::new(p, None, &mut ids)); + let iter = Footnotes::new(HeadingLinks::new(p, None, &mut ids, 0)); for ev in iter { if let Event::Start(Tag::Link(kind, dest, _)) = ev.0 { diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs index 1e4cf3381f6a3..c6af7e5847c52 100644 --- a/src/librustdoc/html/markdown/tests.rs +++ b/src/librustdoc/html/markdown/tests.rs @@ -147,33 +147,33 @@ fn test_lang_string_tokenizer() { fn test_header() { fn t(input: &str, expect: &str) { let mut map = IdMap::new(); - let output = - Markdown(input, &[], &mut map, ErrorCodes::Yes, DEFAULT_EDITION, &None).into_string(); + let output = Markdown(input, &[], &mut map, ErrorCodes::Yes, DEFAULT_EDITION, &None, 0) + .into_string(); assert_eq!(output, expect, "original: {}", input); } t( "# Foo bar", - "

Foo bar

", + "

Foo bar

", ); t( "## Foo-bar_baz qux", - "

\ - Foo-bar_baz qux

", + "

\ + Foo-bar_baz qux

", ); t( "### **Foo** *bar* baz!?!& -_qux_-%", - "

\ + "

\ Foo \ bar baz!?!& -qux-%\ -

", +

", ); t( "#### **Foo?** & \\*bar?!* _`baz`_ ❤ #qux", - "

\ + "

\ Foo? & *bar?!* \ baz ❤ #qux\ -
", + ", ); } @@ -182,39 +182,39 @@ fn test_header_ids_multiple_blocks() { let mut map = IdMap::new(); fn t(map: &mut IdMap, input: &str, expect: &str) { let output = - Markdown(input, &[], map, ErrorCodes::Yes, DEFAULT_EDITION, &None).into_string(); + Markdown(input, &[], map, ErrorCodes::Yes, DEFAULT_EDITION, &None, 0).into_string(); assert_eq!(output, expect, "original: {}", input); } t( &mut map, "# Example", - "

Example

", + "

Example

", ); t( &mut map, "# Panics", - "

Panics

", + "

Panics

", ); t( &mut map, "# Example", - "

Example

", + "

Example

", ); t( &mut map, "# Main", - "

Main

", + "

Main

", ); t( &mut map, "# Example", - "

Example

", + "

Example

", ); t( &mut map, "# Panics", - "

Panics

", + "

Panics

", ); } diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 5045a99800ab1..69f39bb58a853 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -471,19 +471,35 @@ fn settings(root_path: &str, suffix: &str, themes: &[StylePath]) -> Result, item: &clean::Item, parent: Option<&clean::Item>) { + document_at_level(w, cx, item, parent, 0) +} + +fn document_at_level( + w: &mut Buffer, + cx: &Context<'_>, + item: &clean::Item, + parent: Option<&clean::Item>, + level: u32, +) { if let Some(ref name) = item.name { info!("Documenting {}", name); } document_item_info(w, cx, item, parent); if parent.is_none() { - document_full_collapsible(w, item, cx); + document_full_collapsible(w, item, cx, level); } else { - document_full(w, item, cx); + document_full(w, item, cx, level); } } /// Render md_text as markdown. -fn render_markdown(w: &mut Buffer, cx: &Context<'_>, md_text: &str, links: Vec) { +fn render_markdown( + w: &mut Buffer, + cx: &Context<'_>, + md_text: &str, + links: Vec, + level: u32, +) { let mut ids = cx.id_map.borrow_mut(); write!( w, @@ -494,7 +510,8 @@ fn render_markdown(w: &mut Buffer, cx: &Context<'_>, md_text: &str, links: Vec) { - document_full_inner(w, item, cx, true); +fn document_full_collapsible(w: &mut Buffer, item: &clean::Item, cx: &Context<'_>, level: u32) { + document_full_inner(w, item, cx, true, level); } -fn document_full(w: &mut Buffer, item: &clean::Item, cx: &Context<'_>) { - document_full_inner(w, item, cx, false); +fn document_full(w: &mut Buffer, item: &clean::Item, cx: &Context<'_>, level: u32) { + document_full_inner(w, item, cx, false, level); } -fn document_full_inner(w: &mut Buffer, item: &clean::Item, cx: &Context<'_>, is_collapsible: bool) { +fn document_full_inner( + w: &mut Buffer, + item: &clean::Item, + cx: &Context<'_>, + is_collapsible: bool, + level: u32, +) { if let Some(s) = cx.shared.maybe_collapsed_doc_value(item) { debug!("Doc block: =====\n{}\n=====", s); if is_collapsible { @@ -549,10 +572,10 @@ fn document_full_inner(w: &mut Buffer, item: &clean::Item, cx: &Context<'_>, is_ Expand description\ ", ); - render_markdown(w, cx, &s, item.links(cx)); + render_markdown(w, cx, &s, item.links(cx), level); w.write_str(""); } else { - render_markdown(w, cx, &s, item.links(cx)); + render_markdown(w, cx, &s, item.links(cx), level); } } } @@ -1321,7 +1344,7 @@ fn render_impl( // because impls can't have a stability. if item.doc_value().is_some() { document_item_info(&mut info_buffer, cx, it, Some(parent)); - document_full(&mut doc_buffer, item, cx); + document_full(&mut doc_buffer, item, cx, 0); short_documented = false; } else { // In case the item isn't documented, @@ -1339,7 +1362,7 @@ fn render_impl( } else { document_item_info(&mut info_buffer, cx, item, Some(parent)); if rendering_params.show_def_docs { - document_full(&mut doc_buffer, item, cx); + document_full(&mut doc_buffer, item, cx, 3); short_documented = false; } } @@ -1579,7 +1602,8 @@ fn render_impl( &mut ids, cx.shared.codes, cx.shared.edition(), - &cx.shared.playground + &cx.shared.playground, + 0 ) .into_string() ); diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index fa0d211efe630..59a6925d8b459 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -16,10 +16,10 @@ use rustc_span::symbol::{kw, sym, Symbol}; use rustc_target::abi::{Layout, Primitive, TagEncoding, Variants}; use super::{ - collect_paths_for_type, document, ensure_trailing_slash, item_ty_to_strs, notable_traits_decl, - render_assoc_item, render_assoc_items, render_attributes_in_code, render_attributes_in_pre, - render_impl, render_stability_since_raw, write_srclink, AssocItemLink, Context, - ImplRenderingParameters, + collect_paths_for_type, document, document_at_level, ensure_trailing_slash, item_ty_to_strs, + notable_traits_decl, render_assoc_item, render_assoc_items, render_attributes_in_code, + render_attributes_in_pre, render_impl, render_stability_since_raw, write_srclink, + AssocItemLink, Context, ImplRenderingParameters, }; use crate::clean::{self, GetDefId}; use crate::formats::item_type::ItemType; @@ -626,7 +626,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra let item_type = m.type_(); let id = cx.derive_id(format!("{}.{}", item_type, name)); let mut content = Buffer::empty_from(w); - document(&mut content, cx, m, Some(t)); + document_at_level(&mut content, cx, m, Some(t), 3); let toggled = !content.is_empty(); if toggled { write!(w, "
"); diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index eb7cc9309f416..925d76956ab77 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -126,7 +126,7 @@ h2 { h3 { font-size: 1.3em; } -h1, h2, h3, h4 { +h1, h2, h3, h4, h5, h6 { font-weight: 500; margin: 20px 0 15px 0; padding-bottom: 6px; @@ -179,7 +179,7 @@ div.impl-items > div { padding-left: 0; } -h1, h2, h3, h4, +h1, h2, h3, h4, h5, h6, .sidebar, a.source, .search-input, .search-results .result-name, .content table td:first-child > a, .item-left > a, @@ -501,21 +501,20 @@ nav.sub { white-space: pre-wrap; } -.docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5 { +.docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5, .docblock h6 { border-bottom: 1px solid; } -.top-doc .docblock h1 { font-size: 1.3em; } -.top-doc .docblock h2 { font-size: 1.15em; } -.top-doc .docblock h3, +.top-doc .docblock h2 { font-size: 1.3em; } +.top-doc .docblock h3 { font-size: 1.15em; } .top-doc .docblock h4, -.top-doc .docblock h5 { +.top-doc .docblock h5, +.top-doc .docblock h6 { font-size: 1em; } -.docblock h1 { font-size: 1em; } -.docblock h2 { font-size: 0.95em; } -.docblock h3, .docblock h4, .docblock h5 { font-size: 0.9em; } +.docblock h5 { font-size: 1em; } +.docblock h6 { font-size: 0.95em; } .docblock { margin-left: 24px; diff --git a/src/librustdoc/html/static/css/themes/ayu.css b/src/librustdoc/html/static/css/themes/ayu.css index c79801e830876..0fb4f95acdf34 100644 --- a/src/librustdoc/html/static/css/themes/ayu.css +++ b/src/librustdoc/html/static/css/themes/ayu.css @@ -136,7 +136,7 @@ pre, .rustdoc.source .example-wrap { border-right: 1px solid #ffb44c; } -.docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5 { +.docblock h2, .docblock h3, .docblock h4, .docblock h5, .docblock h6 { border-bottom-color: #5c6773; } diff --git a/src/librustdoc/html/static/css/themes/dark.css b/src/librustdoc/html/static/css/themes/dark.css index d2e54070acd68..4fb6f7b38bbf2 100644 --- a/src/librustdoc/html/static/css/themes/dark.css +++ b/src/librustdoc/html/static/css/themes/dark.css @@ -93,7 +93,7 @@ pre, .rustdoc.source .example-wrap { background-color: #0a042f !important; } -.docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5 { +.docblock h2, .docblock h3, .docblock h4, .docblock h5, .docblock h6 { border-bottom-color: #DDD; } diff --git a/src/librustdoc/html/static/css/themes/light.css b/src/librustdoc/html/static/css/themes/light.css index 25d810560c146..62134f025c82a 100644 --- a/src/librustdoc/html/static/css/themes/light.css +++ b/src/librustdoc/html/static/css/themes/light.css @@ -93,7 +93,7 @@ pre, .rustdoc.source .example-wrap { background-color: #f6fdb0 !important; } -.docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5 { +.docblock h2, .docblock h3, .docblock h4, .docblock h5, .docblock h6 { border-bottom-color: #ddd; } diff --git a/src/librustdoc/markdown.rs b/src/librustdoc/markdown.rs index 2ae4897dc3496..82e6231782c1e 100644 --- a/src/librustdoc/markdown.rs +++ b/src/librustdoc/markdown.rs @@ -70,7 +70,7 @@ crate fn render>( let text = if !options.markdown_no_toc { MarkdownWithToc(text, &mut ids, error_codes, edition, &playground).into_string() } else { - Markdown(text, &[], &mut ids, error_codes, edition, &playground).into_string() + Markdown(text, &[], &mut ids, error_codes, edition, &playground, 0).into_string() }; let err = write!( diff --git a/src/test/rustdoc/external-cross.rs b/src/test/rustdoc/external-cross.rs index 056ed3534624b..3f8e16882911a 100644 --- a/src/test/rustdoc/external-cross.rs +++ b/src/test/rustdoc/external-cross.rs @@ -6,5 +6,5 @@ extern crate external_cross; // @has host/struct.NeedMoreDocs.html -// @has - '//h1' 'Cross-crate imported docs' +// @has - '//h2' 'Cross-crate imported docs' pub use external_cross::NeedMoreDocs; diff --git a/src/test/rustdoc/external-doc.rs b/src/test/rustdoc/external-doc.rs index fc29cb252e26c..bd322d67a370d 100644 --- a/src/test/rustdoc/external-doc.rs +++ b/src/test/rustdoc/external-doc.rs @@ -1,6 +1,6 @@ // @has external_doc/struct.IncludeStrDocs.html -// @has - '//h1' 'External Docs' -// @has - '//h2' 'Inline Docs' +// @has - '//h2' 'External Docs' +// @has - '//h3' 'Inline Docs' #[doc = include_str!("auxiliary/external-doc.md")] /// ## Inline Docs pub struct IncludeStrDocs; @@ -8,7 +8,7 @@ pub struct IncludeStrDocs; macro_rules! dir { () => { "auxiliary" } } // @has external_doc/struct.EagerExpansion.html -// @has - '//h1' 'External Docs' +// @has - '//h2' 'External Docs' #[doc = include_str!(concat!(dir!(), "/external-doc.md"))] /// ## Inline Docs pub struct EagerExpansion; diff --git a/src/test/rustdoc/issue-42760.rs b/src/test/rustdoc/issue-42760.rs index b07dc3f6e967b..4944f8157014e 100644 --- a/src/test/rustdoc/issue-42760.rs +++ b/src/test/rustdoc/issue-42760.rs @@ -1,5 +1,5 @@ // @has issue_42760/struct.NonGen.html -// @has - '//h1' 'Example' +// @has - '//h2' 'Example' /// Item docs. /// diff --git a/src/test/rustdoc/short-docblock.rs b/src/test/rustdoc/short-docblock.rs index 74fa783174da8..17c44eab091a6 100644 --- a/src/test/rustdoc/short-docblock.rs +++ b/src/test/rustdoc/short-docblock.rs @@ -2,7 +2,7 @@ // @has foo/index.html '//*[@class="item-right docblock-short"]/p' 'fooo' // @!has foo/index.html '//*[@class="item-right docblock-short"]/p/h1' 'fooo' -// @has foo/fn.foo.html '//h1[@id="fooo"]/a[@href="#fooo"]' 'fooo' +// @has foo/fn.foo.html '//h2[@id="fooo"]/a[@href="#fooo"]' 'fooo' /// # fooo /// @@ -11,7 +11,7 @@ pub fn foo() {} // @has foo/index.html '//*[@class="item-right docblock-short"]/p' 'mooood' // @!has foo/index.html '//*[@class="item-right docblock-short"]/p/h2' 'mooood' -// @has foo/foo/index.html '//h2[@id="mooood"]/a[@href="#mooood"]' 'mooood' +// @has foo/foo/index.html '//h3[@id="mooood"]/a[@href="#mooood"]' 'mooood' /// ## mooood /// diff --git a/src/test/rustdoc/smart-punct.rs b/src/test/rustdoc/smart-punct.rs index 5319892c99c23..7ae5bd6994579 100644 --- a/src/test/rustdoc/smart-punct.rs +++ b/src/test/rustdoc/smart-punct.rs @@ -21,7 +21,7 @@ //! ``` // @has "foo/index.html" "//p" "This is the “start” of the ‘document’! How’d you know that “it’s” the start?" -// @has "foo/index.html" "//h1" "Header with “smart punct’”" +// @has "foo/index.html" "//h2" "Header with “smart punct’”" // @has "foo/index.html" '//a[@href="https://www.rust-lang.org"]' "link with “smart punct’” – yessiree!" // @has "foo/index.html" '//code' "this inline code -- it shouldn't have \"smart punct\"" // @has "foo/index.html" '//pre' "let x = \"don't smart-punct me -- please!\";" diff --git a/src/tools/error_index_generator/main.rs b/src/tools/error_index_generator/main.rs index 01a3fc812b208..1ba283b178120 100644 --- a/src/tools/error_index_generator/main.rs +++ b/src/tools/error_index_generator/main.rs @@ -125,7 +125,8 @@ impl Formatter for HTMLFormatter { &mut id_map, ErrorCodes::Yes, DEFAULT_EDITION, - &Some(playground) + &Some(playground), + 0 ) .into_string() )? diff --git a/src/tools/tidy/src/error_codes_check.rs b/src/tools/tidy/src/error_codes_check.rs index 53c75a463390d..ae169d383b273 100644 --- a/src/tools/tidy/src/error_codes_check.rs +++ b/src/tools/tidy/src/error_codes_check.rs @@ -49,7 +49,7 @@ fn check_error_code_explanation( } else if s.contains("compile-fail") { invalid_compile_fail_format = true; } - } else if s.starts_with("#### Note: this error code is no longer emitted by the compiler") { + } else if s.starts_with("### Note: this error code is no longer emitted by the compiler") { if !found_error_code { error_codes.get_mut(&err_code).map(|x| x.has_test = true); found_error_code = true; @@ -64,7 +64,7 @@ fn check_if_error_code_is_test_in_explanation(f: &str, err_code: &str) -> bool { for line in f.lines() { let s = line.trim(); - if s.starts_with("#### Note: this error code is no longer emitted by the compiler") { + if s.starts_with("### Note: this error code is no longer emitted by the compiler") { return true; } if s.starts_with("```") { From 4a6aa6e4063a8ecd9810c04a5dae9e8ff2f664d6 Mon Sep 17 00:00:00 2001 From: Mukund Lakshman Date: Mon, 4 Oct 2021 20:49:07 -0400 Subject: [PATCH 2/8] Fix heading for methods on trait impls. --- src/librustdoc/html/render/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 69f39bb58a853..532dce99c0dc2 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1344,7 +1344,7 @@ fn render_impl( // because impls can't have a stability. if item.doc_value().is_some() { document_item_info(&mut info_buffer, cx, it, Some(parent)); - document_full(&mut doc_buffer, item, cx, 0); + document_full(&mut doc_buffer, item, cx, 3); short_documented = false; } else { // In case the item isn't documented, From 6518a0a8b9570b6d347a3c7b2c9b95e66cbbd013 Mon Sep 17 00:00:00 2001 From: Mukund Lakshman Date: Mon, 4 Oct 2021 21:08:58 -0400 Subject: [PATCH 3/8] Change `Markdown(...)` to `Markdown { ... }` --- src/librustdoc/externalfiles.rs | 22 +++++++++++-- src/librustdoc/html/markdown.rs | 42 ++++++++++++++++++------- src/librustdoc/html/markdown/tests.rs | 24 +++++++++++--- src/librustdoc/html/render/mod.rs | 38 +++++++++++----------- src/librustdoc/markdown.rs | 11 ++++++- src/tools/error_index_generator/main.rs | 18 +++++------ 6 files changed, 108 insertions(+), 47 deletions(-) diff --git a/src/librustdoc/externalfiles.rs b/src/librustdoc/externalfiles.rs index 1fd5e2d5ef67e..5cb654a606f34 100644 --- a/src/librustdoc/externalfiles.rs +++ b/src/librustdoc/externalfiles.rs @@ -39,14 +39,32 @@ impl ExternalHtml { let bc = format!( "{}{}", bc, - Markdown(&m_bc, &[], id_map, codes, edition, playground, 0).into_string() + Markdown { + content: &m_bc, + links: &[], + ids: id_map, + error_codes: codes, + edition, + playground, + heading_level: 0 + } + .into_string() ); let ac = load_external_files(after_content, diag)?; let m_ac = load_external_files(md_after_content, diag)?; let ac = format!( "{}{}", ac, - Markdown(&m_ac, &[], id_map, codes, edition, playground, 0).into_string() + Markdown { + content: &m_ac, + links: &[], + ids: id_map, + error_codes: codes, + edition, + playground, + heading_level: 0 + } + .into_string() ); Some(ExternalHtml { in_header: ih, before_content: bc, after_content: ac }) } diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 56b580a05188c..da1482f4e6969 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -12,7 +12,15 @@ //! //! let s = "My *markdown* _text_"; //! let mut id_map = IdMap::new(); -//! let md = Markdown(s, &[], &mut id_map, ErrorCodes::Yes, Edition::Edition2015, &None, 0); +//! let md = Markdown { +//! content: s, +//! links: &[], +//! ids: &mut id_map, +//! error_codes: ErrorCodes::Yes, +//! edition: Edition::Edition2015, +//! playground: &None, +//! heading_level: 0 +//! }; //! let html = md.into_string(); //! // ... something using html //! ``` @@ -69,19 +77,21 @@ pub(crate) fn summary_opts() -> Options { /// When `to_string` is called, this struct will emit the HTML corresponding to /// the rendered version of the contained markdown string. -pub struct Markdown<'a>( - pub &'a str, +pub struct Markdown<'a> { + pub content: &'a str, /// A list of link replacements. - pub &'a [RenderedLink], + pub links: &'a [RenderedLink], /// The current list of used header IDs. - pub &'a mut IdMap, + pub ids: &'a mut IdMap, /// Whether to allow the use of explicit error codes in doctest lang strings. - pub ErrorCodes, + pub error_codes: ErrorCodes, /// Default edition to use when parsing doctests (to add a `fn main`). - pub Edition, - pub &'a Option, - pub u32, -); + pub edition: Edition, + pub playground: &'a Option, + /// Offset at which we render headings. + /// E.g. if `heading_level: 1`, then `# something` renders an `

` instead of `

` + pub heading_level: u32, +} /// A tuple struct like `Markdown` that renders the markdown with a table of contents. crate struct MarkdownWithToc<'a>( crate &'a str, @@ -1010,7 +1020,15 @@ impl LangString { impl Markdown<'_> { pub fn into_string(self) -> String { - let Markdown(md, links, mut ids, codes, edition, playground, level) = self; + let Markdown { + content: md, + links, + mut ids, + error_codes: codes, + edition, + playground, + heading_level, + } = self; // This is actually common enough to special-case if md.is_empty() { @@ -1031,7 +1049,7 @@ impl Markdown<'_> { let mut s = String::with_capacity(md.len() * 3 / 2); - let p = HeadingLinks::new(p, None, &mut ids, level); + let p = HeadingLinks::new(p, None, &mut ids, heading_level); let p = Footnotes::new(p); let p = LinkReplacer::new(p.map(|(ev, _)| ev), links); let p = TableWrapper::new(p); diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs index c6af7e5847c52..b2c18c24011d6 100644 --- a/src/librustdoc/html/markdown/tests.rs +++ b/src/librustdoc/html/markdown/tests.rs @@ -147,8 +147,16 @@ fn test_lang_string_tokenizer() { fn test_header() { fn t(input: &str, expect: &str) { let mut map = IdMap::new(); - let output = Markdown(input, &[], &mut map, ErrorCodes::Yes, DEFAULT_EDITION, &None, 0) - .into_string(); + let output = Markdown { + content: input, + links: &[], + ids: &mut map, + error_codes: ErrorCodes::Yes, + edition: DEFAULT_EDITION, + playground: &None, + heading_level: 0, + } + .into_string(); assert_eq!(output, expect, "original: {}", input); } @@ -181,8 +189,16 @@ fn test_header() { fn test_header_ids_multiple_blocks() { let mut map = IdMap::new(); fn t(map: &mut IdMap, input: &str, expect: &str) { - let output = - Markdown(input, &[], map, ErrorCodes::Yes, DEFAULT_EDITION, &None, 0).into_string(); + let output = Markdown { + content: input, + links: &[], + ids: map, + error_codes: ErrorCodes::Yes, + edition: DEFAULT_EDITION, + playground: &None, + heading_level: 0, + } + .into_string(); assert_eq!(output, expect, "original: {}", input); } diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 532dce99c0dc2..164d745336823 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -498,21 +498,21 @@ fn render_markdown( cx: &Context<'_>, md_text: &str, links: Vec, - level: u32, + heading_level: u32, ) { let mut ids = cx.id_map.borrow_mut(); write!( w, "
{}
", - Markdown( - md_text, - &links, - &mut ids, - cx.shared.codes, - cx.shared.edition(), - &cx.shared.playground, - level - ) + Markdown { + content: md_text, + links: &links, + ids: &mut ids, + error_codes: cx.shared.codes, + edition: cx.shared.edition(), + playground: &cx.shared.playground, + heading_level, + } .into_string() ) } @@ -1596,15 +1596,15 @@ fn render_impl( write!( w, "
{}
", - Markdown( - &*dox, - &i.impl_item.links(cx), - &mut ids, - cx.shared.codes, - cx.shared.edition(), - &cx.shared.playground, - 0 - ) + Markdown { + content: &*dox, + links: &i.impl_item.links(cx), + ids: &mut ids, + error_codes: cx.shared.codes, + edition: cx.shared.edition(), + playground: &cx.shared.playground, + heading_level: 0 + } .into_string() ); } diff --git a/src/librustdoc/markdown.rs b/src/librustdoc/markdown.rs index 82e6231782c1e..962712f5b9175 100644 --- a/src/librustdoc/markdown.rs +++ b/src/librustdoc/markdown.rs @@ -70,7 +70,16 @@ crate fn render>( let text = if !options.markdown_no_toc { MarkdownWithToc(text, &mut ids, error_codes, edition, &playground).into_string() } else { - Markdown(text, &[], &mut ids, error_codes, edition, &playground, 0).into_string() + Markdown { + content: text, + links: &[], + ids: &mut ids, + error_codes, + edition, + playground: &playground, + heading_level: 0, + } + .into_string() }; let err = write!( diff --git a/src/tools/error_index_generator/main.rs b/src/tools/error_index_generator/main.rs index 1ba283b178120..f3c5d65935f66 100644 --- a/src/tools/error_index_generator/main.rs +++ b/src/tools/error_index_generator/main.rs @@ -119,15 +119,15 @@ impl Formatter for HTMLFormatter { write!( output, "{}", - Markdown( - desc, - &[], - &mut id_map, - ErrorCodes::Yes, - DEFAULT_EDITION, - &Some(playground), - 0 - ) + Markdown { + content: desc, + links: &[], + ids: &mut id_map, + error_codes: ErrorCodes::Yes, + edition: DEFAULT_EDITION, + playground: &Some(playground), + heading_level: 0 + } .into_string() )? } From 13558ee0a06c544e68978766d0508b62ef3e22f7 Mon Sep 17 00:00:00 2001 From: Mukund Lakshman Date: Mon, 4 Oct 2021 21:28:26 -0400 Subject: [PATCH 4/8] No need to default offset since we always override it. --- src/librustdoc/externalfiles.rs | 4 +- src/librustdoc/html/markdown.rs | 4 +- src/librustdoc/html/markdown/tests.rs | 4 +- src/librustdoc/html/render/mod.rs | 12 ++---- src/librustdoc/html/render/print_item.rs | 50 ++++++++++++------------ src/tools/error_index_generator/main.rs | 2 +- 6 files changed, 36 insertions(+), 40 deletions(-) diff --git a/src/librustdoc/externalfiles.rs b/src/librustdoc/externalfiles.rs index 5cb654a606f34..cb5c9edcde570 100644 --- a/src/librustdoc/externalfiles.rs +++ b/src/librustdoc/externalfiles.rs @@ -46,7 +46,7 @@ impl ExternalHtml { error_codes: codes, edition, playground, - heading_level: 0 + heading_level: 1 } .into_string() ); @@ -62,7 +62,7 @@ impl ExternalHtml { error_codes: codes, edition, playground, - heading_level: 0 + heading_level: 1 } .into_string() ); diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index da1482f4e6969..ef2f2f90301fb 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -19,7 +19,7 @@ //! error_codes: ErrorCodes::Yes, //! edition: Edition::Edition2015, //! playground: &None, -//! heading_level: 0 +//! heading_level: 1 //! }; //! let html = md.into_string(); //! // ... something using html @@ -544,7 +544,7 @@ impl<'a, 'b, 'ids, I: Iterator>> Iterator self.buf.push_front((Event::Html(format!("{} ", sec).into()), 0..0)); } - let level = std::cmp::min(level + self.level + 1, MAX_HEADER_LEVEL); + let level = std::cmp::min(level + self.level, MAX_HEADER_LEVEL); self.buf.push_back((Event::Html(format!("", level).into()), 0..0)); let start_tags = format!( diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs index b2c18c24011d6..ee6a19978969e 100644 --- a/src/librustdoc/html/markdown/tests.rs +++ b/src/librustdoc/html/markdown/tests.rs @@ -154,7 +154,7 @@ fn test_header() { error_codes: ErrorCodes::Yes, edition: DEFAULT_EDITION, playground: &None, - heading_level: 0, + heading_level: 1, } .into_string(); assert_eq!(output, expect, "original: {}", input); @@ -196,7 +196,7 @@ fn test_header_ids_multiple_blocks() { error_codes: ErrorCodes::Yes, edition: DEFAULT_EDITION, playground: &None, - heading_level: 0, + heading_level: 1, } .into_string(); assert_eq!(output, expect, "original: {}", input); diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 164d745336823..8cf11e526fe38 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -470,11 +470,7 @@ fn settings(root_path: &str, suffix: &str, themes: &[StylePath]) -> Result, item: &clean::Item, parent: Option<&clean::Item>) { - document_at_level(w, cx, item, parent, 0) -} - -fn document_at_level( +fn document( w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, @@ -1344,7 +1340,7 @@ fn render_impl( // because impls can't have a stability. if item.doc_value().is_some() { document_item_info(&mut info_buffer, cx, it, Some(parent)); - document_full(&mut doc_buffer, item, cx, 3); + document_full(&mut doc_buffer, item, cx, 4); short_documented = false; } else { // In case the item isn't documented, @@ -1362,7 +1358,7 @@ fn render_impl( } else { document_item_info(&mut info_buffer, cx, item, Some(parent)); if rendering_params.show_def_docs { - document_full(&mut doc_buffer, item, cx, 3); + document_full(&mut doc_buffer, item, cx, 4); short_documented = false; } } @@ -1603,7 +1599,7 @@ fn render_impl( error_codes: cx.shared.codes, edition: cx.shared.edition(), playground: &cx.shared.playground, - heading_level: 0 + heading_level: 1 } .into_string() ); diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 59a6925d8b459..f26ee84569b49 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -16,10 +16,10 @@ use rustc_span::symbol::{kw, sym, Symbol}; use rustc_target::abi::{Layout, Primitive, TagEncoding, Variants}; use super::{ - collect_paths_for_type, document, document_at_level, ensure_trailing_slash, item_ty_to_strs, - notable_traits_decl, render_assoc_item, render_assoc_items, render_attributes_in_code, - render_attributes_in_pre, render_impl, render_stability_since_raw, write_srclink, - AssocItemLink, Context, ImplRenderingParameters, + collect_paths_for_type, document, ensure_trailing_slash, item_ty_to_strs, notable_traits_decl, + render_assoc_item, render_assoc_items, render_attributes_in_code, render_attributes_in_pre, + render_impl, render_stability_since_raw, write_srclink, AssocItemLink, Context, + ImplRenderingParameters, }; use crate::clean::{self, GetDefId}; use crate::formats::item_type::ItemType; @@ -173,7 +173,7 @@ fn toggle_close(w: &mut Buffer) { } fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) { - document(w, cx, item, None); + document(w, cx, item, None, 1); let mut indices = (0..items.len()).filter(|i| !items[*i].is_stripped()).collect::>(); @@ -485,7 +485,7 @@ fn item_function(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, f: &clean:: notable_traits = notable_traits_decl(&f.decl, cx), ); }); - document(w, cx, it, None) + document(w, cx, it, None, 1) } fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Trait) { @@ -608,7 +608,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra }); // Trait documentation - document(w, cx, it, None); + document(w, cx, it, None, 1); fn write_small_section_header(w: &mut Buffer, id: &str, title: &str, extra_content: &str) { write!( @@ -626,7 +626,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra let item_type = m.type_(); let id = cx.derive_id(format!("{}.{}", item_type, name)); let mut content = Buffer::empty_from(w); - document_at_level(&mut content, cx, m, Some(t), 3); + document(&mut content, cx, m, Some(t), 4); let toggled = !content.is_empty(); if toggled { write!(w, "
"); @@ -840,7 +840,7 @@ fn item_trait_alias(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clea ); }); - document(w, cx, it, None); + document(w, cx, it, None, 1); // Render any items associated directly to this alias, as otherwise they // won't be visible anywhere in the docs. It would be nice to also show @@ -862,7 +862,7 @@ fn item_opaque_ty(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean: ); }); - document(w, cx, it, None); + document(w, cx, it, None, 1); // Render any items associated directly to this alias, as otherwise they // won't be visible anywhere in the docs. It would be nice to also show @@ -893,7 +893,7 @@ fn item_typedef( ); }); - document(w, cx, it, None); + document(w, cx, it, None, 1); let def_id = it.def_id.expect_def_id(); // Render any items associated directly to this alias, as otherwise they @@ -911,7 +911,7 @@ fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Uni }); }); - document(w, cx, it, None); + document(w, cx, it, None, 1); let mut fields = s .fields @@ -944,7 +944,7 @@ fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Uni if let Some(stability_class) = field.stability_class(cx.tcx()) { write!(w, "", stab = stability_class); } - document(w, cx, field, Some(it)); + document(w, cx, field, Some(it), 1); } } let def_id = it.def_id.expect_def_id(); @@ -1026,7 +1026,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum }); }); - document(w, cx, it, None); + document(w, cx, it, None, 1); if !e.variants.is_empty() { write!( @@ -1055,7 +1055,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum w.write_str(""); render_stability_since(w, variant, it, cx.tcx()); w.write_str(""); - document(w, cx, variant, Some(it)); + document(w, cx, variant, Some(it), 1); document_non_exhaustive(w, variant); use crate::clean::Variant; @@ -1095,7 +1095,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum f = field.name.as_ref().unwrap(), t = ty.print(cx) ); - document(w, cx, field, Some(variant)); + document(w, cx, field, Some(variant), 1); } _ => unreachable!(), } @@ -1122,7 +1122,7 @@ fn item_macro(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Mac None, ); }); - document(w, cx, it, None) + document(w, cx, it, None, 1) } fn item_proc_macro(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, m: &clean::ProcMacro) { @@ -1152,11 +1152,11 @@ fn item_proc_macro(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, m: &clean }); } } - document(w, cx, it, None) + document(w, cx, it, None, 1) } fn item_primitive(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item) { - document(w, cx, it, None); + document(w, cx, it, None, 1); render_assoc_items(w, cx, it, it.def_id.expect_def_id(), AssocItemRender::All) } @@ -1195,7 +1195,7 @@ fn item_constant(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, c: &clean:: } }); - document(w, cx, it, None) + document(w, cx, it, None, 1) } fn item_struct(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Struct) { @@ -1206,7 +1206,7 @@ fn item_struct(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St }); }); - document(w, cx, it, None); + document(w, cx, it, None, 1); let mut fields = s .fields @@ -1242,7 +1242,7 @@ fn item_struct(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St name = field_name, ty = ty.print(cx) ); - document(w, cx, field, Some(it)); + document(w, cx, field, Some(it), 1); } } } @@ -1263,7 +1263,7 @@ fn item_static(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St typ = s.type_.print(cx) ); }); - document(w, cx, it, None) + document(w, cx, it, None, 1) } fn item_foreign_type(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item) { @@ -1278,13 +1278,13 @@ fn item_foreign_type(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item) { ); }); - document(w, cx, it, None); + document(w, cx, it, None, 1); render_assoc_items(w, cx, it, it.def_id.expect_def_id(), AssocItemRender::All) } fn item_keyword(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item) { - document(w, cx, it, None) + document(w, cx, it, None, 1) } /// Compare two strings treating multi-digit numbers as single units (i.e. natural sort order). diff --git a/src/tools/error_index_generator/main.rs b/src/tools/error_index_generator/main.rs index f3c5d65935f66..f89f28242a228 100644 --- a/src/tools/error_index_generator/main.rs +++ b/src/tools/error_index_generator/main.rs @@ -126,7 +126,7 @@ impl Formatter for HTMLFormatter { error_codes: ErrorCodes::Yes, edition: DEFAULT_EDITION, playground: &Some(playground), - heading_level: 0 + heading_level: 1 } .into_string() )? From f1425c7c3e62b519354d1a178181a66dad943b4e Mon Sep 17 00:00:00 2001 From: Mukund Lakshman Date: Mon, 4 Oct 2021 21:54:00 -0400 Subject: [PATCH 5/8] heading_level: u32 -> heading_offset: HeadingOffset --- src/librustdoc/externalfiles.rs | 6 ++-- src/librustdoc/html/markdown.rs | 41 +++++++++++++++------- src/librustdoc/html/markdown/tests.rs | 6 ++-- src/librustdoc/html/render/mod.rs | 42 +++++++++++++--------- src/librustdoc/html/render/print_item.rs | 44 ++++++++++++------------ src/librustdoc/markdown.rs | 6 ++-- src/tools/error_index_generator/main.rs | 4 +-- 7 files changed, 88 insertions(+), 61 deletions(-) diff --git a/src/librustdoc/externalfiles.rs b/src/librustdoc/externalfiles.rs index cb5c9edcde570..302fc5a677771 100644 --- a/src/librustdoc/externalfiles.rs +++ b/src/librustdoc/externalfiles.rs @@ -1,4 +1,4 @@ -use crate::html::markdown::{ErrorCodes, IdMap, Markdown, Playground}; +use crate::html::markdown::{ErrorCodes, HeadingOffset, IdMap, Markdown, Playground}; use crate::rustc_span::edition::Edition; use std::fs; use std::path::Path; @@ -46,7 +46,7 @@ impl ExternalHtml { error_codes: codes, edition, playground, - heading_level: 1 + heading_offset: HeadingOffset::H2, } .into_string() ); @@ -62,7 +62,7 @@ impl ExternalHtml { error_codes: codes, edition, playground, - heading_level: 1 + heading_offset: HeadingOffset::H2, } .into_string() ); diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index ef2f2f90301fb..9f2e282fce1c3 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -8,7 +8,7 @@ //! extern crate rustc_span; //! //! use rustc_span::edition::Edition; -//! use rustdoc::html::markdown::{IdMap, Markdown, ErrorCodes}; +//! use rustdoc::html::markdown::{HeadingOffset, IdMap, Markdown, ErrorCodes}; //! //! let s = "My *markdown* _text_"; //! let mut id_map = IdMap::new(); @@ -19,7 +19,7 @@ //! error_codes: ErrorCodes::Yes, //! edition: Edition::Edition2015, //! playground: &None, -//! heading_level: 1 +//! heading_offset: HeadingOffset::H2, //! }; //! let html = md.into_string(); //! // ... something using html @@ -75,6 +75,16 @@ pub(crate) fn summary_opts() -> Options { | Options::ENABLE_SMART_PUNCTUATION } +#[derive(Debug, Clone, Copy)] +pub enum HeadingOffset { + H1 = 0, + H2, + H3, + H4, + H5, + H6, +} + /// When `to_string` is called, this struct will emit the HTML corresponding to /// the rendered version of the contained markdown string. pub struct Markdown<'a> { @@ -89,8 +99,8 @@ pub struct Markdown<'a> { pub edition: Edition, pub playground: &'a Option, /// Offset at which we render headings. - /// E.g. if `heading_level: 1`, then `# something` renders an `

` instead of `

` - pub heading_level: u32, + /// E.g. if `heading_offset: HeadingOffset::H2`, then `# something` renders an `

`. + pub heading_offset: HeadingOffset, } /// A tuple struct like `Markdown` that renders the markdown with a table of contents. crate struct MarkdownWithToc<'a>( @@ -502,12 +512,17 @@ struct HeadingLinks<'a, 'b, 'ids, I> { toc: Option<&'b mut TocBuilder>, buf: VecDeque>, id_map: &'ids mut IdMap, - level: u32, + heading_offset: HeadingOffset, } impl<'a, 'b, 'ids, I> HeadingLinks<'a, 'b, 'ids, I> { - fn new(iter: I, toc: Option<&'b mut TocBuilder>, ids: &'ids mut IdMap, level: u32) -> Self { - HeadingLinks { inner: iter, toc, buf: VecDeque::new(), id_map: ids, level } + fn new( + iter: I, + toc: Option<&'b mut TocBuilder>, + ids: &'ids mut IdMap, + heading_offset: HeadingOffset, + ) -> Self { + HeadingLinks { inner: iter, toc, buf: VecDeque::new(), id_map: ids, heading_offset } } } @@ -544,7 +559,7 @@ impl<'a, 'b, 'ids, I: Iterator>> Iterator self.buf.push_front((Event::Html(format!("{} ", sec).into()), 0..0)); } - let level = std::cmp::min(level + self.level, MAX_HEADER_LEVEL); + let level = std::cmp::min(level + (self.heading_offset as u32), MAX_HEADER_LEVEL); self.buf.push_back((Event::Html(format!("", level).into()), 0..0)); let start_tags = format!( @@ -1027,7 +1042,7 @@ impl Markdown<'_> { error_codes: codes, edition, playground, - heading_level, + heading_offset, } = self; // This is actually common enough to special-case @@ -1049,7 +1064,7 @@ impl Markdown<'_> { let mut s = String::with_capacity(md.len() * 3 / 2); - let p = HeadingLinks::new(p, None, &mut ids, heading_level); + let p = HeadingLinks::new(p, None, &mut ids, heading_offset); let p = Footnotes::new(p); let p = LinkReplacer::new(p.map(|(ev, _)| ev), links); let p = TableWrapper::new(p); @@ -1071,7 +1086,7 @@ impl MarkdownWithToc<'_> { let mut toc = TocBuilder::new(); { - let p = HeadingLinks::new(p, Some(&mut toc), &mut ids, 0); + let p = HeadingLinks::new(p, Some(&mut toc), &mut ids, HeadingOffset::H1); let p = Footnotes::new(p); let p = TableWrapper::new(p.map(|(ev, _)| ev)); let p = CodeBlocks::new(p, codes, edition, playground); @@ -1100,7 +1115,7 @@ impl MarkdownHtml<'_> { let mut s = String::with_capacity(md.len() * 3 / 2); - let p = HeadingLinks::new(p, None, &mut ids, 0); + let p = HeadingLinks::new(p, None, &mut ids, HeadingOffset::H1); let p = Footnotes::new(p); let p = TableWrapper::new(p.map(|(ev, _)| ev)); let p = CodeBlocks::new(p, codes, edition, playground); @@ -1318,7 +1333,7 @@ crate fn markdown_links(md: &str) -> Vec { // There's no need to thread an IdMap through to here because // the IDs generated aren't going to be emitted anywhere. let mut ids = IdMap::new(); - let iter = Footnotes::new(HeadingLinks::new(p, None, &mut ids, 0)); + let iter = Footnotes::new(HeadingLinks::new(p, None, &mut ids, HeadingOffset::H1)); for ev in iter { if let Event::Start(Tag::Link(kind, dest, _)) = ev.0 { diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs index ee6a19978969e..68ab002f13867 100644 --- a/src/librustdoc/html/markdown/tests.rs +++ b/src/librustdoc/html/markdown/tests.rs @@ -1,5 +1,5 @@ use super::{find_testable_code, plain_text_summary, short_markdown_summary}; -use super::{ErrorCodes, IdMap, Ignore, LangString, Markdown, MarkdownHtml}; +use super::{ErrorCodes, HeadingOffset, IdMap, Ignore, LangString, Markdown, MarkdownHtml}; use rustc_span::edition::{Edition, DEFAULT_EDITION}; #[test] @@ -154,7 +154,7 @@ fn test_header() { error_codes: ErrorCodes::Yes, edition: DEFAULT_EDITION, playground: &None, - heading_level: 1, + heading_offset: HeadingOffset::H2, } .into_string(); assert_eq!(output, expect, "original: {}", input); @@ -196,7 +196,7 @@ fn test_header_ids_multiple_blocks() { error_codes: ErrorCodes::Yes, edition: DEFAULT_EDITION, playground: &None, - heading_level: 1, + heading_offset: HeadingOffset::H2, } .into_string(); assert_eq!(output, expect, "original: {}", input); diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 8cf11e526fe38..11682afdf899b 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -67,7 +67,7 @@ use crate::html::format::{ href, print_abi_with_space, print_constness_with_space, print_default_space, print_generic_bounds, print_where_clause, Buffer, HrefError, PrintWithSpace, }; -use crate::html::markdown::{Markdown, MarkdownHtml, MarkdownSummaryLine}; +use crate::html::markdown::{HeadingOffset, Markdown, MarkdownHtml, MarkdownSummaryLine}; /// A pair of name and its optional document. crate type NameDoc = (String, Option); @@ -475,16 +475,16 @@ fn document( cx: &Context<'_>, item: &clean::Item, parent: Option<&clean::Item>, - level: u32, + heading_offset: HeadingOffset, ) { if let Some(ref name) = item.name { info!("Documenting {}", name); } document_item_info(w, cx, item, parent); if parent.is_none() { - document_full_collapsible(w, item, cx, level); + document_full_collapsible(w, item, cx, heading_offset); } else { - document_full(w, item, cx, level); + document_full(w, item, cx, heading_offset); } } @@ -494,7 +494,7 @@ fn render_markdown( cx: &Context<'_>, md_text: &str, links: Vec, - heading_level: u32, + heading_offset: HeadingOffset, ) { let mut ids = cx.id_map.borrow_mut(); write!( @@ -507,7 +507,7 @@ fn render_markdown( error_codes: cx.shared.codes, edition: cx.shared.edition(), playground: &cx.shared.playground, - heading_level, + heading_offset, } .into_string() ) @@ -544,12 +544,22 @@ fn document_short( } } -fn document_full_collapsible(w: &mut Buffer, item: &clean::Item, cx: &Context<'_>, level: u32) { - document_full_inner(w, item, cx, true, level); +fn document_full_collapsible( + w: &mut Buffer, + item: &clean::Item, + cx: &Context<'_>, + heading_offset: HeadingOffset, +) { + document_full_inner(w, item, cx, true, heading_offset); } -fn document_full(w: &mut Buffer, item: &clean::Item, cx: &Context<'_>, level: u32) { - document_full_inner(w, item, cx, false, level); +fn document_full( + w: &mut Buffer, + item: &clean::Item, + cx: &Context<'_>, + heading_offset: HeadingOffset, +) { + document_full_inner(w, item, cx, false, heading_offset); } fn document_full_inner( @@ -557,7 +567,7 @@ fn document_full_inner( item: &clean::Item, cx: &Context<'_>, is_collapsible: bool, - level: u32, + heading_offset: HeadingOffset, ) { if let Some(s) = cx.shared.maybe_collapsed_doc_value(item) { debug!("Doc block: =====\n{}\n=====", s); @@ -568,10 +578,10 @@ fn document_full_inner( Expand description\

", ); - render_markdown(w, cx, &s, item.links(cx), level); + render_markdown(w, cx, &s, item.links(cx), heading_offset); w.write_str("
"); } else { - render_markdown(w, cx, &s, item.links(cx), level); + render_markdown(w, cx, &s, item.links(cx), heading_offset); } } } @@ -1340,7 +1350,7 @@ fn render_impl( // because impls can't have a stability. if item.doc_value().is_some() { document_item_info(&mut info_buffer, cx, it, Some(parent)); - document_full(&mut doc_buffer, item, cx, 4); + document_full(&mut doc_buffer, item, cx, HeadingOffset::H5); short_documented = false; } else { // In case the item isn't documented, @@ -1358,7 +1368,7 @@ fn render_impl( } else { document_item_info(&mut info_buffer, cx, item, Some(parent)); if rendering_params.show_def_docs { - document_full(&mut doc_buffer, item, cx, 4); + document_full(&mut doc_buffer, item, cx, HeadingOffset::H5); short_documented = false; } } @@ -1599,7 +1609,7 @@ fn render_impl( error_codes: cx.shared.codes, edition: cx.shared.edition(), playground: &cx.shared.playground, - heading_level: 1 + heading_offset: HeadingOffset::H2 } .into_string() ); diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index f26ee84569b49..9b39a3eeaf0fa 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -30,7 +30,7 @@ use crate::html::format::{ }; use crate::html::highlight; use crate::html::layout::Page; -use crate::html::markdown::MarkdownSummaryLine; +use crate::html::markdown::{HeadingOffset, MarkdownSummaryLine}; const ITEM_TABLE_OPEN: &'static str = "
"; const ITEM_TABLE_CLOSE: &'static str = "
"; @@ -173,7 +173,7 @@ fn toggle_close(w: &mut Buffer) { } fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) { - document(w, cx, item, None, 1); + document(w, cx, item, None, HeadingOffset::H2); let mut indices = (0..items.len()).filter(|i| !items[*i].is_stripped()).collect::>(); @@ -485,7 +485,7 @@ fn item_function(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, f: &clean:: notable_traits = notable_traits_decl(&f.decl, cx), ); }); - document(w, cx, it, None, 1) + document(w, cx, it, None, HeadingOffset::H2) } fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Trait) { @@ -608,7 +608,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra }); // Trait documentation - document(w, cx, it, None, 1); + document(w, cx, it, None, HeadingOffset::H2); fn write_small_section_header(w: &mut Buffer, id: &str, title: &str, extra_content: &str) { write!( @@ -626,7 +626,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra let item_type = m.type_(); let id = cx.derive_id(format!("{}.{}", item_type, name)); let mut content = Buffer::empty_from(w); - document(&mut content, cx, m, Some(t), 4); + document(&mut content, cx, m, Some(t), HeadingOffset::H5); let toggled = !content.is_empty(); if toggled { write!(w, "
"); @@ -840,7 +840,7 @@ fn item_trait_alias(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clea ); }); - document(w, cx, it, None, 1); + document(w, cx, it, None, HeadingOffset::H2); // Render any items associated directly to this alias, as otherwise they // won't be visible anywhere in the docs. It would be nice to also show @@ -862,7 +862,7 @@ fn item_opaque_ty(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean: ); }); - document(w, cx, it, None, 1); + document(w, cx, it, None, HeadingOffset::H2); // Render any items associated directly to this alias, as otherwise they // won't be visible anywhere in the docs. It would be nice to also show @@ -893,7 +893,7 @@ fn item_typedef( ); }); - document(w, cx, it, None, 1); + document(w, cx, it, None, HeadingOffset::H2); let def_id = it.def_id.expect_def_id(); // Render any items associated directly to this alias, as otherwise they @@ -911,7 +911,7 @@ fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Uni }); }); - document(w, cx, it, None, 1); + document(w, cx, it, None, HeadingOffset::H2); let mut fields = s .fields @@ -944,7 +944,7 @@ fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Uni if let Some(stability_class) = field.stability_class(cx.tcx()) { write!(w, "", stab = stability_class); } - document(w, cx, field, Some(it), 1); + document(w, cx, field, Some(it), HeadingOffset::H2); } } let def_id = it.def_id.expect_def_id(); @@ -1026,7 +1026,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum }); }); - document(w, cx, it, None, 1); + document(w, cx, it, None, HeadingOffset::H2); if !e.variants.is_empty() { write!( @@ -1055,7 +1055,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum w.write_str(""); render_stability_since(w, variant, it, cx.tcx()); w.write_str(""); - document(w, cx, variant, Some(it), 1); + document(w, cx, variant, Some(it), HeadingOffset::H2); document_non_exhaustive(w, variant); use crate::clean::Variant; @@ -1095,7 +1095,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum f = field.name.as_ref().unwrap(), t = ty.print(cx) ); - document(w, cx, field, Some(variant), 1); + document(w, cx, field, Some(variant), HeadingOffset::H2); } _ => unreachable!(), } @@ -1122,7 +1122,7 @@ fn item_macro(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Mac None, ); }); - document(w, cx, it, None, 1) + document(w, cx, it, None, HeadingOffset::H2) } fn item_proc_macro(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, m: &clean::ProcMacro) { @@ -1152,11 +1152,11 @@ fn item_proc_macro(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, m: &clean }); } } - document(w, cx, it, None, 1) + document(w, cx, it, None, HeadingOffset::H2) } fn item_primitive(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item) { - document(w, cx, it, None, 1); + document(w, cx, it, None, HeadingOffset::H2); render_assoc_items(w, cx, it, it.def_id.expect_def_id(), AssocItemRender::All) } @@ -1195,7 +1195,7 @@ fn item_constant(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, c: &clean:: } }); - document(w, cx, it, None, 1) + document(w, cx, it, None, HeadingOffset::H2) } fn item_struct(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Struct) { @@ -1206,7 +1206,7 @@ fn item_struct(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St }); }); - document(w, cx, it, None, 1); + document(w, cx, it, None, HeadingOffset::H2); let mut fields = s .fields @@ -1242,7 +1242,7 @@ fn item_struct(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St name = field_name, ty = ty.print(cx) ); - document(w, cx, field, Some(it), 1); + document(w, cx, field, Some(it), HeadingOffset::H2); } } } @@ -1263,7 +1263,7 @@ fn item_static(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St typ = s.type_.print(cx) ); }); - document(w, cx, it, None, 1) + document(w, cx, it, None, HeadingOffset::H2) } fn item_foreign_type(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item) { @@ -1278,13 +1278,13 @@ fn item_foreign_type(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item) { ); }); - document(w, cx, it, None, 1); + document(w, cx, it, None, HeadingOffset::H2); render_assoc_items(w, cx, it, it.def_id.expect_def_id(), AssocItemRender::All) } fn item_keyword(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item) { - document(w, cx, it, None, 1) + document(w, cx, it, None, HeadingOffset::H2) } /// Compare two strings treating multi-digit numbers as single units (i.e. natural sort order). diff --git a/src/librustdoc/markdown.rs b/src/librustdoc/markdown.rs index 962712f5b9175..47b24d40edc27 100644 --- a/src/librustdoc/markdown.rs +++ b/src/librustdoc/markdown.rs @@ -10,7 +10,9 @@ use crate::config::{Options, RenderOptions}; use crate::doctest::{Collector, TestOptions}; use crate::html::escape::Escape; use crate::html::markdown; -use crate::html::markdown::{find_testable_code, ErrorCodes, IdMap, Markdown, MarkdownWithToc}; +use crate::html::markdown::{ + find_testable_code, ErrorCodes, HeadingOffset, IdMap, Markdown, MarkdownWithToc, +}; /// Separate any lines at the start of the file that begin with `# ` or `%`. fn extract_leading_metadata(s: &str) -> (Vec<&str>, &str) { @@ -77,7 +79,7 @@ crate fn render>( error_codes, edition, playground: &playground, - heading_level: 0, + heading_offset: HeadingOffset::H1, } .into_string() }; diff --git a/src/tools/error_index_generator/main.rs b/src/tools/error_index_generator/main.rs index f89f28242a228..e796934961094 100644 --- a/src/tools/error_index_generator/main.rs +++ b/src/tools/error_index_generator/main.rs @@ -14,7 +14,7 @@ use std::path::PathBuf; use rustc_span::edition::DEFAULT_EDITION; -use rustdoc::html::markdown::{ErrorCodes, IdMap, Markdown, Playground}; +use rustdoc::html::markdown::{ErrorCodes, HeadingOffset, IdMap, Markdown, Playground}; pub struct ErrorMetadata { pub description: Option, @@ -126,7 +126,7 @@ impl Formatter for HTMLFormatter { error_codes: ErrorCodes::Yes, edition: DEFAULT_EDITION, playground: &Some(playground), - heading_level: 1 + heading_offset: HeadingOffset::H2, } .into_string() )? From 08a4f24f6873bff2845e1e52f2785a8a903ac133 Mon Sep 17 00:00:00 2001 From: Mukund Lakshman Date: Mon, 4 Oct 2021 21:54:48 -0400 Subject: [PATCH 6/8] Add tests for ensuring docblock headings. --- .../rustdoc/issue-89309-heading-levels.rs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/test/rustdoc/issue-89309-heading-levels.rs diff --git a/src/test/rustdoc/issue-89309-heading-levels.rs b/src/test/rustdoc/issue-89309-heading-levels.rs new file mode 100644 index 0000000000000..bb706c28ffa51 --- /dev/null +++ b/src/test/rustdoc/issue-89309-heading-levels.rs @@ -0,0 +1,29 @@ +#![crate_name = "foo"] + +// @has foo/trait.Read.html +// @has - '//h2' 'Trait examples' +/// # Trait examples +pub trait Read { + // @has - '//h5' 'Function examples' + /// # Function examples + fn read(&mut self, buf: &mut [u8]) -> Result; +} + +pub struct Foo; + +// @has foo/struct.Foo.html +impl Foo { + // @has - '//h5' 'Implementation header' + /// # Implementation header + pub fn bar(&self) -> usize { + 1 + } +} + +impl Read for Foo { + // @has - '//h5' 'Trait implementation header' + /// # Trait implementation header + fn read(&mut self, buf: &mut [u8]) -> Result { + Ok(1) + } +} From 742d8be5e6c1cedfde503424036b597c514079ae Mon Sep 17 00:00:00 2001 From: Mukund Lakshman Date: Wed, 6 Oct 2021 07:27:13 -0400 Subject: [PATCH 7/8] Restore h1 styles, which got accidentally removed. --- src/librustdoc/html/static/css/themes/ayu.css | 2 +- src/librustdoc/html/static/css/themes/dark.css | 2 +- src/librustdoc/html/static/css/themes/light.css | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/html/static/css/themes/ayu.css b/src/librustdoc/html/static/css/themes/ayu.css index 0fb4f95acdf34..0fd6462a8f5dd 100644 --- a/src/librustdoc/html/static/css/themes/ayu.css +++ b/src/librustdoc/html/static/css/themes/ayu.css @@ -136,7 +136,7 @@ pre, .rustdoc.source .example-wrap { border-right: 1px solid #ffb44c; } -.docblock h2, .docblock h3, .docblock h4, .docblock h5, .docblock h6 { +.docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5, .docblock h6 { border-bottom-color: #5c6773; } diff --git a/src/librustdoc/html/static/css/themes/dark.css b/src/librustdoc/html/static/css/themes/dark.css index 4fb6f7b38bbf2..d863701dd73c7 100644 --- a/src/librustdoc/html/static/css/themes/dark.css +++ b/src/librustdoc/html/static/css/themes/dark.css @@ -93,7 +93,7 @@ pre, .rustdoc.source .example-wrap { background-color: #0a042f !important; } -.docblock h2, .docblock h3, .docblock h4, .docblock h5, .docblock h6 { +.docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5, .docblock h6 { border-bottom-color: #DDD; } diff --git a/src/librustdoc/html/static/css/themes/light.css b/src/librustdoc/html/static/css/themes/light.css index 62134f025c82a..28d2e99a3d073 100644 --- a/src/librustdoc/html/static/css/themes/light.css +++ b/src/librustdoc/html/static/css/themes/light.css @@ -93,7 +93,7 @@ pre, .rustdoc.source .example-wrap { background-color: #f6fdb0 !important; } -.docblock h2, .docblock h3, .docblock h4, .docblock h5, .docblock h6 { +.docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5, .docblock h6 { border-bottom-color: #ddd; } From 1f86a8e2a058d7f12b25406a53576b08817677fe Mon Sep 17 00:00:00 2001 From: Mukund Lakshman Date: Wed, 6 Oct 2021 07:58:41 -0400 Subject: [PATCH 8/8] Revert the rustc_error_codes changes. --- compiler/rustc_error_codes/src/error_codes/E0001.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0002.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0007.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0009.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0014.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0073.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0074.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0087.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0088.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0089.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0090.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0110.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0136.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0137.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0139.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0154.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0162.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0165.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0193.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0205.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0211.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0243.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0244.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0251.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0256.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0281.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0297.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0301.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0302.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0303.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0329.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0383.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0386.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0387.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0388.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0389.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0398.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0399.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0439.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0447.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0448.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0497.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0504.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0595.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0619.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0633.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0665.md | 2 +- compiler/rustc_error_codes/src/error_codes/E0671.md | 2 +- src/tools/error_index_generator/main.rs | 2 +- src/tools/tidy/src/error_codes_check.rs | 4 ++-- 50 files changed, 51 insertions(+), 51 deletions(-) diff --git a/compiler/rustc_error_codes/src/error_codes/E0001.md b/compiler/rustc_error_codes/src/error_codes/E0001.md index cd6e15f581f3b..90756780d1502 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0001.md +++ b/compiler/rustc_error_codes/src/error_codes/E0001.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. This error suggests that the expression arm corresponding to the noted pattern will never be reached as for all possible values of the expression being diff --git a/compiler/rustc_error_codes/src/error_codes/E0002.md b/compiler/rustc_error_codes/src/error_codes/E0002.md index 4e7aa7fb9ed81..5cb59da10e00b 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0002.md +++ b/compiler/rustc_error_codes/src/error_codes/E0002.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. This error indicates that an empty match expression is invalid because the type it is matching on is non-empty (there exist values of this type). In safe code diff --git a/compiler/rustc_error_codes/src/error_codes/E0007.md b/compiler/rustc_error_codes/src/error_codes/E0007.md index d30de4af0eb37..2c22b86af9246 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0007.md +++ b/compiler/rustc_error_codes/src/error_codes/E0007.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. This error indicates that the bindings in a match arm would require a value to be moved into more than one location, thus violating unique ownership. Code diff --git a/compiler/rustc_error_codes/src/error_codes/E0009.md b/compiler/rustc_error_codes/src/error_codes/E0009.md index 6aab44cb4d6ec..aaabba0434993 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0009.md +++ b/compiler/rustc_error_codes/src/error_codes/E0009.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. In a pattern, all values that don't implement the `Copy` trait have to be bound the same way. The goal here is to avoid binding simultaneously by-move and diff --git a/compiler/rustc_error_codes/src/error_codes/E0014.md b/compiler/rustc_error_codes/src/error_codes/E0014.md index 27ae8f098987a..2c69957e9f642 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0014.md +++ b/compiler/rustc_error_codes/src/error_codes/E0014.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. Constants can only be initialized by a constant value or, in a future version of Rust, a call to a const function. This error indicates the use diff --git a/compiler/rustc_error_codes/src/error_codes/E0073.md b/compiler/rustc_error_codes/src/error_codes/E0073.md index 39c16bc438fea..a5aea86ff2d9d 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0073.md +++ b/compiler/rustc_error_codes/src/error_codes/E0073.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. You cannot define a struct (or enum) `Foo` that requires an instance of `Foo` in order to make a new `Foo` value. This is because there would be no way a diff --git a/compiler/rustc_error_codes/src/error_codes/E0074.md b/compiler/rustc_error_codes/src/error_codes/E0074.md index 026acac99e74f..785d6de226d3d 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0074.md +++ b/compiler/rustc_error_codes/src/error_codes/E0074.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. When using the `#[simd]` attribute on a tuple struct, the components of the tuple struct must all be of a concrete, nongeneric type so the compiler can diff --git a/compiler/rustc_error_codes/src/error_codes/E0087.md b/compiler/rustc_error_codes/src/error_codes/E0087.md index cd2da0469bb63..9d292186f0fa5 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0087.md +++ b/compiler/rustc_error_codes/src/error_codes/E0087.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. Too many type arguments were supplied for a function. For example: diff --git a/compiler/rustc_error_codes/src/error_codes/E0088.md b/compiler/rustc_error_codes/src/error_codes/E0088.md index 6b565507ce4a3..7780ad5b56e03 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0088.md +++ b/compiler/rustc_error_codes/src/error_codes/E0088.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. You gave too many lifetime arguments. Erroneous code example: diff --git a/compiler/rustc_error_codes/src/error_codes/E0089.md b/compiler/rustc_error_codes/src/error_codes/E0089.md index b78f95f266c19..504fbc7b96a98 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0089.md +++ b/compiler/rustc_error_codes/src/error_codes/E0089.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. Too few type arguments were supplied for a function. For example: diff --git a/compiler/rustc_error_codes/src/error_codes/E0090.md b/compiler/rustc_error_codes/src/error_codes/E0090.md index 7b07a86dc25a4..e091bb6c9f2f7 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0090.md +++ b/compiler/rustc_error_codes/src/error_codes/E0090.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. You gave too few lifetime arguments. Example: diff --git a/compiler/rustc_error_codes/src/error_codes/E0110.md b/compiler/rustc_error_codes/src/error_codes/E0110.md index 91f599ff1dcfb..b9fe406ffb9bd 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0110.md +++ b/compiler/rustc_error_codes/src/error_codes/E0110.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. You tried to provide a lifetime to a type which doesn't need it. See `E0109` for more details. diff --git a/compiler/rustc_error_codes/src/error_codes/E0136.md b/compiler/rustc_error_codes/src/error_codes/E0136.md index 0a74558e75b05..15cf09a18cbde 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0136.md +++ b/compiler/rustc_error_codes/src/error_codes/E0136.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. More than one `main` function was found. diff --git a/compiler/rustc_error_codes/src/error_codes/E0137.md b/compiler/rustc_error_codes/src/error_codes/E0137.md index ba6f02add9494..d4e19170f3f7b 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0137.md +++ b/compiler/rustc_error_codes/src/error_codes/E0137.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. More than one function was declared with the `#[main]` attribute. diff --git a/compiler/rustc_error_codes/src/error_codes/E0139.md b/compiler/rustc_error_codes/src/error_codes/E0139.md index e7ad2a6f44dc1..a116cf29395fa 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0139.md +++ b/compiler/rustc_error_codes/src/error_codes/E0139.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. There are various restrictions on transmuting between types in Rust; for example types being transmuted must have the same size. To apply all these restrictions, diff --git a/compiler/rustc_error_codes/src/error_codes/E0154.md b/compiler/rustc_error_codes/src/error_codes/E0154.md index 9c954839eee6b..e437a71897c66 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0154.md +++ b/compiler/rustc_error_codes/src/error_codes/E0154.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. Imports (`use` statements) are not allowed after non-item statements, such as variable declarations and expression statements. diff --git a/compiler/rustc_error_codes/src/error_codes/E0162.md b/compiler/rustc_error_codes/src/error_codes/E0162.md index 2e0f387e3521f..0161c9325c211 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0162.md +++ b/compiler/rustc_error_codes/src/error_codes/E0162.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. An `if let` pattern attempts to match the pattern, and enters the body if the match was successful. If the match is irrefutable (when it cannot fail to diff --git a/compiler/rustc_error_codes/src/error_codes/E0165.md b/compiler/rustc_error_codes/src/error_codes/E0165.md index 3222b7a87eb65..7bcd6c0cbf379 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0165.md +++ b/compiler/rustc_error_codes/src/error_codes/E0165.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. A `while let` pattern attempts to match the pattern, and enters the body if the match was successful. If the match is irrefutable (when it cannot fail to diff --git a/compiler/rustc_error_codes/src/error_codes/E0193.md b/compiler/rustc_error_codes/src/error_codes/E0193.md index 6e7ebbaddf921..e29a949ffba91 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0193.md +++ b/compiler/rustc_error_codes/src/error_codes/E0193.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. `where` clauses must use generic type parameters: it does not make sense to use them otherwise. An example causing this error: diff --git a/compiler/rustc_error_codes/src/error_codes/E0205.md b/compiler/rustc_error_codes/src/error_codes/E0205.md index 07bbd1f68347b..7916f53ad3b41 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0205.md +++ b/compiler/rustc_error_codes/src/error_codes/E0205.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. An attempt to implement the `Copy` trait for an enum failed because one of the variants does not implement `Copy`. To fix this, you must implement `Copy` for diff --git a/compiler/rustc_error_codes/src/error_codes/E0211.md b/compiler/rustc_error_codes/src/error_codes/E0211.md index 2485367e09712..77289f019005e 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0211.md +++ b/compiler/rustc_error_codes/src/error_codes/E0211.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. You used a function or type which doesn't fit the requirements for where it was used. Erroneous code examples: diff --git a/compiler/rustc_error_codes/src/error_codes/E0243.md b/compiler/rustc_error_codes/src/error_codes/E0243.md index ef4a837ec2172..5d3d1828bf59b 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0243.md +++ b/compiler/rustc_error_codes/src/error_codes/E0243.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. This error indicates that not enough type parameters were found in a type or trait. diff --git a/compiler/rustc_error_codes/src/error_codes/E0244.md b/compiler/rustc_error_codes/src/error_codes/E0244.md index 31c5b4542e28f..5187b7b05d2c1 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0244.md +++ b/compiler/rustc_error_codes/src/error_codes/E0244.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. This error indicates that too many type parameters were found in a type or trait. diff --git a/compiler/rustc_error_codes/src/error_codes/E0251.md b/compiler/rustc_error_codes/src/error_codes/E0251.md index 7b048db5ece3e..4121dd27877a0 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0251.md +++ b/compiler/rustc_error_codes/src/error_codes/E0251.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. Two items of the same name cannot be imported without rebinding one of the items under a new local name. diff --git a/compiler/rustc_error_codes/src/error_codes/E0256.md b/compiler/rustc_error_codes/src/error_codes/E0256.md index 1b518b1615b64..385376cdade91 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0256.md +++ b/compiler/rustc_error_codes/src/error_codes/E0256.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. You can't import a type or module when the name of the item being imported is the same as another type or submodule defined in the module. diff --git a/compiler/rustc_error_codes/src/error_codes/E0281.md b/compiler/rustc_error_codes/src/error_codes/E0281.md index 2d8ead0b0181c..1d7904b67ddb4 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0281.md +++ b/compiler/rustc_error_codes/src/error_codes/E0281.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. You tried to supply a type which doesn't implement some trait in a location which expected that trait. This error typically occurs when working with diff --git a/compiler/rustc_error_codes/src/error_codes/E0297.md b/compiler/rustc_error_codes/src/error_codes/E0297.md index 001e0f3089e15..66c31376d8b28 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0297.md +++ b/compiler/rustc_error_codes/src/error_codes/E0297.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. Patterns used to bind names must be irrefutable. That is, they must guarantee that a name will be extracted in all cases. Instead of pattern matching the diff --git a/compiler/rustc_error_codes/src/error_codes/E0301.md b/compiler/rustc_error_codes/src/error_codes/E0301.md index 7b1e02051dc4e..485e19fbb8d9c 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0301.md +++ b/compiler/rustc_error_codes/src/error_codes/E0301.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. Mutable borrows are not allowed in pattern guards, because matching cannot have side effects. Side effects could alter the matched object or the environment diff --git a/compiler/rustc_error_codes/src/error_codes/E0302.md b/compiler/rustc_error_codes/src/error_codes/E0302.md index c56500fcebce8..e6ac9d590c88f 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0302.md +++ b/compiler/rustc_error_codes/src/error_codes/E0302.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. Assignments are not allowed in pattern guards, because matching cannot have side effects. Side effects could alter the matched object or the environment diff --git a/compiler/rustc_error_codes/src/error_codes/E0303.md b/compiler/rustc_error_codes/src/error_codes/E0303.md index 750b766f5bfdf..459906047cc87 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0303.md +++ b/compiler/rustc_error_codes/src/error_codes/E0303.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. Sub-bindings, e.g. `ref x @ Some(ref y)` are now allowed under `#![feature(bindings_after_at)]` and checked to make sure that diff --git a/compiler/rustc_error_codes/src/error_codes/E0329.md b/compiler/rustc_error_codes/src/error_codes/E0329.md index 36114316e8803..37d84a1a89bfe 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0329.md +++ b/compiler/rustc_error_codes/src/error_codes/E0329.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. An attempt was made to access an associated constant through either a generic type parameter or `Self`. This is not supported yet. An example causing this diff --git a/compiler/rustc_error_codes/src/error_codes/E0383.md b/compiler/rustc_error_codes/src/error_codes/E0383.md index 309eb2b59eb97..fd2b0b08fb007 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0383.md +++ b/compiler/rustc_error_codes/src/error_codes/E0383.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. This error occurs when an attempt is made to partially reinitialize a structure that is currently uninitialized. diff --git a/compiler/rustc_error_codes/src/error_codes/E0386.md b/compiler/rustc_error_codes/src/error_codes/E0386.md index 5e45a2b40cefa..de3b468b6e4ac 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0386.md +++ b/compiler/rustc_error_codes/src/error_codes/E0386.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. This error occurs when an attempt is made to mutate the target of a mutable reference stored inside an immutable container. diff --git a/compiler/rustc_error_codes/src/error_codes/E0387.md b/compiler/rustc_error_codes/src/error_codes/E0387.md index ddc838bdca1b3..38ad19bd6aa9a 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0387.md +++ b/compiler/rustc_error_codes/src/error_codes/E0387.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. This error occurs when an attempt is made to mutate or mutably reference data that a closure has captured immutably. diff --git a/compiler/rustc_error_codes/src/error_codes/E0388.md b/compiler/rustc_error_codes/src/error_codes/E0388.md index 13ef94a48553b..512fb42e6ecb5 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0388.md +++ b/compiler/rustc_error_codes/src/error_codes/E0388.md @@ -1 +1 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. diff --git a/compiler/rustc_error_codes/src/error_codes/E0389.md b/compiler/rustc_error_codes/src/error_codes/E0389.md index 19bb6ec408131..9f064e44c8209 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0389.md +++ b/compiler/rustc_error_codes/src/error_codes/E0389.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. An attempt was made to mutate data using a non-mutable reference. This commonly occurs when attempting to assign to a non-mutable reference of a diff --git a/compiler/rustc_error_codes/src/error_codes/E0398.md b/compiler/rustc_error_codes/src/error_codes/E0398.md index 12e0eb1a5d5dd..75d86979e3c87 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0398.md +++ b/compiler/rustc_error_codes/src/error_codes/E0398.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. In Rust 1.3, the default object lifetime bounds are expected to change, as described in [RFC 1156]. You are getting a warning because the compiler diff --git a/compiler/rustc_error_codes/src/error_codes/E0399.md b/compiler/rustc_error_codes/src/error_codes/E0399.md index c3e9616c60698..6ea6054b41779 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0399.md +++ b/compiler/rustc_error_codes/src/error_codes/E0399.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler +#### Note: this error code is no longer emitted by the compiler You implemented a trait, overriding one or more of its associated types but did not reimplement its default methods. diff --git a/compiler/rustc_error_codes/src/error_codes/E0439.md b/compiler/rustc_error_codes/src/error_codes/E0439.md index 85e965c4eee62..24268aef2222a 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0439.md +++ b/compiler/rustc_error_codes/src/error_codes/E0439.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. The length of the platform-intrinsic function `simd_shuffle` wasn't specified. diff --git a/compiler/rustc_error_codes/src/error_codes/E0447.md b/compiler/rustc_error_codes/src/error_codes/E0447.md index e880ff4637da7..af8cd8d6d5202 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0447.md +++ b/compiler/rustc_error_codes/src/error_codes/E0447.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. The `pub` keyword was used inside a function. diff --git a/compiler/rustc_error_codes/src/error_codes/E0448.md b/compiler/rustc_error_codes/src/error_codes/E0448.md index f4bd184188824..ba096f9e984ae 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0448.md +++ b/compiler/rustc_error_codes/src/error_codes/E0448.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. The `pub` keyword was used inside a public enum. diff --git a/compiler/rustc_error_codes/src/error_codes/E0497.md b/compiler/rustc_error_codes/src/error_codes/E0497.md index 12004996384a2..ef2882415d24a 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0497.md +++ b/compiler/rustc_error_codes/src/error_codes/E0497.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. A stability attribute was used outside of the standard library. diff --git a/compiler/rustc_error_codes/src/error_codes/E0504.md b/compiler/rustc_error_codes/src/error_codes/E0504.md index 640cfad656f71..bcbd00a8690a4 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0504.md +++ b/compiler/rustc_error_codes/src/error_codes/E0504.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. This error occurs when an attempt is made to move a borrowed variable into a closure. diff --git a/compiler/rustc_error_codes/src/error_codes/E0595.md b/compiler/rustc_error_codes/src/error_codes/E0595.md index 96fbb5e410ae7..e6729013243f6 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0595.md +++ b/compiler/rustc_error_codes/src/error_codes/E0595.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. Closures cannot mutate immutable captured variables. diff --git a/compiler/rustc_error_codes/src/error_codes/E0619.md b/compiler/rustc_error_codes/src/error_codes/E0619.md index d33154058dd37..f516de43095bd 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0619.md +++ b/compiler/rustc_error_codes/src/error_codes/E0619.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. The type-checker needed to know the type of an expression, but that type had not yet been inferred. diff --git a/compiler/rustc_error_codes/src/error_codes/E0633.md b/compiler/rustc_error_codes/src/error_codes/E0633.md index f6e8a4042ed35..5b6c15c82eb63 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0633.md +++ b/compiler/rustc_error_codes/src/error_codes/E0633.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. The `unwind` attribute was malformed. diff --git a/compiler/rustc_error_codes/src/error_codes/E0665.md b/compiler/rustc_error_codes/src/error_codes/E0665.md index db5e088cc501e..ae54d6d15798d 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0665.md +++ b/compiler/rustc_error_codes/src/error_codes/E0665.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. The `Default` trait was derived on an enum. diff --git a/compiler/rustc_error_codes/src/error_codes/E0671.md b/compiler/rustc_error_codes/src/error_codes/E0671.md index a68273f752e73..d4dbfb7a5d8e6 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0671.md +++ b/compiler/rustc_error_codes/src/error_codes/E0671.md @@ -1,4 +1,4 @@ -### Note: this error code is no longer emitted by the compiler. +#### Note: this error code is no longer emitted by the compiler. Const parameters cannot depend on type parameters. The following is therefore invalid: diff --git a/src/tools/error_index_generator/main.rs b/src/tools/error_index_generator/main.rs index e796934961094..5b3da5893ea7e 100644 --- a/src/tools/error_index_generator/main.rs +++ b/src/tools/error_index_generator/main.rs @@ -126,7 +126,7 @@ impl Formatter for HTMLFormatter { error_codes: ErrorCodes::Yes, edition: DEFAULT_EDITION, playground: &Some(playground), - heading_offset: HeadingOffset::H2, + heading_offset: HeadingOffset::H1, } .into_string() )? diff --git a/src/tools/tidy/src/error_codes_check.rs b/src/tools/tidy/src/error_codes_check.rs index ae169d383b273..53c75a463390d 100644 --- a/src/tools/tidy/src/error_codes_check.rs +++ b/src/tools/tidy/src/error_codes_check.rs @@ -49,7 +49,7 @@ fn check_error_code_explanation( } else if s.contains("compile-fail") { invalid_compile_fail_format = true; } - } else if s.starts_with("### Note: this error code is no longer emitted by the compiler") { + } else if s.starts_with("#### Note: this error code is no longer emitted by the compiler") { if !found_error_code { error_codes.get_mut(&err_code).map(|x| x.has_test = true); found_error_code = true; @@ -64,7 +64,7 @@ fn check_if_error_code_is_test_in_explanation(f: &str, err_code: &str) -> bool { for line in f.lines() { let s = line.trim(); - if s.starts_with("### Note: this error code is no longer emitted by the compiler") { + if s.starts_with("#### Note: this error code is no longer emitted by the compiler") { return true; } if s.starts_with("```") {