Skip to content

Commit cdc0068

Browse files
committed
fix ICE in rustdoc::invalid_html_tags
1 parent 6710835 commit cdc0068

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// regression test for https://github.com/rust-lang/rust/issues/146890
2+
#[deny(rustdoc::invalid_html_tags)]
3+
4+
/// <TABLE
5+
/// BORDER>
6+
/// <TR
7+
/// >
8+
/// <TH
9+
//~^ ERROR: unclosed HTML tag `TH`
10+
/// >key
11+
/// </TD
12+
//~^ ERROR: unopened HTML tag `TD`
13+
/// >
14+
/// <TH
15+
//~^ ERROR: unclosed HTML tag `TH`
16+
/// >value
17+
/// </TD
18+
//~^ ERROR: unopened HTML tag `TD`
19+
/// >
20+
/// </TR
21+
/// >
22+
/// </TABLE
23+
/// >
24+
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:11: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:2: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:17: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:8:5
27+
|
28+
LL | /// <TH
29+
| ^^^
30+
31+
error: unclosed HTML tag `TH`
32+
--> $DIR/invalid-html-tags-ice-146890.rs:14:5
33+
|
34+
LL | /// <TH
35+
| ^^^
36+
37+
error: aborting due to 4 previous errors
38+

0 commit comments

Comments
 (0)