diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2020-07-04 00:12:16 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2020-07-04 00:15:29 +0200 |
| commit | d64a4b57aef5e1f0a51bbae24b73e5a7acd20aef (patch) | |
| tree | 7c51c012522f4977838d29238d3a08754e945f9f | |
| parent | f844ea1e561475e6023282ef167e76bc973773ef (diff) | |
| download | rust-d64a4b57aef5e1f0a51bbae24b73e5a7acd20aef.tar.gz rust-d64a4b57aef5e1f0a51bbae24b73e5a7acd20aef.zip | |
Create new E0768 error code for "no valid digits found for number" error
| -rw-r--r-- | src/librustc_error_codes/error_codes.rs | 1 | ||||
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0768.md | 13 | ||||
| -rw-r--r-- | src/librustc_parse/lexer/mod.rs | 9 |
3 files changed, 22 insertions, 1 deletions
diff --git a/src/librustc_error_codes/error_codes.rs b/src/librustc_error_codes/error_codes.rs index 00c072e1b04..f687221d78e 100644 --- a/src/librustc_error_codes/error_codes.rs +++ b/src/librustc_error_codes/error_codes.rs @@ -449,6 +449,7 @@ E0764: include_str!("./error_codes/E0764.md"), E0765: include_str!("./error_codes/E0765.md"), E0766: include_str!("./error_codes/E0766.md"), E0767: include_str!("./error_codes/E0767.md"), +E0768: include_str!("./error_codes/E0768.md"), ; // E0006, // merged with E0005 // E0008, // cannot bind by-move into a pattern guard diff --git a/src/librustc_error_codes/error_codes/E0768.md b/src/librustc_error_codes/error_codes/E0768.md new file mode 100644 index 00000000000..24169ef512e --- /dev/null +++ b/src/librustc_error_codes/error_codes/E0768.md @@ -0,0 +1,13 @@ +A number in a non-decimal base has no digits. + +Erroneous code example: + +```compile_fail,E0768 +let s: i32 = 0b; // error! +``` + +To fix this error, add the missing digits: + +``` +let s: i32 = 0b1; // ok! +``` diff --git a/src/librustc_parse/lexer/mod.rs b/src/librustc_parse/lexer/mod.rs index 5050f03bea9..2b0e637c74e 100644 --- a/src/librustc_parse/lexer/mod.rs +++ b/src/librustc_parse/lexer/mod.rs @@ -391,7 +391,14 @@ impl<'a> StringReader<'a> { } rustc_lexer::LiteralKind::Int { base, empty_int } => { return if empty_int { - self.err_span_(start, suffix_start, "no valid digits found for number"); + self.sess + .span_diagnostic + .struct_span_err_with_code( + self.mk_sp(start, suffix_start), + "no valid digits found for number", + error_code!(E0768), + ) + .emit(); (token::Integer, sym::integer(0)) } else { self.validate_int_literal(base, start, suffix_start); |
