Skip to content

Commit ddde836

Browse files
authored
Rollup merge of rust-lang#146897 - lolbinarycat:rustdoc-invalid_html_tags-ice-146890, r=GuillaumeGomez
fix ICE in rustdoc::invalid_html_tags fixes rust-lang#146890 r? `@GuillaumeGomez`
2 parents 6ea9efb + 82c4018 commit ddde836

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

src/librustdoc/passes/lint/html_tags.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ impl TagParser {
364364
} else {
365365
if !self.tag_name.is_empty() {
366366
self.in_attrs = true;
367+
// range of the entire tag within dox
367368
let mut r = Range { start: range.start + start_pos, end: range.start + pos };
368369
if c == '>' {
369370
// In case we have a tag without attribute, we can consider the span to
@@ -381,7 +382,7 @@ impl TagParser {
381382
for (new_pos, c) in text[pos..].char_indices() {
382383
if !c.is_whitespace() {
383384
if c == '>' {
384-
r.end = range.start + new_pos + 1;
385+
r.end = range.start + pos + new_pos + 1;
385386
found = true;
386387
} else if c == '<' {
387388
self.handle_lt_in_tag(range.clone(), pos + new_pos, f);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// this test ensures that bad HTML with multiline tags doesn't cause an ICE
2+
// regression test for https://github.com/rust-lang/rust/issues/146890
3+
#[deny(rustdoc::invalid_html_tags)]
4+
5+
/// <TABLE
6+
/// BORDER>
7+
/// <TR
8+
/// >
9+
/// <TH
10+
//~^ ERROR: unclosed HTML tag `TH`
11+
/// >key
12+
/// </TD
13+
//~^ ERROR: unopened HTML tag `TD`
14+
/// >
15+
/// <TH
16+
//~^ ERROR: unclosed HTML tag `TH`
17+
/// >value
18+
/// </TD
19+
//~^ ERROR: unopened HTML tag `TD`
20+
/// >
21+
/// </TR
22+
/// >
23+
/// </TABLE
24+
/// >
25+
pub fn foo() {}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
error: unopened HTML tag `TD`
2+
--> $DIR/invalid-html-tags-ice-146890.rs:12:5
3+
|
4+
LL | /// </TD
5+
| _____^
6+
LL | |
7+
LL | | /// >
8+
| |_____^
9+
|
10+
note: the lint level is defined here
11+
--> $DIR/invalid-html-tags-ice-146890.rs:3:8
12+
|
13+
LL | #[deny(rustdoc::invalid_html_tags)]
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
15+
16+
error: unopened HTML tag `TD`
17+
--> $DIR/invalid-html-tags-ice-146890.rs:18:5
18+
|
19+
LL | /// </TD
20+
| _____^
21+
LL | |
22+
LL | | /// >
23+
| |_____^
24+
25+
error: unclosed HTML tag `TH`
26+
--> $DIR/invalid-html-tags-ice-146890.rs:9:5
27+
|
28+
LL | /// <TH
29+
| ^^^
30+
31+
error: unclosed HTML tag `TH`
32+
--> $DIR/invalid-html-tags-ice-146890.rs:15:5
33+
|
34+
LL | /// <TH
35+
| ^^^
36+
37+
error: aborting due to 4 previous errors
38+

0 commit comments

Comments
 (0)