Skip to content

Commit 68f5c84

Browse files
committed
Markdown edits for diagnostic errors.
1 parent 31e3cb7 commit 68f5c84

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

src/librustc/diagnostics.rs

+26-22
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ An example of an empty type is `enum Empty { }`.
3737
E0003: r##"
3838
Not-a-Number (NaN) values cannot be compared for equality and hence can never
3939
match the input to a match expression. To match against NaN values, you should
40-
instead use the `is_nan` method in a guard, as in: x if x.is_nan() => ...
40+
instead use the `is_nan` method in a guard, as in: `x if x.is_nan() => ...`
4141
"##,
4242

4343
E0004: r##"
@@ -71,7 +71,7 @@ failure.
7171
E0007: r##"
7272
This error indicates that the bindings in a match arm would require a value to
7373
be moved into more than one location, thus violating unique ownership. Code like
74-
the following is invalid as it requires the entire Option<String> to be moved
74+
the following is invalid as it requires the entire `Option<String>` to be moved
7575
into a variable called `op_string` while simultaneously requiring the inner
7676
String to be moved into a variable called `s`.
7777
@@ -99,10 +99,10 @@ match Some("hi".to_string()) {
9999
}
100100
```
101101
102-
The variable `s` has type String, and its use in the guard is as a variable of
103-
type String. The guard code effectively executes in a separate scope to the body
104-
of the arm, so the value would be moved into this anonymous scope and therefore
105-
become unavailable in the body of the arm. Although this example seems
102+
The variable `s` has type `String`, and its use in the guard is as a variable of
103+
type `String`. The guard code effectively executes in a separate scope to the
104+
body of the arm, so the value would be moved into this anonymous scope and
105+
therefore become unavailable in the body of the arm. Although this example seems
106106
innocuous, the problem is most clear when considering functions that take their
107107
argument by value.
108108
@@ -140,7 +140,8 @@ match x {
140140
```
141141
142142
You have two solutions:
143-
1. Bind the pattern's values the same way:
143+
144+
Solution #1: Bind the pattern's values the same way.
144145
145146
```
146147
struct X { x: (), }
@@ -153,8 +154,9 @@ match x {
153154
}
154155
```
155156
156-
2. Implement the `Copy` trait for the X structure (however, please
157-
keep in mind that the first solution should be preferred!):
157+
Solution #2: Implement the `Copy` trait for the `X` structure.
158+
159+
However, please keep in mind that the first solution should be preferred.
158160
159161
```
160162
#[derive(Clone, Copy)]
@@ -258,11 +260,13 @@ functions via FFI or marked as unsafe, is potentially dangerous and disallowed
258260
by safety checks. As such, those safety checks can be temporarily relaxed by
259261
wrapping the unsafe instructions inside an `unsafe` block. For instance:
260262
263+
```
261264
unsafe fn f() { return; }
262265
263266
fn main() {
264267
unsafe { f(); }
265268
}
269+
```
266270
267271
See also http://doc.rust-lang.org/book/unsafe.html
268272
"##,
@@ -313,8 +317,8 @@ it around as usual.
313317

314318
E0162: r##"
315319
An if-let pattern attempts to match the pattern, and enters the body if the
316-
match was succesful. If the match is irrefutable (when it cannot fail to match),
317-
use a regular `let`-binding instead. For instance:
320+
match was successful. If the match is irrefutable (when it cannot fail to
321+
match), use a regular `let`-binding instead. For instance:
318322
319323
```
320324
struct Irrefutable(i32);
@@ -334,8 +338,8 @@ foo(x);
334338

335339
E0165: r##"
336340
A while-let pattern attempts to match the pattern, and enters the body if the
337-
match was succesful. If the match is irrefutable (when it cannot fail to match),
338-
use a regular `let`-binding inside a `loop` instead. For instance:
341+
match was successful. If the match is irrefutable (when it cannot fail to
342+
match), use a regular `let`-binding inside a `loop` instead. For instance:
339343
340344
```
341345
struct Irrefutable(i32);
@@ -374,7 +378,7 @@ match m {
374378
```
375379
376380
If you don't qualify the names, the code will bind new variables named "GET" and
377-
"POST" instead. This behavior is likely not what you want, so rustc warns when
381+
"POST" instead. This behavior is likely not what you want, so `rustc` warns when
378382
that happens.
379383
380384
Qualified names are good practice, and most code works well with them. But if
@@ -403,16 +407,16 @@ const Y: u32 = X;
403407
"##,
404408

405409
E0267: r##"
406-
This error indicates the use of loop keyword (break or continue) inside a
407-
closure but outside of any loop. Break and continue can be used as normal
408-
inside closures as long as they are also contained within a loop. To halt the
409-
execution of a closure you should instead use a return statement.
410+
This error indicates the use of a loop keyword (`break` or `continue`) inside a
411+
closure but outside of any loop. Break and continue can be used as normal inside
412+
closures as long as they are also contained within a loop. To halt the execution
413+
of a closure you should instead use a return statement.
410414
"##,
411415

412416
E0268: r##"
413-
This error indicates the use of loop keyword (break or continue) outside of a
414-
loop. Without a loop to break out of or continue in, no sensible action can be
415-
taken.
417+
This error indicates the use of a loop keyword (`break` or `continue`) outside
418+
of a loop. Without a loop to break out of or continue in, no sensible action can
419+
be taken.
416420
"##,
417421

418422
E0296: r##"
@@ -507,7 +511,7 @@ match Some("hi".to_string()) {
507511
}
508512
```
509513
510-
The `op_string_ref` binding has type &Option<&String> in both cases.
514+
The `op_string_ref` binding has type `&Option<&String>` in both cases.
511515
512516
See also https://github.com/rust-lang/rust/issues/14587
513517
"##,

0 commit comments

Comments
 (0)