Rollup merge of #73581 - GuillaumeGomez:add-0766, r=varkor
Create 0766 error code
This commit is contained in:
commit
0d03456163
@ -446,6 +446,7 @@ E0762: include_str!("./error_codes/E0762.md"),
|
|||||||
E0763: include_str!("./error_codes/E0763.md"),
|
E0763: include_str!("./error_codes/E0763.md"),
|
||||||
E0764: include_str!("./error_codes/E0764.md"),
|
E0764: include_str!("./error_codes/E0764.md"),
|
||||||
E0765: include_str!("./error_codes/E0765.md"),
|
E0765: include_str!("./error_codes/E0765.md"),
|
||||||
|
E0766: include_str!("./error_codes/E0766.md"),
|
||||||
;
|
;
|
||||||
// E0006, // merged with E0005
|
// E0006, // merged with E0005
|
||||||
// E0008, // cannot bind by-move into a pattern guard
|
// E0008, // cannot bind by-move into a pattern guard
|
||||||
|
13
src/librustc_error_codes/error_codes/E0766.md
Normal file
13
src/librustc_error_codes/error_codes/E0766.md
Normal 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!
|
||||||
|
```
|
@ -367,12 +367,15 @@ impl<'a> StringReader<'a> {
|
|||||||
}
|
}
|
||||||
rustc_lexer::LiteralKind::ByteStr { terminated } => {
|
rustc_lexer::LiteralKind::ByteStr { terminated } => {
|
||||||
if !terminated {
|
if !terminated {
|
||||||
self.fatal_span_(
|
self.sess
|
||||||
start + BytePos(1),
|
.span_diagnostic
|
||||||
suffix_start,
|
.struct_span_fatal_with_code(
|
||||||
|
self.mk_sp(start + BytePos(1), suffix_start),
|
||||||
"unterminated double quote byte string",
|
"unterminated double quote byte string",
|
||||||
|
error_code!(E0766),
|
||||||
)
|
)
|
||||||
.raise()
|
.emit();
|
||||||
|
FatalError.raise();
|
||||||
}
|
}
|
||||||
(token::ByteStr, Mode::ByteStr, 2, 1) // b" "
|
(token::ByteStr, Mode::ByteStr, 2, 1) // b" "
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ error: byte constant must be ASCII. Use a \xHH escape for a non-ASCII byte
|
|||||||
LL | b"é";
|
LL | b"é";
|
||||||
| ^
|
| ^
|
||||||
|
|
||||||
error: unterminated double quote byte string
|
error[E0766]: unterminated double quote byte string
|
||||||
--> $DIR/byte-string-literals.rs:7:6
|
--> $DIR/byte-string-literals.rs:7:6
|
||||||
|
|
|
|
||||||
LL | b"a
|
LL | b"a
|
||||||
@ -32,3 +32,4 @@ LL | | }
|
|||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error: aborting due to 5 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0766`.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user