Skip to content

Commit 6339abd

Browse files
authored
Rollup merge of #73861 - GuillaumeGomez:create-e0767, r=Dylan-DPC
Create E0768 r? @Dylan-DPC
2 parents 9a659c5 + 6970c92 commit 6339abd

File tree

6 files changed

+33
-9
lines changed

6 files changed

+33
-9
lines changed

src/librustc_error_codes/error_codes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ E0764: include_str!("./error_codes/E0764.md"),
449449
E0765: include_str!("./error_codes/E0765.md"),
450450
E0766: include_str!("./error_codes/E0766.md"),
451451
E0767: include_str!("./error_codes/E0767.md"),
452+
E0768: include_str!("./error_codes/E0768.md"),
452453
;
453454
// E0006, // merged with E0005
454455
// E0008, // cannot bind by-move into a pattern guard
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
A number in a non-decimal base has no digits.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0768
6+
let s: i32 = 0b; // error!
7+
```
8+
9+
To fix this error, add the missing digits:
10+
11+
```
12+
let s: i32 = 0b1; // ok!
13+
```

src/librustc_parse/lexer/mod.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,14 @@ impl<'a> StringReader<'a> {
391391
}
392392
rustc_lexer::LiteralKind::Int { base, empty_int } => {
393393
return if empty_int {
394-
self.err_span_(start, suffix_start, "no valid digits found for number");
394+
self.sess
395+
.span_diagnostic
396+
.struct_span_err_with_code(
397+
self.mk_sp(start, suffix_start),
398+
"no valid digits found for number",
399+
error_code!(E0768),
400+
)
401+
.emit();
395402
(token::Integer, sym::integer(0))
396403
} else {
397404
self.validate_int_literal(base, start, suffix_start);
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
error: no valid digits found for number
1+
error[E0768]: no valid digits found for number
22
--> $DIR/issue-1802-1.rs:5:16
33
|
44
LL | log(error, 0b);
55
| ^^
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0768`.
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
error: no valid digits found for number
1+
error[E0768]: no valid digits found for number
22
--> $DIR/issue-1802-2.rs:5:16
33
|
44
LL | log(error, 0b);
55
| ^^
66

77
error: aborting due to previous error
88

9+
For more information about this error, try `rustc --explain E0768`.

src/test/ui/parser/lex-bad-numeric-literals.stderr

+7-6
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ error: hexadecimal float literal is not supported
4646
LL | 0x9.0e-9;
4747
| ^^^^^^^^
4848

49-
error: no valid digits found for number
49+
error[E0768]: no valid digits found for number
5050
--> $DIR/lex-bad-numeric-literals.rs:11:5
5151
|
5252
LL | 0o;
@@ -64,31 +64,31 @@ error: hexadecimal float literal is not supported
6464
LL | 0x539.0;
6565
| ^^^^^^^
6666

67-
error: no valid digits found for number
67+
error[E0768]: no valid digits found for number
6868
--> $DIR/lex-bad-numeric-literals.rs:18:5
6969
|
7070
LL | 0x;
7171
| ^^
7272

73-
error: no valid digits found for number
73+
error[E0768]: no valid digits found for number
7474
--> $DIR/lex-bad-numeric-literals.rs:19:5
7575
|
7676
LL | 0xu32;
7777
| ^^
7878

79-
error: no valid digits found for number
79+
error[E0768]: no valid digits found for number
8080
--> $DIR/lex-bad-numeric-literals.rs:20:5
8181
|
8282
LL | 0ou32;
8383
| ^^
8484

85-
error: no valid digits found for number
85+
error[E0768]: no valid digits found for number
8686
--> $DIR/lex-bad-numeric-literals.rs:21:5
8787
|
8888
LL | 0bu32;
8989
| ^^
9090

91-
error: no valid digits found for number
91+
error[E0768]: no valid digits found for number
9292
--> $DIR/lex-bad-numeric-literals.rs:22:5
9393
|
9494
LL | 0b;
@@ -138,3 +138,4 @@ LL | 0b101f64;
138138

139139
error: aborting due to 23 previous errors
140140

141+
For more information about this error, try `rustc --explain E0768`.

0 commit comments

Comments
 (0)