Skip to content

Commit a77da2d

Browse files
committed
Auto merge of rust-lang#91034 - camelid:docfragment, r=jyn514
rustdoc: Cleanup `DocFragment` - Remove unused `DocFragment.line` field - Avoid using `Iterator::count()` where possible
2 parents 18fa434 + 7a4e2ce commit a77da2d

File tree

4 files changed

+4
-8
lines changed

4 files changed

+4
-8
lines changed

src/librustdoc/clean/types.rs

-5
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,6 @@ impl<I: Iterator<Item = ast::NestedMetaItem> + IntoIterator<Item = ast::NestedMe
906906
/// kept separate because of issue #42760.
907907
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
908908
crate struct DocFragment {
909-
crate line: usize,
910909
crate span: rustc_span::Span,
911910
/// The module this doc-comment came from.
912911
///
@@ -1027,7 +1026,6 @@ impl Attributes {
10271026
additional_attrs: Option<(&[ast::Attribute], DefId)>,
10281027
) -> Attributes {
10291028
let mut doc_strings: Vec<DocFragment> = vec![];
1030-
let mut doc_line = 0;
10311029

10321030
fn update_need_backline(doc_strings: &mut Vec<DocFragment>) {
10331031
if let Some(prev) = doc_strings.last_mut() {
@@ -1045,10 +1043,7 @@ impl Attributes {
10451043
DocFragmentKind::RawDoc
10461044
};
10471045

1048-
let line = doc_line;
1049-
doc_line += value.as_str().lines().count();
10501046
let frag = DocFragment {
1051-
line,
10521047
span: attr.span,
10531048
doc: value,
10541049
kind,

src/librustdoc/html/markdown.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ impl<'a, I> Footnotes<'a, I> {
656656
}
657657

658658
fn get_entry(&mut self, key: &str) -> &mut (Vec<Event<'a>>, u16) {
659-
let new_id = self.footnotes.keys().count() + 1;
659+
let new_id = self.footnotes.len() + 1;
660660
let key = key.to_owned();
661661
self.footnotes.entry(key).or_insert((Vec::new(), new_id as u16))
662662
}

src/librustdoc/passes/unindent_comments.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use std::cmp;
22

3+
use rustc_span::symbol::kw;
4+
35
use crate::clean::{self, DocFragment, DocFragmentKind, Item};
46
use crate::core::DocContext;
57
use crate::fold::{self, DocFolder};
@@ -87,7 +89,7 @@ fn unindent_fragments(docs: &mut Vec<DocFragment>) {
8789
};
8890

8991
for fragment in docs {
90-
if fragment.doc.as_str().lines().count() == 0 {
92+
if fragment.doc == kw::Empty {
9193
continue;
9294
}
9395

src/librustdoc/passes/unindent_comments/tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use rustc_span::symbol::Symbol;
55

66
fn create_doc_fragment(s: &str) -> Vec<DocFragment> {
77
vec![DocFragment {
8-
line: 0,
98
span: DUMMY_SP,
109
parent_module: None,
1110
doc: Symbol::intern(s),

0 commit comments

Comments
 (0)