Skip to content

Commit e510c0c

Browse files
authored
Merge pull request rust-lang#6 from matthewjasper/highlight-fix
Fix code block annotations
2 parents 717b942 + 3063893 commit e510c0c

8 files changed

+61
-61
lines changed

src/attributes.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ apply to the item that follows the attribute.
1717

1818
An example of attributes:
1919

20-
```{.rust}
20+
```rust
2121
// General metadata applied to the enclosing module or crate.
2222
#![crate_type = "lib"]
2323

@@ -164,8 +164,8 @@ macro scope.
164164

165165
## Miscellaneous attributes
166166

167-
- `deprecated` - mark the item as deprecated; the full attribute is
168-
`#[deprecated(since = "crate version", note = "...")`, where both arguments
167+
- `deprecated` - mark the item as deprecated; the full attribute is
168+
`#[deprecated(since = "crate version", note = "...")`, where both arguments
169169
are optional.
170170
- `export_name` - on statics and functions, this determines the name of the
171171
exported symbol.
@@ -218,7 +218,7 @@ Configuration options are either provided by the compiler or passed in on the
218218
command line using `--cfg` (e.g. `rustc main.rs --cfg foo --cfg 'bar="baz"'`).
219219
Rust code then checks for their presence using the `#[cfg(...)]` attribute:
220220

221-
```
221+
```rust
222222
// The function is only included in the build when compiling for macOS
223223
#[cfg(target_os = "macos")]
224224
fn macos_only() {
@@ -320,7 +320,7 @@ along with their default settings. [Compiler
320320
plugins](../unstable-book/plugin.html#lint-plugins) can provide additional
321321
lint checks.
322322

323-
```{.ignore}
323+
```rust,ignore
324324
pub mod m1 {
325325
// Missing documentation is ignored here
326326
#[allow(missing_docs)]
@@ -339,7 +339,7 @@ pub mod m1 {
339339
This example shows how one can use `allow` and `warn` to toggle a particular
340340
check on and off:
341341

342-
```{.ignore}
342+
```rust
343343
#[warn(missing_docs)]
344344
pub mod m2{
345345
#[allow(missing_docs)]
@@ -361,7 +361,7 @@ pub mod m2{
361361
This example shows how one can use `forbid` to disallow uses of `allow` for
362362
that lint check:
363363

364-
```{.ignore}
364+
```rust,ignore
365365
#[forbid(missing_docs)]
366366
pub mod m3 {
367367
// Attempting to toggle warning signals an error here
@@ -379,7 +379,7 @@ operations have to be easy for the compiler to find. The `lang` attribute
379379
makes it possible to declare these operations. For example, the `str` module
380380
in the Rust standard library defines the string equality function:
381381

382-
```{.ignore}
382+
```rust,ignore
383383
#[lang = "str_eq"]
384384
pub fn eq_slice(a: &str, b: &str) -> bool {
385385
// details elided
@@ -419,7 +419,7 @@ for data structures. For example, the following will create an `impl` for the
419419
`PartialEq` and `Clone` traits for `Foo`, the type parameter `T` will be given
420420
the `PartialEq` or `Clone` constraints for the appropriate `impl`:
421421

422-
```
422+
```rust
423423
#[derive(PartialEq, Clone)]
424424
struct Foo<T> {
425425
a: i32,
@@ -429,7 +429,7 @@ struct Foo<T> {
429429

430430
The generated `impl` for `PartialEq` is equivalent to
431431

432-
```
432+
```rust
433433
# struct Foo<T> { a: i32, b: T }
434434
impl<T: PartialEq> PartialEq for Foo<T> {
435435
fn eq(&self, other: &Foo<T>) -> bool {
@@ -454,7 +454,7 @@ considered a full-fledged language feature.
454454

455455
For this reason, Rust recognizes a special crate-level attribute of the form:
456456

457-
```{.ignore}
457+
```rust,ignore
458458
#![feature(feature1, feature2, feature3)]
459459
```
460460

src/expressions.md

+31-31
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ A _literal expression_ consists of one of the [literal](tokens.html#literals) fo
8989
described earlier. It directly describes a number, character, string, boolean
9090
value, or the unit value.
9191

92-
```text
92+
```rust
9393
(); // unit type
9494
"hello"; // string type
9595
'5'; // character type
@@ -108,15 +108,15 @@ Tuples are written by enclosing zero or more comma-separated expressions in
108108
parentheses. They are used to create [tuple-typed](types.html#tuple-types)
109109
values.
110110

111-
```{.tuple}
111+
```rust
112112
(0.0, 4.5);
113113
("a", 4usize, true);
114114
```
115115

116116
You can disambiguate a single-element tuple from a value in parentheses with a
117117
comma:
118118

119-
```
119+
```rust
120120
(0,); // single-element tuple
121121
(0); // zero in parentheses
122122
```
@@ -141,7 +141,7 @@ A _unit-like struct expression_ consists only of the [path](paths.html) of a
141141

142142
The following are examples of struct expressions:
143143

144-
```
144+
```rust
145145
# struct Point { x: f64, y: f64 }
146146
# struct NothingInMe { }
147147
# struct TuplePoint(f64, f64);
@@ -166,7 +166,7 @@ the same type as the base expression) with the given values for the fields that
166166
were explicitly specified and the values in the base expression for all other
167167
fields.
168168

169-
```
169+
```rust
170170
# struct Point3d { x: i32, y: i32, z: i32 }
171171
let base = Point3d {x: 1, y: 2, z: 3};
172172
Point3d {y: 0, z: 10, .. base};
@@ -180,7 +180,7 @@ This allows a compact syntax with less duplication.
180180

181181
Example:
182182

183-
```
183+
```rust
184184
# struct Point3d { x: i32, y: i32, z: i32 }
185185
# let x = 0;
186186
# let y_value = 0;
@@ -199,13 +199,13 @@ the block itself.
199199
A block will execute each statement sequentially, and then execute the
200200
expression (if given). If the block ends in a statement, its value is `()`:
201201

202-
```
202+
```rust
203203
let x: () = { println!("Hello."); };
204204
```
205205

206206
If it ends in an expression, its value and type are that of the expression:
207207

208-
```
208+
```rust
209209
let x: i32 = { println!("Hello."); 5 };
210210

211211
assert_eq!(5, x);
@@ -227,7 +227,7 @@ identifier, when not immediately followed by a parenthesized expression-list
227227
(the latter is a [method call expression](#method-call-expressions)). A field
228228
expression denotes a field of a [struct](types.html#struct-types).
229229

230-
```{.ignore .field}
230+
```rust,ignore
231231
mystruct.myfield;
232232
foo().x;
233233
(Struct {a: 10, b: 20}).a;
@@ -252,7 +252,7 @@ In the `[expr ';' expr]` form, the expression after the `';'` must be a
252252
constant expression that can be evaluated at compile time, such as a
253253
[literal](tokens.html#literals) or a [static item](items.html#static-items).
254254

255-
```
255+
```rust
256256
[1, 2, 3, 4];
257257
["a", "b", "c", "d"];
258258
[0; 128]; // array with 128 zeros
@@ -271,7 +271,7 @@ bounds-checked at compile-time for constant arrays being accessed with a
271271
constant index value. Otherwise a check will be performed at run-time that
272272
will put the thread in a _panicked state_ if it fails.
273273

274-
```{should-fail}
274+
```rust,should_panic
275275
([1, 2, 3, 4])[0];
276276
277277
let x = (["a", "b"])[10]; // compiler error: const index-expr is out of bounds
@@ -292,7 +292,7 @@ autoderefs to more.
292292

293293
The `..` operator will construct an object of one of the `std::ops::Range` variants.
294294

295-
```
295+
```rust
296296
1..2; // std::ops::Range
297297
3..; // std::ops::RangeFrom
298298
..4; // std::ops::RangeTo
@@ -301,7 +301,7 @@ The `..` operator will construct an object of one of the `std::ops::Range` varia
301301

302302
The following expressions are equivalent.
303303

304-
```
304+
```rust
305305
let x = std::ops::Range {start: 0, end: 10};
306306
let y = 0..10;
307307

@@ -311,15 +311,15 @@ assert_eq!(x, y);
311311
Similarly, the `...` operator will construct an object of one of the
312312
`std::ops::RangeInclusive` variants.
313313

314-
```
314+
```rust
315315
# #![feature(inclusive_range_syntax)]
316316
1...2; // std::ops::RangeInclusive
317317
...4; // std::ops::RangeToInclusive
318318
```
319319

320320
The following expressions are equivalent.
321321

322-
```
322+
```rust
323323
# #![feature(inclusive_range_syntax, inclusive_range)]
324324
let x = std::ops::RangeInclusive::NonEmpty {start: 0, end: 10};
325325
let y = 0...10;
@@ -464,7 +464,7 @@ on the right-hand side.
464464

465465
An example of an `as` expression:
466466

467-
```
467+
```rust
468468
# fn sum(values: &[f64]) -> f64 { 0.0 }
469469
# fn len(values: &[f64]) -> i32 { 0 }
470470

@@ -493,7 +493,7 @@ Evaluating an assignment expression [either copies or
493493
moves](#moved-and-copied-types) its right-hand operand to its left-hand
494494
operand.
495495

496-
```
496+
```rust
497497
# let mut x = 0;
498498
# let y = 0;
499499
x = y;
@@ -512,7 +512,7 @@ Any such expression always has the [`unit`](types.html#tuple-types) type.
512512
The precedence of Rust binary operators is ordered as follows, going from
513513
strong to weak:
514514

515-
```{.text .precedence}
515+
```text
516516
as :
517517
* / %
518518
+ -
@@ -540,7 +540,7 @@ within an expression.
540540

541541
An example of a parenthesized expression:
542542

543-
```
543+
```rust
544544
let x: i32 = (2 + 3) * 4;
545545
```
546546

@@ -553,7 +553,7 @@ eventually returns, then the expression completes.
553553

554554
Some examples of call expressions:
555555

556-
```
556+
```rust
557557
# fn add(x: i32, y: i32) -> i32 { 0 }
558558

559559
let x: i32 = add(1i32, 2i32);
@@ -592,7 +592,7 @@ In this example, we define a function `ten_times` that takes a higher-order
592592
function argument, and we then call it with a lambda expression as an argument,
593593
followed by a lambda expression that moves values from its environment.
594594

595-
```
595+
```rust
596596
fn ten_times<F>(f: F) where F: Fn(i32) {
597597
for index in 0..10 {
598598
f(index);
@@ -646,7 +646,7 @@ conditional expression evaluates to `false`, the `while` expression completes.
646646

647647
An example:
648648

649-
```
649+
```rust
650650
let mut i = 0;
651651

652652
while i < 10 {
@@ -667,7 +667,7 @@ by an implementation of `std::iter::IntoIterator`.
667667

668668
An example of a `for` loop over the contents of an array:
669669

670-
```
670+
```rust
671671
# type Foo = i32;
672672
# fn bar(f: &Foo) { }
673673
# let a = 0;
@@ -683,7 +683,7 @@ for e in v {
683683

684684
An example of a for loop over a series of integers:
685685

686-
```
686+
```rust
687687
# fn bar(b:usize) { }
688688
for i in 0..256 {
689689
bar(i);
@@ -738,7 +738,7 @@ the inside of the match.
738738

739739
An example of a `match` expression:
740740

741-
```
741+
```rust
742742
let x = 1;
743743

744744
match x {
@@ -759,7 +759,7 @@ bind to a reference by using the `ref` keyword, or to a mutable reference using
759759
Subpatterns can also be bound to variables by the use of the syntax `variable @
760760
subpattern`. For example:
761761

762-
```
762+
```rust
763763
let x = 1;
764764

765765
match x {
@@ -772,7 +772,7 @@ Patterns can also dereference pointers by using the `&`, `&mut` and `box`
772772
symbols, as appropriate. For example, these two matches on `x: &i32` are
773773
equivalent:
774774

775-
```
775+
```rust
776776
# let x = &3;
777777
let y = match *x { 0 => "zero", _ => "some" };
778778
let z = match x { &0 => "zero", _ => "some" };
@@ -783,7 +783,7 @@ assert_eq!(y, z);
783783
Multiple match patterns may be joined with the `|` operator. A range of values
784784
may be specified with `...`. For example:
785785

786-
```
786+
```rust
787787
# let x = 2;
788788

789789
let message = match x {
@@ -802,7 +802,7 @@ criteria for matching a case. Pattern guards appear after the pattern and
802802
consist of a bool-typed expression following the `if` keyword. A pattern guard
803803
may refer to the variables bound within the pattern they follow.
804804

805-
```
805+
```rust
806806
# let maybe_digit = Some(0);
807807
# fn process_digit(i: i32) { }
808808
# fn process_other(i: i32) { }
@@ -822,7 +822,7 @@ pattern. If the value of the expression on the right hand side of the `let`
822822
statement matches the pattern, the corresponding block will execute, otherwise
823823
flow proceeds to the first `else` block that follows.
824824

825-
```
825+
```rust
826826
let dish = ("Ham", "Eggs");
827827

828828
// this body will be skipped because the pattern is refuted
@@ -853,7 +853,7 @@ transfers control to the caller frame.
853853

854854
An example of a `return` expression:
855855

856-
```
856+
```rust
857857
fn max(a: i32, b: i32) -> i32 {
858858
if a > b {
859859
return a;

src/paths.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ crates; an item's canonical path merely identifies it within the crate.
1414

1515
Two examples of simple paths consisting of only identifier components:
1616

17-
```{.ignore}
17+
```rust,ignore
1818
x;
1919
x::y::z;
2020
```

src/subtyping.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ would be due to type equality.
99
Consider the following example: string literals always have `'static`
1010
lifetime. Nevertheless, we can assign `s` to `t`:
1111

12-
```
12+
```rust
1313
fn bar<'a>() {
1414
let s: &'static str = "hi";
1515
let t: &'a str = s;

0 commit comments

Comments
 (0)