Skip to content

Commit f8e76ee

Browse files
committed
Audit code blocks.
1 parent 1ad8c2e commit f8e76ee

28 files changed

+193
-95
lines changed

src/abi.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ The *`link_section` attribute* specifies the section of the object file that a
6868
[function] or [static]'s content will be placed into. It uses the
6969
[_MetaNameValueStr_] syntax to specify the section name.
7070

71-
```rust,ignore
71+
<!-- no_run: don't link. The format of the section name is platform-specific. -->
72+
```rust,no_run
7273
#[no_mangle]
7374
#[link_section = ".example_section"]
7475
pub static VAR1: u32 = 1;
@@ -80,7 +81,7 @@ The *`export_name` attribute* specifies the name of the symbol that will be
8081
exported on a [function] or [static]. It uses the [_MetaNameValueStr_] syntax
8182
to specify the symbol name.
8283

83-
```rust,ignore
84+
```rust
8485
#[export_name = "exported_symbol_name"]
8586
pub fn name_in_rust() { }
8687
```

src/attributes/codegen.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ enable code generation of that function for specific platform architecture
4949
features. It uses the [_MetaListNameValueStr_] syntax with a single key of
5050
`enable` whose value is a string of comma-separated feature names to enable.
5151

52-
```rust,ignore
52+
```rust
53+
# #[cfg(target_feature = "avx2")]
5354
#[target_feature(enable = "avx2")]
5455
unsafe fn foo_avx2() {}
5556
```

src/attributes/type_system.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ Non-exhaustive types cannot be constructed outside of the defining crate:
6666
with a [_StructExpression_] \(including with [functional update syntax]).
6767
- [`enum`][enum] instances can be constructed in an [_EnumerationVariantExpression_].
6868

69-
```rust,ignore (requires multiple crates)
69+
<!-- ignore: requires external crates -->
70+
```rust,ignore
7071
// `Config`, `Error`, and `Message` are types defined in an upstream crate that have been
7172
// annotated as `#[non_exhaustive]`.
7273
use upstream::{Config, Error, Message};
@@ -99,7 +100,8 @@ There are limitations when matching on non-exhaustive types outside of the defin
99100
- When pattern matching on a non-exhaustive [`enum`][enum], matching on a variant does not
100101
contribute towards the exhaustiveness of the arms.
101102

102-
```rust, ignore (requires multiple crates)
103+
<!-- ignore: requires external crates -->
104+
```rust, ignore
103105
// `Config`, `Error`, and `Message` are types defined in an upstream crate that have been
104106
// annotated as `#[non_exhaustive]`.
105107
use upstream::{Config, Error, Message};

src/conditional-compilation.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ When the configuration predicate is true, this attribute expands out to the
264264
attributes listed after the predicate. For example, the following module will
265265
either be found at `linux.rs` or `windows.rs` based on the target.
266266

267+
<!-- ignore: `mod` needs multiple files -->
267268
```rust,ignore
268269
#[cfg_attr(linux, path = "linux.rs")]
269270
#[cfg_attr(windows, path = "windows.rs")]
@@ -273,6 +274,7 @@ mod os;
273274
Zero, one, or more attributes may be listed. Multiple attributes will each be
274275
expanded into separate attributes. For example:
275276

277+
<!-- ignore: fake attributes -->
276278
```rust,ignore
277279
#[cfg_attr(feature = "magic", sparkles, crackles)]
278280
fn bewitched() {}

src/crates-and-source-files.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ that apply to the containing module, most of which influence the behavior of
5353
the compiler. The anonymous crate module can have additional attributes that
5454
apply to the crate as a whole.
5555

56-
```rust,no_run
56+
```rust
5757
// Specify the crate name.
5858
#![crate_name = "projx"]
5959

@@ -75,7 +75,8 @@ essentially to treat the source file as an executable script. The shebang
7575
can only occur at the beginning of the file (but after the optional
7676
_UTF8BOM_). It is ignored by the compiler. For example:
7777

78-
```text,ignore
78+
<!-- ignore: tests don't like shebang -->
79+
```rust,ignore
7980
#!/usr/bin/env rustx
8081
8182
fn main() {
@@ -136,7 +137,7 @@ other object being linked to defines `main`.
136137
The *`crate_name` [attribute]* may be applied at the crate level to specify the
137138
name of the crate with the [_MetaNameValueStr_] syntax.
138139

139-
```rust,ignore
140+
```rust
140141
#![crate_name = "mycrate"]
141142
```
142143

src/expressions/await-expr.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ context, there must be some task context available.
5151
Effectively, an `<expr>.await` expression is roughly
5252
equivalent to the following (this desugaring is not normative):
5353

54+
<!-- ignore: example expansion -->
5455
```rust,ignore
5556
match /* <expr> */ {
5657
mut pinned => loop {

src/expressions/field-expr.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ A _field expression_ consists of an expression followed by a single dot and an
1010
field of a [struct] or [union]. To call a function stored in a struct,
1111
parentheses are needed around the field expression.
1212

13+
<!-- ignore: needs lots of support code -->
1314
```rust,ignore
1415
mystruct.myfield;
1516
foo().x;

src/expressions/if-expr.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ assert_eq!(a, 3);
9797

9898
An `if let` expression is equivalent to a [`match` expression] as follows:
9999

100+
<!-- ignore: expansion example -->
100101
```rust,ignore
101102
if let PATS = EXPR {
102103
/* body */
@@ -107,6 +108,7 @@ if let PATS = EXPR {
107108

108109
is equivalent to
109110

111+
<!-- ignore: expansion example -->
110112
```rust,ignore
111113
match EXPR {
112114
PATS => { /* body */ },
@@ -135,6 +137,7 @@ of the language (the implementation of if-let chains - see [eRFC 2947][_eRFCIfLe
135137
When lazy boolean operator expression is desired, this can be achieved
136138
by using parenthesis as below:
137139

140+
<!-- ignore: psuedo code -->
138141
```rust,ignore
139142
// Before...
140143
if let PAT = EXPR && EXPR { .. }

src/expressions/loop-expr.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ while let _ = 5 {
9393
A `while let` loop is equivalent to a `loop` expression containing a [`match`
9494
expression] as follows.
9595

96+
<!-- ignore: expansion example -->
9697
```rust,ignore
9798
'label: while let PATS = EXPR {
9899
/* loop body */
@@ -101,6 +102,7 @@ expression] as follows.
101102

102103
is equivalent to
103104

105+
<!-- ignore: expansion example -->
104106
```rust,ignore
105107
'label: loop {
106108
match EXPR {
@@ -156,6 +158,7 @@ assert_eq!(sum, 55);
156158

157159
A for loop is equivalent to the following block expression.
158160

161+
<!-- ignore: expansion example -->
159162
```rust,ignore
160163
'label: for PATTERN in iter_expr {
161164
/* loop body */
@@ -164,6 +167,7 @@ A for loop is equivalent to the following block expression.
164167

165168
is equivalent to
166169

170+
<!-- ignore: expansion example -->
167171
```rust,ignore
168172
{
169173
let result = match IntoIterator::into_iter(iter_expr) {

src/expressions/operator-expr.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,9 @@ functions and macros in the standard library can then use that assumption
260260
above, these operators implicitly take shared borrows of their operands,
261261
evaluating them in [place expression context][place expression]:
262262

263-
```rust,ignore
263+
```rust
264+
# let a = 1;
265+
# let b = 1;
264266
a == b;
265267
// is equivalent to
266268
::std::cmp::PartialEq::eq(&a, &b);

0 commit comments

Comments
 (0)