Skip to content

Commit

Permalink
Auto merge of #91034 - camelid:docfragment, r=jyn514
Browse files Browse the repository at this point in the history
rustdoc: Cleanup `DocFragment`

- Remove unused `DocFragment.line` field
- Avoid using `Iterator::count()` where possible
  • Loading branch information
bors committed Nov 19, 2021
2 parents 18fa434 + 7a4e2ce commit a77da2d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
5 changes: 0 additions & 5 deletions src/librustdoc/clean/types.rs
Expand Up @@ -906,7 +906,6 @@ impl<I: Iterator<Item = ast::NestedMetaItem> + IntoIterator<Item = ast::NestedMe
/// kept separate because of issue #42760.
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
crate struct DocFragment {
crate line: usize,
crate span: rustc_span::Span,
/// The module this doc-comment came from.
///
Expand Down Expand Up @@ -1027,7 +1026,6 @@ impl Attributes {
additional_attrs: Option<(&[ast::Attribute], DefId)>,
) -> Attributes {
let mut doc_strings: Vec<DocFragment> = vec![];
let mut doc_line = 0;

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

let line = doc_line;
doc_line += value.as_str().lines().count();
let frag = DocFragment {
line,
span: attr.span,
doc: value,
kind,
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/markdown.rs
Expand Up @@ -656,7 +656,7 @@ impl<'a, I> Footnotes<'a, I> {
}

fn get_entry(&mut self, key: &str) -> &mut (Vec<Event<'a>>, u16) {
let new_id = self.footnotes.keys().count() + 1;
let new_id = self.footnotes.len() + 1;
let key = key.to_owned();
self.footnotes.entry(key).or_insert((Vec::new(), new_id as u16))
}
Expand Down
4 changes: 3 additions & 1 deletion src/librustdoc/passes/unindent_comments.rs
@@ -1,5 +1,7 @@
use std::cmp;

use rustc_span::symbol::kw;

use crate::clean::{self, DocFragment, DocFragmentKind, Item};
use crate::core::DocContext;
use crate::fold::{self, DocFolder};
Expand Down Expand Up @@ -87,7 +89,7 @@ fn unindent_fragments(docs: &mut Vec<DocFragment>) {
};

for fragment in docs {
if fragment.doc.as_str().lines().count() == 0 {
if fragment.doc == kw::Empty {
continue;
}

Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/passes/unindent_comments/tests.rs
Expand Up @@ -5,7 +5,6 @@ use rustc_span::symbol::Symbol;

fn create_doc_fragment(s: &str) -> Vec<DocFragment> {
vec![DocFragment {
line: 0,
span: DUMMY_SP,
parent_module: None,
doc: Symbol::intern(s),
Expand Down

0 comments on commit a77da2d

Please sign in to comment.