Skip to content

Commit 19e9828

Browse files
committed
Fix printing of extended errors.
1 parent 2615106 commit 19e9828

File tree

2 files changed

+36
-28
lines changed

2 files changed

+36
-28
lines changed

src/librustc/diagnostics.rs

+34-27
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,52 @@
1010

1111
#![allow(non_snake_case)]
1212

13+
// Error messages for EXXXX errors.
14+
// Each message should start and end with a new line, and be wrapped to 80 characters.
15+
// In vim you can `:set tw=80` and use `gq` to wrap paragraphs. Use `:set tw=0` to disable.
1316
register_long_diagnostics! {
14-
E0001: r##"
15-
This error suggests that the expression arm corresponding to the noted pattern
16-
will never be reached as for all possible values of the expression being matched,
17-
one of the preceding patterns will match.
1817

19-
This means that perhaps some of the preceding patterns are too general, this
20-
one is too specific or the ordering is incorrect.
18+
E0001: r##"
19+
This error suggests that the expression arm corresponding to the noted pattern
20+
will never be reached as for all possible values of the expression being
21+
matched, one of the preceding patterns will match.
22+
23+
This means that perhaps some of the preceding patterns are too general, this one
24+
is too specific or the ordering is incorrect.
2125
"##,
2226

23-
E0003: r##"
24-
Not-a-Number (NaN) values can not be compared for equality and hence can never match
25-
the input to a match expression. To match against NaN values, you should instead use
26-
the `is_nan` method in a guard, as in: x if x.is_nan() => ...
27+
E0003: r##"
28+
Not-a-Number (NaN) values can not be compared for equality and hence can never
29+
match the input to a match expression. To match against NaN values, you should
30+
instead use the `is_nan` method in a guard, as in: x if x.is_nan() => ...
2731
"##,
2832

29-
E0004: r##"
30-
This error indicates that the compiler can not guarantee a matching pattern for one
31-
or more possible inputs to a match expression. Guaranteed matches are required in order
32-
to assign values to match expressions, or alternatively, determine the flow of execution.
33+
E0004: r##"
34+
This error indicates that the compiler can not guarantee a matching pattern for
35+
one or more possible inputs to a match expression. Guaranteed matches are
36+
required in order to assign values to match expressions, or alternatively,
37+
determine the flow of execution.
3338
34-
If you encounter this error you must alter your patterns so that every possible value of
35-
the input type is matched. For types with a small number of variants (like enums) you
36-
should probably cover all cases explicitly. Alternatively, the underscore `_` wildcard
37-
pattern can be added after all other patterns to match "anything else".
39+
If you encounter this error you must alter your patterns so that every possible
40+
value of the input type is matched. For types with a small number of variants
41+
(like enums) you should probably cover all cases explicitly. Alternatively, the
42+
underscore `_` wildcard pattern can be added after all other patterns to match
43+
"anything else".
3844
"##,
3945

40-
// FIXME: Remove duplication here?
41-
E0005: r##"
42-
Patterns used to bind names must be irrefutable, that is, they must guarantee that a
43-
name will be extracted in all cases. If you encounter this error you probably need
44-
to use a `match` or `if let` to deal with the possibility of failure.
46+
// FIXME: Remove duplication here?
47+
E0005: r##"
48+
Patterns used to bind names must be irrefutable, that is, they must guarantee that a
49+
name will be extracted in all cases. If you encounter this error you probably need
50+
to use a `match` or `if let` to deal with the possibility of failure.
4551
"##,
4652

47-
E0006: r##"
48-
Patterns used to bind names must be irrefutable, that is, they must guarantee that a
49-
name will be extracted in all cases. If you encounter this error you probably need
50-
to use a `match` or `if let` to deal with the possibility of failure.
53+
E0006: r##"
54+
Patterns used to bind names must be irrefutable, that is, they must guarantee that a
55+
name will be extracted in all cases. If you encounter this error you probably need
56+
to use a `match` or `if let` to deal with the possibility of failure.
5157
"##
58+
5259
}
5360

5461
register_diagnostics! {

src/librustc_driver/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,8 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
277277
Some(ref code) => {
278278
match descriptions.find_description(&code[..]) {
279279
Some(ref description) => {
280-
println!("{}", description);
280+
// Slice off the leading newline and print.
281+
print!("{}", &description[1..]);
281282
}
282283
None => {
283284
early_error(&format!("no extended information for {}", code));

0 commit comments

Comments
 (0)