diff options
| -rw-r--r-- | src/librustdoc/passes/lint/html_tags.rs | 3 | ||||
| -rw-r--r-- | tests/rustdoc-ui/lints/invalid-html-tags-ice-146890.rs | 25 | ||||
| -rw-r--r-- | tests/rustdoc-ui/lints/invalid-html-tags-ice-146890.stderr | 38 |
3 files changed, 65 insertions, 1 deletions
diff --git a/src/librustdoc/passes/lint/html_tags.rs b/src/librustdoc/passes/lint/html_tags.rs index da09117b1bb..136ff258048 100644 --- a/src/librustdoc/passes/lint/html_tags.rs +++ b/src/librustdoc/passes/lint/html_tags.rs @@ -364,6 +364,7 @@ impl TagParser { } else { if !self.tag_name.is_empty() { self.in_attrs = true; + // range of the entire tag within dox let mut r = Range { start: range.start + start_pos, end: range.start + pos }; if c == '>' { // In case we have a tag without attribute, we can consider the span to @@ -381,7 +382,7 @@ impl TagParser { for (new_pos, c) in text[pos..].char_indices() { if !c.is_whitespace() { if c == '>' { - r.end = range.start + new_pos + 1; + r.end = range.start + pos + new_pos + 1; found = true; } else if c == '<' { self.handle_lt_in_tag(range.clone(), pos + new_pos, f); diff --git a/tests/rustdoc-ui/lints/invalid-html-tags-ice-146890.rs b/tests/rustdoc-ui/lints/invalid-html-tags-ice-146890.rs new file mode 100644 index 00000000000..d7efc201e7e --- /dev/null +++ b/tests/rustdoc-ui/lints/invalid-html-tags-ice-146890.rs @@ -0,0 +1,25 @@ +// this test ensures that bad HTML with multiline tags doesn't cause an ICE +// regression test for https://github.com/rust-lang/rust/issues/146890 +#[deny(rustdoc::invalid_html_tags)] + +/// <TABLE +/// BORDER> +/// <TR +/// > +/// <TH +//~^ ERROR: unclosed HTML tag `TH` +/// >key +/// </TD +//~^ ERROR: unopened HTML tag `TD` +/// > +/// <TH +//~^ ERROR: unclosed HTML tag `TH` +/// >value +/// </TD +//~^ ERROR: unopened HTML tag `TD` +/// > +/// </TR +/// > +/// </TABLE +/// > +pub fn foo() {} diff --git a/tests/rustdoc-ui/lints/invalid-html-tags-ice-146890.stderr b/tests/rustdoc-ui/lints/invalid-html-tags-ice-146890.stderr new file mode 100644 index 00000000000..64a82b3a952 --- /dev/null +++ b/tests/rustdoc-ui/lints/invalid-html-tags-ice-146890.stderr @@ -0,0 +1,38 @@ +error: unopened HTML tag `TD` + --> $DIR/invalid-html-tags-ice-146890.rs:12:5 + | +LL | /// </TD + | _____^ +LL | | +LL | | /// > + | |_____^ + | +note: the lint level is defined here + --> $DIR/invalid-html-tags-ice-146890.rs:3:8 + | +LL | #[deny(rustdoc::invalid_html_tags)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: unopened HTML tag `TD` + --> $DIR/invalid-html-tags-ice-146890.rs:18:5 + | +LL | /// </TD + | _____^ +LL | | +LL | | /// > + | |_____^ + +error: unclosed HTML tag `TH` + --> $DIR/invalid-html-tags-ice-146890.rs:9:5 + | +LL | /// <TH + | ^^^ + +error: unclosed HTML tag `TH` + --> $DIR/invalid-html-tags-ice-146890.rs:15:5 + | +LL | /// <TH + | ^^^ + +error: aborting due to 4 previous errors + |
