Skip to content

Commit 0be8d01

Browse files
committed
WIP: remove unused arg
1 parent 3272337 commit 0be8d01

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

src/librustdoc/passes/lint/html_tags.rs

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item, hir_id: HirId, dox: &
145145
match event {
146146
Event::Start(Tag::CodeBlock(_)) => in_code_block = true,
147147
Event::Html(text) | Event::InlineHtml(text) if !in_code_block => {
148-
tagp.extract_tags(&text, range, dox, &mut is_in_comment, &report_diag)
148+
tagp.extract_tags(&text, range, &mut is_in_comment, &report_diag)
149149
}
150150
Event::End(TagEnd::CodeBlock) => in_code_block = false,
151151
_ => {}
@@ -167,7 +167,7 @@ pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item, hir_id: HirId, dox: &
167167
}
168168
for (tag, range) in tagp.tags.iter().filter(|(t, range)| {
169169
let t = t.to_lowercase();
170-
!is_implicitly_self_closing(&t, range.clone(), dox)
170+
!is_implicitly_self_closing(&t)
171171
}) {
172172
report_diag(format!("unclosed HTML tag `{tag}`"), range, true);
173173
}
@@ -182,7 +182,7 @@ const ALLOWED_UNCLOSED: &[&str] = &[
182182
];
183183

184184
/// Allows constructs like `<img>`, but not `<img`.
185-
fn is_implicitly_self_closing(tag_name: &str, _range: Range<usize>, _dox: &str) -> bool {
185+
fn is_implicitly_self_closing(tag_name: &str) -> bool {
186186
ALLOWED_UNCLOSED.contains(&tag_name)
187187
}
188188

@@ -283,7 +283,6 @@ impl TagParser {
283283
fn drop_tag(
284284
&mut self,
285285
range: Range<usize>,
286-
dox: &str,
287286
f: &impl Fn(String, &Range<usize>, bool),
288287
) {
289288
let tag_name_low = self.tag_name.to_lowercase();
@@ -299,7 +298,7 @@ impl TagParser {
299298
continue;
300299
}
301300
let last_tag_name_low = last_tag_name.to_lowercase();
302-
if is_implicitly_self_closing(&last_tag_name_low, last_tag_span.clone(), dox) {
301+
if is_implicitly_self_closing(&last_tag_name_low) {
303302
continue;
304303
}
305304
// `tags` is used as a queue, meaning that everything after `pos` is included inside it.
@@ -334,7 +333,6 @@ impl TagParser {
334333
&mut self,
335334
text: &str,
336335
range: &Range<usize>,
337-
dox: &str,
338336
start_pos: usize,
339337
iter: &mut Peekable<CharIndices<'_>>,
340338
f: &impl Fn(String, &Range<usize>, bool),
@@ -388,7 +386,7 @@ impl TagParser {
388386
break 'outer_loop;
389387
}
390388
}
391-
self.drop_tag(r, dox, f);
389+
self.drop_tag(r, f);
392390
self.tag_parsed();
393391
} else {
394392
self.extract_opening_tag(text, range, r, pos, c, iter, f)
@@ -477,7 +475,6 @@ impl TagParser {
477475
&mut self,
478476
text: &str,
479477
range: Range<usize>,
480-
dox: &str,
481478
is_in_comment: &mut Option<Range<usize>>,
482479
f: &impl Fn(String, &Range<usize>, bool),
483480
) {
@@ -490,7 +487,7 @@ impl TagParser {
490487
if self.in_attrs &&
491488
let Some(&(start_pos, _)) = iter.peek()
492489
{
493-
self.extract_html_tag(text, &range, dox, start_pos, &mut iter, f);
490+
self.extract_html_tag(text, &range, start_pos, &mut iter, f);
494491
// if no progress is being made, move forward forcefully.
495492
if prev_pos == start_pos {
496493
iter.next();
@@ -524,11 +521,11 @@ impl TagParser {
524521
self.tag_parsed();
525522
526523
}*/
527-
self.extract_html_tag(text, &range, dox, start_pos, &mut iter, f);
524+
self.extract_html_tag(text, &range, start_pos, &mut iter, f);
528525
}
529526
} else if !self.tag_name.is_empty() {
530527
// partially inside html tag that spans across events
531-
self.extract_html_tag(text, &range, dox, start_pos, &mut iter, f);
528+
self.extract_html_tag(text, &range, start_pos, &mut iter, f);
532529
}
533530
}
534531
}
@@ -544,7 +541,7 @@ fn test_extract_tags_nested_unclosed() {
544541
let mut tagp = TagParser::new();
545542
let mut diags = RefCell::new(Vec::new());
546543
let dox = "<div>\n<br</div>";
547-
tagp.extract_tags(dox, 0..dox.len(), dox, &mut None, &|s, r, b| {
544+
tagp.extract_tags(dox, 0..dox.len(), &mut None, &|s, r, b| {
548545
diags.borrow_mut().push((s, r.clone(), b));
549546
});
550547
assert_eq!(diags.borrow().len(), 1, "did not get expected diagnostics: {diags:?}");
@@ -558,7 +555,7 @@ fn test_extract_tags_taglike_in_attr() {
558555
let mut tagp = TagParser::new();
559556
let mut diags = RefCell::new(Vec::new());
560557
let dox = "<img src='<div>'>";
561-
tagp.extract_tags(dox, 0..dox.len(), dox, &mut None, &|s, r, b| {
558+
tagp.extract_tags(dox, 0..dox.len(), &mut None, &|s, r, b| {
562559
diags.borrow_mut().push((s, r.clone(), b));
563560
});
564561
assert_eq!(diags.borrow().len(), 0, "unexpected diagnostics: {diags:?}");
@@ -571,8 +568,22 @@ fn test_extract_tags_taglike_in_multiline_attr() {
571568
let mut tagp = TagParser::new();
572569
let mut diags = RefCell::new(Vec::new());
573570
let dox = "<img src=\"\nasd\n<div>\n\">";
574-
tagp.extract_tags(dox, 0..dox.len(), dox, &mut None, &|s, r, b| {
571+
tagp.extract_tags(dox, 0..dox.len(), &mut None, &|s, r, b| {
575572
diags.borrow_mut().push((s, r.clone(), b));
576573
});
577574
assert_eq!(diags.borrow().len(), 0, "unexpected diagnostics: {diags:?}");
578575
}
576+
577+
/*#[test]
578+
fn test_extract_tags_taglike_in_multievent_attr() {
579+
use std::cell::RefCell;
580+
581+
let mut tagp = TagParser::new();
582+
let mut diags = RefCell::new(Vec::new());
583+
let dox = "<img src='<div>'>";
584+
let split_point = 10;
585+
tagp.extract_tags(dox, 0..dox.len(), &mut None, &|s, r, b| {
586+
diags.borrow_mut().push((s, r.clone(), b));
587+
});
588+
assert_eq!(diags.borrow().len(), 0, "unexpected diagnostics: {diags:?}");
589+
}*/

0 commit comments

Comments
 (0)