diff --git a/src/librustdoc/passes/html_tags.rs b/src/librustdoc/passes/html_tags.rs
index ae4eac89b457a..1d9be619ec91a 100644
--- a/src/librustdoc/passes/html_tags.rs
+++ b/src/librustdoc/passes/html_tags.rs
@@ -7,6 +7,8 @@ use core::ops::Range;
use pulldown_cmark::{Event, Parser};
use rustc_feature::UnstableFeatures;
use rustc_session::lint;
+use std::iter::Peekable;
+use std::str::CharIndices;
pub const CHECK_INVALID_HTML_TAGS: Pass = Pass {
name: "check-invalid-html-tags",
@@ -75,70 +77,97 @@ fn drop_tag(
}
}
-fn extract_tag(
+fn extract_html_tag(
tags: &mut Vec<(String, Range)>,
text: &str,
- range: Range,
+ range: &Range,
+ start_pos: usize,
+ iter: &mut Peekable>,
f: &impl Fn(&str, &Range),
) {
- let mut iter = text.char_indices().peekable();
+ let mut tag_name = String::new();
+ let mut is_closing = false;
+ let mut prev_pos = start_pos;
- while let Some((start_pos, c)) = iter.next() {
- if c == '<' {
- let mut tag_name = String::new();
- let mut is_closing = false;
- let mut prev_pos = start_pos;
- loop {
- let (pos, c) = match iter.peek() {
- Some((pos, c)) => (*pos, *c),
- // In case we reached the of the doc comment, we want to check that it's an
- // unclosed HTML tag. For example "///