Skip to content

Commit 9a4401f

Browse files
michaelsproulbrson
authored andcommitted
Add some extended errors.
1 parent 9f59f7e commit 9a4401f

File tree

2 files changed

+40
-6
lines changed

2 files changed

+40
-6
lines changed

src/librustc/diagnostics.rs

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,49 @@
1010

1111
#![allow(non_snake_case)]
1212

13-
register_diagnostic! { E0001, r##"
13+
register_long_diagnostics! {
14+
E0001: r##"
1415
This error suggests that the expression arm corresponding to the noted pattern
1516
will never be reached as for all possible values of the expression being matched,
1617
one of the preceeding patterns will match.
1718
1819
This means that perhaps some of the preceeding patterns are too general, this
1920
one is too specific or the ordering is incorrect.
20-
"## }
21+
"##,
22+
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+
"##,
28+
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+
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".
38+
"##,
39+
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.
45+
"##,
46+
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.
51+
"##
52+
}
2153

2254
register_diagnostics! {
2355
E0002,
24-
E0003,
25-
E0004,
26-
E0005,
27-
E0006,
2856
E0007,
2957
E0008,
3058
E0009,

src/libsyntax/diagnostics/macros.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,9 @@ macro_rules! register_diagnostics {
5959
)
6060
}
6161

62+
#[macro_export]
63+
macro_rules! register_long_diagnostics {
64+
($($code:tt: $description:tt),*) => (
65+
$(register_diagnostic! { $code, $description })*
66+
)
67+
}

0 commit comments

Comments
 (0)