Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add E0763 #73280

Merged
merged 2 commits into from
Jun 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/librustc_error_codes/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions src/librustc_error_codes/error_codes/E0763.md
Original file line number Diff line number Diff line change
@@ -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!
```
11 changes: 9 additions & 2 deletions src/librustc_parse/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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' '
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/byte-literals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ pub fn main() {
b' '; //~ ERROR byte constant must be escaped
b'''; //~ ERROR byte constant must be escaped
b'é'; //~ ERROR byte constant must be ASCII
b'a //~ ERROR unterminated byte constant
b'a //~ ERROR unterminated byte constant [E0763]
}
3 changes: 2 additions & 1 deletion src/test/ui/parser/byte-literals.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ error: byte constant must be ASCII. Use a \xHH escape for a non-ASCII byte
LL | b'é';
| ^

error: unterminated byte constant
error[E0763]: unterminated byte constant
--> $DIR/byte-literals.rs:11:6
|
LL | b'a
| ^^^^

error: aborting due to 7 previous errors

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