added error handle for error code > 9999 · rust-lang/rust@3c1c072 (original) (raw)
11 files changed
lines changed
Original file line number |
Diff line number |
Diff line change |
@@ -463,6 +463,7 @@ fn handle_explain(early_dcx: &EarlyDiagCtxt, registry: Registry, code: &str, col |
|
|
463 |
463 |
// Allow "E0123" or "0123" form. |
464 |
464 |
let upper_cased_code = code.to_ascii_uppercase(); |
465 |
465 |
if let Ok(code) = upper_cased_code.strip_prefix('E').unwrap_or(&upper_cased_code).parse::<u32>() |
|
466 |
+ && code <= ErrCode::MAX_AS_U32 |
466 |
467 |
&& let Ok(description) = registry.try_find_description(ErrCode::from_u32(code)) |
467 |
468 |
{ |
468 |
469 |
let mut is_in_code_block = false; |
File renamed without changes.
File renamed without changes.
Original file line number |
Diff line number |
Diff line change |
@@ -0,0 +1,3 @@ |
|
|
|
1 |
+// It's a valid error with no added explanation |
|
2 |
+//@ compile-flags: --explain E9999 |
|
3 |
+//~? ERROR: E9999 is not a valid error code |
Original file line number |
Diff line number |
Diff line change |
@@ -0,0 +1,2 @@ |
|
|
|
1 |
+error: E9999 is not a valid error code |
|
2 |
+ |
Original file line number |
Diff line number |
Diff line change |
@@ -0,0 +1,2 @@ |
|
|
|
1 |
+//@ compile-flags: --explain error_code |
|
2 |
+//~? ERROR: error_code is not a valid error code |
Original file line number |
Diff line number |
Diff line change |
@@ -0,0 +1,2 @@ |
|
|
|
1 |
+error: error_code is not a valid error code |
|
2 |
+ |
Original file line number |
Diff line number |
Diff line change |
@@ -0,0 +1,2 @@ |
|
|
|
1 |
+//@ compile-flags: --explain 425 |
|
2 |
+//@ check-pass |
Original file line number |
Diff line number |
Diff line change |
@@ -0,0 +1,57 @@ |
|
|
|
1 |
+An unresolved name was used. |
|
2 |
+ |
|
3 |
+Erroneous code examples: |
|
4 |
+ |
|
5 |
+``` |
|
6 |
+something_that_doesnt_exist::foo; |
|
7 |
+// error: unresolved name `something_that_doesnt_exist::foo` |
|
8 |
+ |
|
9 |
+// or: |
|
10 |
+ |
|
11 |
+trait Foo { |
|
12 |
+ fn bar() { |
|
13 |
+ Self; // error: unresolved name `Self` |
|
14 |
+ } |
|
15 |
+} |
|
16 |
+ |
|
17 |
+// or: |
|
18 |
+ |
|
19 |
+let x = unknown_variable; // error: unresolved name `unknown_variable` |
|
20 |
+``` |
|
21 |
+ |
|
22 |
+Please verify that the name wasn't misspelled and ensure that the |
|
23 |
+identifier being referred to is valid for the given situation. Example: |
|
24 |
+ |
|
25 |
+``` |
|
26 |
+enum something_that_does_exist { |
|
27 |
+ Foo, |
|
28 |
+} |
|
29 |
+``` |
|
30 |
+ |
|
31 |
+Or: |
|
32 |
+ |
|
33 |
+``` |
|
34 |
+mod something_that_does_exist { |
|
35 |
+ pub static foo : i32 = 0i32; |
|
36 |
+} |
|
37 |
+ |
|
38 |
+something_that_does_exist::foo; // ok! |
|
39 |
+``` |
|
40 |
+ |
|
41 |
+Or: |
|
42 |
+ |
|
43 |
+``` |
|
44 |
+let unknown_variable = 12u32; |
|
45 |
+let x = unknown_variable; // ok! |
|
46 |
+``` |
|
47 |
+ |
|
48 |
+If the item is not defined in the current module, it must be imported using a |
|
49 |
+`use` statement, like so: |
|
50 |
+ |
|
51 |
+``` |
|
52 |
+use foo::bar; |
|
53 |
+bar(); |
|
54 |
+``` |
|
55 |
+ |
|
56 |
+If the item you are importing is not defined in some super-module of the |
|
57 |
+current module, then it must also be declared as public (e.g., `pub fn`). |
Original file line number |
Diff line number |
Diff line change |
@@ -0,0 +1,4 @@ |
|
|
|
1 |
+// Check that we don't crash on error codes exceeding our internal limit. |
|
2 |
+// issue: https://github.com/rust-lang/rust/issues/140647 |
|
3 |
+//@ compile-flags: --explain E10000 |
|
4 |
+//~? ERROR: E10000 is not a valid error code |
Original file line number |
Diff line number |
Diff line change |
@@ -0,0 +1,2 @@ |
|
|
|
1 |
+error: E10000 is not a valid error code |
|
2 |
+ |