Skip to content

Commit f80986b

Browse files
authored
Merge pull request #1710 from WaffleLapkin/pretty-rule-refs
move r[rules] to the left of the main body, using a grid
2 parents 293af99 + 1f12877 commit f80986b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+635
-710
lines changed

mdbook-spec/src/rules.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,10 @@ impl Spec {
105105
}
106106
format!(
107107
"<div class=\"rule\" id=\"r-{rule_id}\">\
108-
<a class=\"rule-link\" href=\"#r-{rule_id}\">[{rule_id}]</a>\
108+
<a class=\"rule-link\" href=\"#r-{rule_id}\" title=\"{rule_id}\"><span>[{rule_id_broken}]<span/></a>\
109109
{test_html}\
110-
</div>\n"
110+
</div>\n",
111+
rule_id_broken = rule_id.replace(".", "<wbr>."),
111112
)
112113
})
113114
.to_string()

src/attributes.md

+4-8
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,8 @@ fn some_unused_variables() {
105105
}
106106
```
107107

108-
## Meta Item Attribute Syntax
109-
110108
r[attributes.meta]
109+
## Meta Item Attribute Syntax
111110

112111
r[attributes.meta.intro]
113112
A "meta item" is the syntax used for the _Attr_ rule by most [built-in
@@ -188,9 +187,8 @@ _MetaListPaths_ | `allow(unused, clippy::inline_always)`
188187
_MetaListIdents_ | `macro_use(foo, bar)`
189188
_MetaListNameValueStr_ | `link(name = "CoreFoundation", kind = "framework")`
190189

191-
## Active and inert attributes
192-
193190
r[attributes.activity]
191+
## Active and inert attributes
194192

195193
r[attributes.activity.intro]
196194
An attribute is either active or inert. During attribute processing, *active
@@ -201,9 +199,8 @@ The [`cfg`] and [`cfg_attr`] attributes are active. The [`test`] attribute is
201199
inert when compiling for tests and active otherwise. [Attribute macros] are
202200
active. All other attributes are inert.
203201

204-
## Tool attributes
205-
206202
r[attributes.tool]
203+
## Tool attributes
207204

208205
r[attributes.tool.intro]
209206
The compiler may allow attributes for external tools where each tool resides
@@ -234,9 +231,8 @@ pub fn f() {}
234231
> Note: `rustc` currently recognizes the tools "clippy", "rustfmt", "diagnostic",
235232
> "miri" and "rust_analyzer".
236233
237-
## Built-in attributes index
238-
239234
r[attributes.builtin]
235+
## Built-in attributes index
240236

241237
The following is an index of all built-in attributes.
242238

src/attributes/codegen.md

+17-24
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
r[attributes.codegen]
12
# Code generation attributes
23

3-
r[attributes.codegen]
44

55
The following [attributes] are used for controlling code generation.
66

7-
## Optimization hints
8-
97
r[attributes.codegen.hint]
8+
## Optimization hints
109

1110
r[attributes.codegen.hint.cold-inline]
1211
The `cold` and `inline` [attributes] give suggestions to generate code in a
@@ -19,9 +18,8 @@ Both attributes can be used on [functions]. When applied to a function in a
1918
a trait implementation and not to all trait implementations. The attributes
2019
have no effect on a trait function without a body.
2120

22-
### The `inline` attribute
23-
2421
r[attributes.codegen.inline]
22+
### The `inline` attribute
2523

2624
r[attributes.codegen.inline.intro]
2725
The *`inline` [attribute]* suggests that a copy of the attributed function
@@ -44,24 +42,23 @@ There are three ways to use the inline attribute:
4442
> ***Note***: `#[inline]` in every form is a hint, with no *requirements*
4543
> on the language to place a copy of the attributed function in the caller.
4644
45+
r[attributes.codegen.cold]
4746
### The `cold` attribute
4847

49-
r[attributes.codegen.cold]
5048

5149
The *`cold` [attribute]* suggests that the attributed function is unlikely to
5250
be called.
5351

52+
r[attributes.codegen.no_builtins]
5453
## The `no_builtins` attribute
5554

56-
r[attributes.codegen.no_builtins]
5755

5856
The *`no_builtins` [attribute]* may be applied at the crate level to disable
5957
optimizing certain code patterns to invocations of library functions that are
6058
assumed to exist.
6159

62-
## The `target_feature` attribute
63-
6460
r[attributes.codegen.target_feature]
61+
## The `target_feature` attribute
6562

6663
r[attributes.codegen.target_feature.intro]
6764
The *`target_feature` [attribute]* may be applied to a function to
@@ -90,15 +87,15 @@ Functions marked with `target_feature` are not inlined into a context that
9087
does not support the given features. The `#[inline(always)]` attribute may not
9188
be used with a `target_feature` attribute.
9289

90+
r[attributes.codegen.target_feature.availability]
9391
### Available features
9492

95-
r[attributes.codegen.target_feature.availability]
9693

9794
The following is a list of the available feature names.
9895

96+
r[attributes.codegen.target_feature.x86]
9997
#### `x86` or `x86_64`
10098

101-
r[attributes.codegen.target_feature.x86]
10299

103100
Executing code with unsupported features is undefined behavior on this platform.
104101
Hence this platform requires that `#[target_feature]` is only applied to [`unsafe`
@@ -165,9 +162,9 @@ Feature | Implicitly Enables | Description
165162
[`xsaveopt`]: https://www.felixcloutier.com/x86/xsaveopt
166163
[`xsaves`]: https://www.felixcloutier.com/x86/xsaves
167164

165+
r[attributes.codegen.target_feature.aarch64]
168166
#### `aarch64`
169167

170-
r[attributes.codegen.target_feature.aarch64]
171168

172169
This platform requires that `#[target_feature]` is only applied to [`unsafe`
173170
functions][unsafe function].
@@ -230,9 +227,9 @@ Feature | Implicitly Enables | Feature Name
230227
`tme` | | FEAT_TME --- Transactional Memory Extension
231228
`vh` | | FEAT_VHE --- Virtualization Host Extensions
232229

230+
r[attributes.codegen.target_feature.riscv]
233231
#### `riscv32` or `riscv64`
234232

235-
r[attributes.codegen.target_feature.riscv]
236233

237234
This platform requires that `#[target_feature]` is only applied to [`unsafe`
238235
functions][unsafe function].
@@ -292,9 +289,9 @@ Feature | Implicitly Enables | Description
292289
[rv-zksh]: https://github.com/riscv/riscv-crypto/blob/e2dd7d98b7f34d477e38cb5fd7a3af4379525189/doc/scalar/riscv-crypto-scalar-zksh.adoc
293290
[rv-zkt]: https://github.com/riscv/riscv-crypto/blob/e2dd7d98b7f34d477e38cb5fd7a3af4379525189/doc/scalar/riscv-crypto-scalar-zkt.adoc
294291

292+
r[attributes.codegen.target_feature.wasm]
295293
#### `wasm32` or `wasm64`
296294

297-
r[attributes.codegen.target_feature.wasm]
298295

299296
`#[target_feature]` may be used with both safe and
300297
[`unsafe` functions][unsafe function] on Wasm platforms. It is impossible to
@@ -327,9 +324,8 @@ Feature | Implicitly Enables | Description
327324
[tail-call]: https://github.com/webassembly/tail-call
328325
[multivalue]: https://github.com/webassembly/multi-value
329326

330-
### Additional information
331-
332327
r[attributes.codegen.target_feature.info]
328+
### Additional information
333329

334330
r[attributes.codegen.target_feature.remark-cfg]
335331
See the [`target_feature` conditional compilation option] for selectively
@@ -346,9 +342,8 @@ in the standard library for runtime feature detection on these platforms.
346342
> may be enabled or disabled for an entire crate with the
347343
> [`-C target-feature`] flag.
348344
349-
## The `track_caller` attribute
350-
351345
r[attributes.codegen.track_caller]
346+
## The `track_caller` attribute
352347

353348
r[attributes.codegen.track_caller.allowed-positions]
354349
The `track_caller` attribute may be applied to any function with [`"Rust"` ABI][rust-abi]
@@ -364,9 +359,9 @@ implementations, otherwise undefined behavior results. When applied to a functio
364359
available to an `extern` block, the declaration in the `extern` block must also have the attribute,
365360
otherwise undefined behavior results.
366361

362+
r[attributes.codegen.track_caller.behavior]
367363
### Behavior
368364

369-
r[attributes.codegen.track_caller.behavior]
370365
Applying the attribute to a function `f` allows code within `f` to get a hint of the [`Location`] of
371366
the "topmost" tracked call that led to `f`'s invocation. At the point of observation, an
372367
implementation behaves as if it walks up the stack from `f`'s frame to find the nearest frame of an
@@ -444,9 +439,8 @@ fn calls_h() {
444439

445440
And so on.
446441

447-
### Limitations
448-
449442
r[attributes.codegen.track_caller.limits]
443+
### Limitations
450444

451445
r[attributes.codegen.track_caller.hint]
452446
This information is a hint and implementations are not required to preserve it.
@@ -480,9 +474,8 @@ trait object whose methods are attributed.
480474
[rust-abi]: ../items/external-blocks.md#abi
481475
[`Location`]: core::panic::Location
482476

483-
## The `instruction_set` attribute
484-
485477
r[attributes.codegen.instruction_set]
478+
## The `instruction_set` attribute
486479

487480
r[attributes.codegen.instruction_set.allowed-positions]
488481
The *`instruction_set` [attribute]* may be applied to a function to control which instruction set the function will be generated for.
@@ -498,9 +491,9 @@ It uses the [_MetaListPath_] syntax, and a path comprised of the architecture fa
498491
r[attributes.codegen.instruction_set.target-limits]
499492
It is a compilation error to use the `instruction_set` attribute on a target that does not support it.
500493

494+
r[attributes.codegen.instruction_set.arm]
501495
### On ARM
502496

503-
r[attributes.codegen.instruction_set.arm]
504497

505498
For the `ARMv4T` and `ARMv5te` architectures, the following are supported:
506499
* `arm::a32` --- Generate the function as A32 "ARM" code.

src/attributes/debugger.md

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
r[attributes.debugger]
12
# Debugger attributes
23

3-
r[attributes.debugger]
44

55
The following [attributes] are used for enhancing the debugging experience when using third-party debuggers like GDB or WinDbg.
66

7-
## The `debugger_visualizer` attribute
8-
97
r[attributes.debugger.debugger_visualizer]
8+
## The `debugger_visualizer` attribute
109

1110
r[attributes.debugger.debugger_visualizer.intro]
1211
The *`debugger_visualizer` attribute* can be used to embed a debugger visualizer file into the debug information.
@@ -15,9 +14,8 @@ This enables an improved debugger experience for displaying values in the debugg
1514
r[attributes.debugger.debugger_visualizer.syntax]
1615
It uses the [_MetaListNameValueStr_] syntax to specify its inputs, and must be specified as a crate attribute.
1716

18-
### Using `debugger_visualizer` with Natvis
19-
2017
r[attributes.debugger.debugger_visualizer.natvis]
18+
### Using `debugger_visualizer` with Natvis
2119

2220
r[attributes.debugger.debugger_visualizer.natvis.intro]
2321
Natvis is an XML-based framework for Microsoft debuggers (such as Visual Studio and WinDbg) that uses declarative rules to customize the display of types.
@@ -82,9 +80,8 @@ When viewed under WinDbg, the `fancy_rect` variable would be shown as follows:
8280
> LowerRight: (15.0, 10.0)
8381
```
8482

85-
### Using `debugger_visualizer` with GDB
86-
8783
r[attributes.debugger.debugger_visualizer.gdb]
84+
### Using `debugger_visualizer` with GDB
8885

8986
r[attributes.debugger.debugger_visualizer.gdb.pretty]
9087
GDB supports the use of a structured Python script, called a *pretty printer*, that describes how a type should be visualized in the debugger view.
@@ -156,9 +153,8 @@ When the crate's debug executable is passed into GDB[^rust-gdb], `print bob` wil
156153
[pretty printing documentation]: https://sourceware.org/gdb/onlinedocs/gdb/Pretty-Printing.html
157154
[_MetaListNameValueStr_]: ../attributes.md#meta-item-attribute-syntax
158155

159-
## The `collapse_debuginfo` attribute
160-
161156
r[attributes.debugger.collapse_debuginfo]
157+
## The `collapse_debuginfo` attribute
162158

163159
r[attributes.debugger.collapse_debuginfo.intro]
164160
The *`collapse_debuginfo` [attribute]* controls whether code locations from a macro definition are collapsed into a single location associated with the macro's call site,

src/attributes/derive.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# Derive
2-
31
r[attributes.derive]
2+
# Derive
43

54
r[attributes.derive.intro]
65
The *`derive` attribute* allows new [items] to be automatically generated for
@@ -36,9 +35,9 @@ impl<T: PartialEq> PartialEq for Foo<T> {
3635
r[attributes.derive.proc-macro]
3736
You can implement `derive` for your own traits through [procedural macros].
3837

38+
r[attributes.derive.automatically_derived]
3939
## The `automatically_derived` attribute
4040

41-
r[attributes.derive.automatically_derived]
4241
The *`automatically_derived` attribute* is automatically added to
4342
[implementations] created by the `derive` attribute for built-in traits. It
4443
has no direct effect, but it may be used by tools and diagnostic lints to

src/attributes/diagnostics.md

+10-18
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
# Diagnostic attributes
2-
31
r[attributes.diagnostics]
2+
# Diagnostic attributes
43

54
The following [attributes] are used for controlling or generating diagnostic
65
messages during compilation.
76

8-
## Lint check attributes
9-
107
r[attributes.diagnostics.lint]
8+
## Lint check attributes
119

1210
A lint check names a potentially undesirable coding pattern, such as
1311
unreachable code or omitted documentation.
@@ -104,9 +102,9 @@ pub mod m3 {
104102
> [command-line][rustc-lint-cli], and also supports [setting
105103
> caps][rustc-lint-caps] on the lints that are reported.
106104
105+
r[attributes.diagnostics.lint.reason]
107106
### Lint Reasons
108107

109-
r[attributes.diagnostics.lint.reason]
110108
All lint attributes support an additional `reason` parameter, to give context why
111109
a certain attribute was added. This reason will be displayed as part of the lint
112110
message if the lint is emitted at the defined level.
@@ -141,9 +139,8 @@ pub fn get_path() -> PathBuf {
141139
}
142140
```
143141

144-
### The `#[expect]` attribute
145-
146142
r[attributes.diagnostics.expect]
143+
### The `#[expect]` attribute
147144

148145
r[attributes.diagnostics.expect.intro]
149146
The `#[expect(C)]` attribute creates a lint expectation for lint `C`. The
@@ -228,9 +225,9 @@ pub fn another_example() {
228225
> Note: The behavior of `#[expect(unfulfilled_lint_expectations)]` is currently
229226
> defined to always generate the `unfulfilled_lint_expectations` lint.
230227
228+
r[attributes.diagnostics.lint.group]
231229
### Lint groups
232230

233-
r[attributes.diagnostics.lint.group]
234231
Lints may be organized into named groups so that the level of related lints
235232
can be adjusted together. Using a named group is equivalent to listing out the
236233
lints within that group.
@@ -269,9 +266,8 @@ fn example_err() {
269266
}
270267
```
271268

272-
### Tool lint attributes
273-
274269
r[attributes.diagnostics.lint.tool]
270+
### Tool lint attributes
275271

276272
r[attributes.diagnostics.lint.tool.intro]
277273
Tool lints allows using scoped lints, to `allow`, `warn`, `deny` or `forbid`
@@ -303,9 +299,8 @@ fn foo() {
303299

304300
> Note: `rustc` currently recognizes the tool lints for "[clippy]" and "[rustdoc]".
305301
306-
## The `deprecated` attribute
307-
308302
r[attributes.diagnostics.deprecated]
303+
## The `deprecated` attribute
309304

310305
r[attributes.diagnostics.deprecated.intro]
311306
The *`deprecated` attribute* marks an item as deprecated. `rustc` will issue
@@ -350,9 +345,8 @@ The [RFC][1270-deprecation.md] contains motivations and more details.
350345

351346
[1270-deprecation.md]: https://github.com/rust-lang/rfcs/blob/master/text/1270-deprecation.md
352347

353-
## The `must_use` attribute
354-
355348
r[attributes.diagnostics.must_use]
349+
## The `must_use` attribute
356350

357351
r[attributes.diagnostics.must_use.intro]
358352
The *`must_use` attribute* is used to issue a diagnostic warning when a value
@@ -469,9 +463,8 @@ When used on a function in a trait implementation, the attribute does nothing.
469463
> let _ = five();
470464
> ```
471465
472-
## The `diagnostic` tool attribute namespace
473-
474466
r[attributes.diagnostic.namespace]
467+
## The `diagnostic` tool attribute namespace
475468
476469
r[attributes.diagnostic.namespace.intro]
477470
The `#[diagnostic]` attribute namespace is a home for attributes to influence compile-time error messages.
@@ -482,9 +475,8 @@ Unknown attributes in this namespace are accepted, though they may emit warnings
482475
Additionally, invalid inputs to known attributes will typically be a warning (see the attribute definitions for details).
483476
This is meant to allow adding or discarding attributes and changing inputs in the future to allow changes without the need to keep the non-meaningful attributes or options working.
484477
485-
### The `diagnostic::on_unimplemented` attribute
486-
487478
r[attributes.diagnostic.on_unimplemented]
479+
### The `diagnostic::on_unimplemented` attribute
488480
489481
r[attributes.diagnostic.on_unimplemented.intro]
490482
The `#[diagnostic::on_unimplemented]` attribute is a hint to the compiler to supplement the error message that would normally be generated in scenarios where a trait is required but not implemented on a type.

0 commit comments

Comments
 (0)