提交 0aa28446 编写于 作者: J Joshua Nelson

rustdoc: Remove unnecessary `StripItem` wrapper

上级 ae8b84bf
use crate::clean::*;
crate struct StripItem(pub Item);
impl StripItem {
crate fn strip(self) -> Item {
match self.0 {
Item { kind: box StrippedItem(..), .. } => self.0,
mut i => {
i.kind = box StrippedItem(i.kind);
i
}
}
crate fn strip_item(mut item: Item) -> Item {
if !matches!(*item.kind, StrippedItem(..)) {
item.kind = box StrippedItem(item.kind);
}
item
}
crate trait DocFolder: Sized {
......
......@@ -4,7 +4,7 @@
use crate::clean;
use crate::clean::{FakeDefIdSet, Item, NestedAttributesExt};
use crate::core::DocContext;
use crate::fold::{DocFolder, StripItem};
use crate::fold::{strip_item, DocFolder};
use crate::passes::{ImplStripper, Pass};
crate const STRIP_HIDDEN: Pass = Pass {
......@@ -44,7 +44,7 @@ fn fold_item(&mut self, i: Item) -> Option<Item> {
// strip things like impl methods but when doing so
// we must not add any items to the `retained` set.
let old = mem::replace(&mut self.update_retained, false);
let ret = StripItem(self.fold_item_recur(i)).strip();
let ret = strip_item(self.fold_item_recur(i));
self.update_retained = old;
return Some(ret);
}
......
......@@ -3,7 +3,7 @@
use std::mem;
use crate::clean::{self, FakeDefIdSet, GetDefId, Item};
use crate::fold::{DocFolder, StripItem};
use crate::fold::{strip_item, DocFolder};
crate struct Stripper<'a> {
crate retained: &'a mut FakeDefIdSet,
......@@ -51,7 +51,7 @@ fn fold_item(&mut self, i: Item) -> Option<Item> {
clean::StructFieldItem(..) => {
if !i.visibility.is_public() {
return Some(StripItem(i).strip());
return Some(strip_item(i));
}
}
......@@ -59,7 +59,7 @@ fn fold_item(&mut self, i: Item) -> Option<Item> {
if i.def_id.is_local() && !i.visibility.is_public() {
debug!("Stripper: stripping module {:?}", i.name);
let old = mem::replace(&mut self.update_retained, false);
let ret = StripItem(self.fold_item_recur(i)).strip();
let ret = strip_item(self.fold_item_recur(i));
self.update_retained = old;
return Some(ret);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册