Skip to content

Commit 45aa36b

Browse files
authored
Rollup merge of #73280 - GuillaumeGomez:add-e0763, r=petrochenkov
Add E0763
2 parents 1e31a7c + bad252c commit 45aa36b

File tree

5 files changed

+26
-4
lines changed

5 files changed

+26
-4
lines changed

src/librustc_error_codes/error_codes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ E0759: include_str!("./error_codes/E0759.md"),
443443
E0760: include_str!("./error_codes/E0760.md"),
444444
E0761: include_str!("./error_codes/E0761.md"),
445445
E0762: include_str!("./error_codes/E0762.md"),
446+
E0763: include_str!("./error_codes/E0763.md"),
446447
;
447448
// E0006, // merged with E0005
448449
// E0008, // cannot bind by-move into a pattern guard
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
A byte constant wasn't correctly ended.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0763
6+
let c = b'a; // error!
7+
```
8+
9+
To fix this error, add the missing quote:
10+
11+
```
12+
let c = b'a'; // ok!
13+
```

src/librustc_parse/lexer/mod.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,15 @@ impl<'a> StringReader<'a> {
339339
}
340340
rustc_lexer::LiteralKind::Byte { terminated } => {
341341
if !terminated {
342-
self.fatal_span_(start + BytePos(1), suffix_start, "unterminated byte constant")
343-
.raise()
342+
self.sess
343+
.span_diagnostic
344+
.struct_span_fatal_with_code(
345+
self.mk_sp(start + BytePos(1), suffix_start),
346+
"unterminated byte constant",
347+
error_code!(E0763),
348+
)
349+
.emit();
350+
FatalError.raise();
344351
}
345352
(token::Byte, Mode::Byte, 2, 1) // b' '
346353
}

src/test/ui/parser/byte-literals.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ pub fn main() {
88
b' '; //~ ERROR byte constant must be escaped
99
b'''; //~ ERROR byte constant must be escaped
1010
b'é'; //~ ERROR byte constant must be ASCII
11-
b'a //~ ERROR unterminated byte constant
11+
b'a //~ ERROR unterminated byte constant [E0763]
1212
}

src/test/ui/parser/byte-literals.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ error: byte constant must be ASCII. Use a \xHH escape for a non-ASCII byte
3434
LL | b'é';
3535
| ^
3636

37-
error: unterminated byte constant
37+
error[E0763]: unterminated byte constant
3838
--> $DIR/byte-literals.rs:11:6
3939
|
4040
LL | b'a
4141
| ^^^^
4242

4343
error: aborting due to 7 previous errors
4444

45+
For more information about this error, try `rustc --explain E0763`.

0 commit comments

Comments
 (0)