Rollup merge of #73581 - GuillaumeGomez:add-0766, r=varkor

Create 0766 error code
This commit is contained in:
Manish Goregaokar 2020-06-25 18:00:14 -07:00 committed by GitHub
commit 0d03456163
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 7 deletions

View File

@ -446,6 +446,7 @@ E0762: include_str!("./error_codes/E0762.md"),
E0763: include_str!("./error_codes/E0763.md"),
E0764: include_str!("./error_codes/E0764.md"),
E0765: include_str!("./error_codes/E0765.md"),
E0766: include_str!("./error_codes/E0766.md"),
;
// E0006, // merged with E0005
// E0008, // cannot bind by-move into a pattern guard

View File

@ -0,0 +1,13 @@
A double quote byte string (`b"`) was not terminated.
Erroneous code example:
```compile_fail,E0766
let s = b"; // error!
```
To fix this error, add the missing double quote at the end of the string:
```
let s = b""; // ok!
```

View File

@ -367,12 +367,15 @@ impl<'a> StringReader<'a> {
}
rustc_lexer::LiteralKind::ByteStr { terminated } => {
if !terminated {
self.fatal_span_(
start + BytePos(1),
suffix_start,
self.sess
.span_diagnostic
.struct_span_fatal_with_code(
self.mk_sp(start + BytePos(1), suffix_start),
"unterminated double quote byte string",
error_code!(E0766),
)
.raise()
.emit();
FatalError.raise();
}
(token::ByteStr, Mode::ByteStr, 2, 1) // b" "
}

View File

@ -22,7 +22,7 @@ error: byte constant must be ASCII. Use a \xHH escape for a non-ASCII byte
LL | b"é";
| ^
error: unterminated double quote byte string
error[E0766]: unterminated double quote byte string
--> $DIR/byte-string-literals.rs:7:6
|
LL | b"a
@ -32,3 +32,4 @@ LL | | }
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0766`.