Skip to content

Commit

Permalink
Add error code E744 for unterminated raw string
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Nov 6, 2019
1 parent e8b190a commit 26fe3f5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
18 changes: 18 additions & 0 deletions src/libsyntax/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,24 @@ undefined number of parameters to a given function (like `printf` in C). The
equivalent in Rust would be to use macros directly.
"##,

E0744: r##"
A raw string isn't terminated.
Erroneous code example:
```compile_fail,E0744
let dolphins = r##"Dolphins!"#; // error!
```
To terminate a raw string, you have to have the same number of `#` at the end
than at the beginning. Example:
```
let dolphins = r#"Dolphins!"#; // one `#` at the beginning, one at the end so
// all good!
```
"##,

;

E0539, // incorrect meta item
Expand Down
6 changes: 4 additions & 2 deletions src/libsyntax/parse/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,10 @@ impl<'a> StringReader<'a> {
}

fn report_unterminated_raw_string(&self, start: BytePos, n_hashes: usize) -> ! {
let mut err = self.struct_span_fatal(
start, start,
let mut err = struct_span_fatal!(
self.sess.span_diagnostic,
self.mk_sp(start, start),
E0744,
"unterminated raw string",
);
err.span_label(
Expand Down

0 comments on commit 26fe3f5

Please sign in to comment.