Skip to content

Commit a657be4

Browse files
Create E0765 error for unterminated double quote strings
1 parent 228a0ed commit a657be4

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

src/librustc_error_codes/error_codes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ E0761: include_str!("./error_codes/E0761.md"),
445445
E0762: include_str!("./error_codes/E0762.md"),
446446
E0763: include_str!("./error_codes/E0763.md"),
447447
E0764: include_str!("./error_codes/E0764.md"),
448+
E0765: include_str!("./error_codes/E0765.md"),
448449
;
449450
// E0006, // merged with E0005
450451
// E0008, // cannot bind by-move into a pattern guard
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
A double quote string (`"`) was not terminated.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0765
6+
let s = "; // error!
7+
```
8+
9+
To fix this error, add the missing double quote at the end of the string:
10+
11+
```
12+
let s = ""; // ok!
13+
```

src/librustc_parse/lexer/mod.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,15 @@ impl<'a> StringReader<'a> {
353353
}
354354
rustc_lexer::LiteralKind::Str { terminated } => {
355355
if !terminated {
356-
self.fatal_span_(start, suffix_start, "unterminated double quote string")
357-
.raise()
356+
self.sess
357+
.span_diagnostic
358+
.struct_span_fatal_with_code(
359+
self.mk_sp(start, suffix_start),
360+
"unterminated double quote string",
361+
error_code!(E0765),
362+
)
363+
.emit();
364+
FatalError.raise();
358365
}
359366
(token::Str, Mode::Str, 1, 1) // " "
360367
}

0 commit comments

Comments
 (0)