Skip to content

Commit 4840b7c

Browse files
authored
Rollup merge of rust-lang#72912 - GuillaumeGomez:add-e0755, r=estebank
Add new E0758 error code
2 parents 74311fc + ec81d92 commit 4840b7c

File tree

7 files changed

+50
-1
lines changed

7 files changed

+50
-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
@@ -191,7 +191,15 @@ impl<'a> StringReader<'a> {
191191
"unterminated block comment"
192192
};
193193
let last_bpos = self.pos;
194-
self.fatal_span_(start, last_bpos, msg).raise();
194+
self.sess
195+
.span_diagnostic
196+
.struct_span_fatal_with_code(
197+
self.mk_sp(start, last_bpos),
198+
msg,
199+
error_code!(E0758),
200+
)
201+
.emit();
202+
FatalError.raise();
195203
}
196204

197205
if is_doc_comment {

src/test/ui/unterminated-comment.rs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* //~ ERROR E0758
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0758]: unterminated block comment
2+
--> $DIR/unterminated-comment.rs:1:1
3+
|
4+
LL | /*
5+
| ^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0758`.
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/*! //~ ERROR E0758
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0758]: unterminated block doc-comment
2+
--> $DIR/unterminated-doc-comment.rs:1:1
3+
|
4+
LL | /*!
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0758`.

0 commit comments

Comments
 (0)