Skip to content

Commit 26fe3f5

Browse files
Add error code E744 for unterminated raw string
1 parent e8b190a commit 26fe3f5

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/libsyntax/error_codes.rs

+18
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,24 @@ undefined number of parameters to a given function (like `printf` in C). The
518518
equivalent in Rust would be to use macros directly.
519519
"##,
520520

521+
E0744: r##"
522+
A raw string isn't terminated.
523+
524+
Erroneous code example:
525+
526+
```compile_fail,E0744
527+
let dolphins = r##"Dolphins!"#; // error!
528+
```
529+
530+
To terminate a raw string, you have to have the same number of `#` at the end
531+
than at the beginning. Example:
532+
533+
```
534+
let dolphins = r#"Dolphins!"#; // one `#` at the beginning, one at the end so
535+
// all good!
536+
```
537+
"##,
538+
521539
;
522540

523541
E0539, // incorrect meta item

src/libsyntax/parse/lexer/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,10 @@ impl<'a> StringReader<'a> {
501501
}
502502

503503
fn report_unterminated_raw_string(&self, start: BytePos, n_hashes: usize) -> ! {
504-
let mut err = self.struct_span_fatal(
505-
start, start,
504+
let mut err = struct_span_fatal!(
505+
self.sess.span_diagnostic,
506+
self.mk_sp(start, start),
507+
E0744,
506508
"unterminated raw string",
507509
);
508510
err.span_label(

0 commit comments

Comments
 (0)