fix ICE in rustdoc::invalid_html_tags
This commit is contained in:
parent
6710835ae7
commit
82c4018619
3 changed files with 65 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
25
tests/rustdoc-ui/lints/invalid-html-tags-ice-146890.rs
Normal file
25
tests/rustdoc-ui/lints/invalid-html-tags-ice-146890.rs
Normal file
|
|
@ -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() {}
|
||||
38
tests/rustdoc-ui/lints/invalid-html-tags-ice-146890.stderr
Normal file
38
tests/rustdoc-ui/lints/invalid-html-tags-ice-146890.stderr
Normal file
|
|
@ -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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue