Create new E0763 error code for unterminated byte constant
This commit is contained in:
parent
59493917be
commit
a19dfb573d
3 changed files with 23 additions and 2 deletions
|
@ -442,6 +442,7 @@ E0758: include_str!("./error_codes/E0758.md"),
|
|||
E0760: include_str!("./error_codes/E0760.md"),
|
||||
E0761: include_str!("./error_codes/E0761.md"),
|
||||
E0762: include_str!("./error_codes/E0762.md"),
|
||||
E0763: include_str!("./error_codes/E0763.md"),
|
||||
;
|
||||
// E0006, // merged with E0005
|
||||
// E0008, // cannot bind by-move into a pattern guard
|
||||
|
|
13
src/librustc_error_codes/error_codes/E0763.md
Normal file
13
src/librustc_error_codes/error_codes/E0763.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
A byte constant wasn't correctly ended.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0763
|
||||
let c = b'a; // error!
|
||||
```
|
||||
|
||||
To fix this error, add the missing quote:
|
||||
|
||||
```
|
||||
let c = b'a'; // ok!
|
||||
```
|
|
@ -339,8 +339,15 @@ impl<'a> StringReader<'a> {
|
|||
}
|
||||
rustc_lexer::LiteralKind::Byte { terminated } => {
|
||||
if !terminated {
|
||||
self.fatal_span_(start + BytePos(1), suffix_start, "unterminated byte constant")
|
||||
.raise()
|
||||
self.sess
|
||||
.span_diagnostic
|
||||
.struct_span_fatal_with_code(
|
||||
self.mk_sp(start + BytePos(1), suffix_start),
|
||||
"unterminated byte constant",
|
||||
error_code!(E0763),
|
||||
)
|
||||
.emit();
|
||||
FatalError.raise();
|
||||
}
|
||||
(token::Byte, Mode::Byte, 2, 1) // b' '
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue