Create E0765 error for unterminated double quote strings
This commit is contained in:
parent
228a0ed7b0
commit
a657be42b1
3 changed files with 23 additions and 2 deletions
|
@ -445,6 +445,7 @@ E0761: include_str!("./error_codes/E0761.md"),
|
||||||
E0762: include_str!("./error_codes/E0762.md"),
|
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"),
|
||||||
;
|
;
|
||||||
// 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/E0765.md
Normal file
13
src/librustc_error_codes/error_codes/E0765.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
A double quote string (`"`) was not terminated.
|
||||||
|
|
||||||
|
Erroneous code example:
|
||||||
|
|
||||||
|
```compile_fail,E0765
|
||||||
|
let s = "; // error!
|
||||||
|
```
|
||||||
|
|
||||||
|
To fix this error, add the missing double quote at the end of the string:
|
||||||
|
|
||||||
|
```
|
||||||
|
let s = ""; // ok!
|
||||||
|
```
|
|
@ -353,8 +353,15 @@ impl<'a> StringReader<'a> {
|
||||||
}
|
}
|
||||||
rustc_lexer::LiteralKind::Str { terminated } => {
|
rustc_lexer::LiteralKind::Str { terminated } => {
|
||||||
if !terminated {
|
if !terminated {
|
||||||
self.fatal_span_(start, suffix_start, "unterminated double quote string")
|
self.sess
|
||||||
.raise()
|
.span_diagnostic
|
||||||
|
.struct_span_fatal_with_code(
|
||||||
|
self.mk_sp(start, suffix_start),
|
||||||
|
"unterminated double quote string",
|
||||||
|
error_code!(E0765),
|
||||||
|
)
|
||||||
|
.emit();
|
||||||
|
FatalError.raise();
|
||||||
}
|
}
|
||||||
(token::Str, Mode::Str, 1, 1) // " "
|
(token::Str, Mode::Str, 1, 1) // " "
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue