Skip to content

Commit 7788cb8

Browse files
Create new error code E0755 for unterminated multi-line comments
1 parent 698c5c6 commit 7788cb8

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

src/librustc_error_codes/error_codes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ E0751: include_str!("./error_codes/E0751.md"),
437437
E0752: include_str!("./error_codes/E0752.md"),
438438
E0753: include_str!("./error_codes/E0753.md"),
439439
E0754: include_str!("./error_codes/E0754.md"),
440+
E0758: include_str!("./error_codes/E0758.md"),
440441
;
441442
// E0006, // merged with E0005
442443
// E0008, // cannot bind by-move into a pattern guard
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
A multi-line (doc-)comment is unterminated.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0758
6+
/* I am not terminated!
7+
```
8+
9+
The same goes for doc comments:
10+
11+
```compile_fail,E0758
12+
/*! I am not terminated!
13+
```
14+
15+
You need to end your multi-line comment with `*/` in order to fix this error:
16+
17+
```
18+
/* I am terminated! */
19+
/*! I am also terminated! */
20+
```

src/librustc_parse/lexer/mod.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,15 @@ impl<'a> StringReader<'a> {
204204
"unterminated block comment"
205205
};
206206
let last_bpos = self.pos;
207-
self.fatal_span_(start, last_bpos, msg).raise();
207+
self.sess
208+
.span_diagnostic
209+
.struct_span_fatal_with_code(
210+
self.mk_sp(start, last_bpos),
211+
msg,
212+
error_code!(E0758),
213+
)
214+
.emit();
215+
FatalError.raise();
208216
}
209217

210218
if is_doc_comment {

0 commit comments

Comments
 (0)