mirror of https://github.com/rust-lang/rust.git
Rollup merge of #84461 - jyn514:remove-strip-item, r=GuillaumeGomez
rustdoc: Remove unnecessary `StripItem` wrapper
This commit is contained in:
commit
9682fa9dc4
|
@ -1,17 +1,10 @@
|
||||||
use crate::clean::*;
|
use crate::clean::*;
|
||||||
|
|
||||||
crate struct StripItem(pub Item);
|
crate fn strip_item(mut item: Item) -> Item {
|
||||||
|
if !matches!(*item.kind, StrippedItem(..)) {
|
||||||
impl StripItem {
|
item.kind = box StrippedItem(item.kind);
|
||||||
crate fn strip(self) -> Item {
|
|
||||||
match self.0 {
|
|
||||||
Item { kind: box StrippedItem(..), .. } => self.0,
|
|
||||||
mut i => {
|
|
||||||
i.kind = box StrippedItem(i.kind);
|
|
||||||
i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
item
|
||||||
}
|
}
|
||||||
|
|
||||||
crate trait DocFolder: Sized {
|
crate trait DocFolder: Sized {
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::mem;
|
||||||
use crate::clean;
|
use crate::clean;
|
||||||
use crate::clean::{FakeDefIdSet, Item, NestedAttributesExt};
|
use crate::clean::{FakeDefIdSet, Item, NestedAttributesExt};
|
||||||
use crate::core::DocContext;
|
use crate::core::DocContext;
|
||||||
use crate::fold::{DocFolder, StripItem};
|
use crate::fold::{strip_item, DocFolder};
|
||||||
use crate::passes::{ImplStripper, Pass};
|
use crate::passes::{ImplStripper, Pass};
|
||||||
|
|
||||||
crate const STRIP_HIDDEN: Pass = Pass {
|
crate const STRIP_HIDDEN: Pass = Pass {
|
||||||
|
@ -44,7 +44,7 @@ impl<'a> DocFolder for Stripper<'a> {
|
||||||
// strip things like impl methods but when doing so
|
// strip things like impl methods but when doing so
|
||||||
// we must not add any items to the `retained` set.
|
// we must not add any items to the `retained` set.
|
||||||
let old = mem::replace(&mut self.update_retained, false);
|
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;
|
self.update_retained = old;
|
||||||
return Some(ret);
|
return Some(ret);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ use rustc_middle::middle::privacy::AccessLevels;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use crate::clean::{self, FakeDefIdSet, GetDefId, Item};
|
use crate::clean::{self, FakeDefIdSet, GetDefId, Item};
|
||||||
use crate::fold::{DocFolder, StripItem};
|
use crate::fold::{strip_item, DocFolder};
|
||||||
|
|
||||||
crate struct Stripper<'a> {
|
crate struct Stripper<'a> {
|
||||||
crate retained: &'a mut FakeDefIdSet,
|
crate retained: &'a mut FakeDefIdSet,
|
||||||
|
@ -51,7 +51,7 @@ impl<'a> DocFolder for Stripper<'a> {
|
||||||
|
|
||||||
clean::StructFieldItem(..) => {
|
clean::StructFieldItem(..) => {
|
||||||
if !i.visibility.is_public() {
|
if !i.visibility.is_public() {
|
||||||
return Some(StripItem(i).strip());
|
return Some(strip_item(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ impl<'a> DocFolder for Stripper<'a> {
|
||||||
if i.def_id.is_local() && !i.visibility.is_public() {
|
if i.def_id.is_local() && !i.visibility.is_public() {
|
||||||
debug!("Stripper: stripping module {:?}", i.name);
|
debug!("Stripper: stripping module {:?}", i.name);
|
||||||
let old = mem::replace(&mut self.update_retained, false);
|
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;
|
self.update_retained = old;
|
||||||
return Some(ret);
|
return Some(ret);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue