mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Remove Clean trait implementation for ty::Visibility
This commit is contained in:
parent
48316dfea1
commit
c2c70e20bc
@ -17,7 +17,8 @@ use rustc_span::symbol::{kw, sym, Symbol};
|
|||||||
|
|
||||||
use crate::clean::{
|
use crate::clean::{
|
||||||
self, clean_fn_decl_from_did_and_sig, clean_middle_field, clean_middle_ty, clean_ty,
|
self, clean_fn_decl_from_did_and_sig, clean_middle_field, clean_middle_ty, clean_ty,
|
||||||
clean_ty_generics, utils, Attributes, AttributesExt, Clean, ImplKind, ItemId, Type, Visibility,
|
clean_ty_generics, clean_visibility, utils, Attributes, AttributesExt, Clean, ImplKind, ItemId,
|
||||||
|
Type, Visibility,
|
||||||
};
|
};
|
||||||
use crate::core::DocContext;
|
use crate::core::DocContext;
|
||||||
use crate::formats::item_type::ItemType;
|
use crate::formats::item_type::ItemType;
|
||||||
@ -134,7 +135,7 @@ pub(crate) fn try_inline(
|
|||||||
);
|
);
|
||||||
if let Some(import_def_id) = import_def_id {
|
if let Some(import_def_id) = import_def_id {
|
||||||
// The visibility needs to reflect the one from the reexport and not from the "source" DefId.
|
// The visibility needs to reflect the one from the reexport and not from the "source" DefId.
|
||||||
item.visibility = cx.tcx.visibility(import_def_id).clean(cx);
|
item.visibility = clean_visibility(cx.tcx.visibility(import_def_id));
|
||||||
}
|
}
|
||||||
ret.push(item);
|
ret.push(item);
|
||||||
Some(ret)
|
Some(ret)
|
||||||
@ -599,7 +600,7 @@ fn build_macro(
|
|||||||
match CStore::from_tcx(cx.tcx).load_macro_untracked(def_id, cx.sess()) {
|
match CStore::from_tcx(cx.tcx).load_macro_untracked(def_id, cx.sess()) {
|
||||||
LoadedMacro::MacroDef(item_def, _) => {
|
LoadedMacro::MacroDef(item_def, _) => {
|
||||||
if let ast::ItemKind::MacroDef(ref def) = item_def.kind {
|
if let ast::ItemKind::MacroDef(ref def) = item_def.kind {
|
||||||
let vis = cx.tcx.visibility(import_def_id.unwrap_or(def_id)).clean(cx);
|
let vis = clean_visibility(cx.tcx.visibility(import_def_id.unwrap_or(def_id)));
|
||||||
clean::MacroItem(clean::Macro {
|
clean::MacroItem(clean::Macro {
|
||||||
source: utils::display_macro_source(cx, name, def, def_id, vis),
|
source: utils::display_macro_source(cx, name, def, def_id, vis),
|
||||||
})
|
})
|
||||||
|
@ -1817,9 +1817,8 @@ fn is_field_vis_inherited(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Clean<'tcx, Visibility> for ty::Visibility {
|
pub(crate) fn clean_visibility(vis: ty::Visibility) -> Visibility {
|
||||||
fn clean(&self, _cx: &mut DocContext<'_>) -> Visibility {
|
match vis {
|
||||||
match *self {
|
|
||||||
ty::Visibility::Public => Visibility::Public,
|
ty::Visibility::Public => Visibility::Public,
|
||||||
// NOTE: this is not quite right: `ty` uses `Invisible` to mean 'private',
|
// NOTE: this is not quite right: `ty` uses `Invisible` to mean 'private',
|
||||||
// while rustdoc really does mean inherited. That means that for enum variants, such as
|
// while rustdoc really does mean inherited. That means that for enum variants, such as
|
||||||
@ -1828,7 +1827,6 @@ impl<'tcx> Clean<'tcx, Visibility> for ty::Visibility {
|
|||||||
ty::Visibility::Invisible => Visibility::Inherited,
|
ty::Visibility::Invisible => Visibility::Inherited,
|
||||||
ty::Visibility::Restricted(module) => Visibility::Restricted(module),
|
ty::Visibility::Restricted(module) => Visibility::Restricted(module),
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Clean<'tcx, VariantStruct> for rustc_hir::VariantData<'tcx> {
|
impl<'tcx> Clean<'tcx, VariantStruct> for rustc_hir::VariantData<'tcx> {
|
||||||
@ -1988,7 +1986,7 @@ fn clean_maybe_renamed_item<'tcx>(
|
|||||||
clean_fn_or_proc_macro(item, sig, generics, body_id, &mut name, cx)
|
clean_fn_or_proc_macro(item, sig, generics, body_id, &mut name, cx)
|
||||||
}
|
}
|
||||||
ItemKind::Macro(ref macro_def, _) => {
|
ItemKind::Macro(ref macro_def, _) => {
|
||||||
let ty_vis = cx.tcx.visibility(def_id).clean(cx);
|
let ty_vis = clean_visibility(cx.tcx.visibility(def_id));
|
||||||
MacroItem(Macro {
|
MacroItem(Macro {
|
||||||
source: display_macro_source(cx, name, macro_def, def_id, ty_vis),
|
source: display_macro_source(cx, name, macro_def, def_id, ty_vis),
|
||||||
})
|
})
|
||||||
@ -2117,7 +2115,7 @@ fn clean_extern_crate<'tcx>(
|
|||||||
name: Some(name),
|
name: Some(name),
|
||||||
attrs: Box::new(attrs.clean(cx)),
|
attrs: Box::new(attrs.clean(cx)),
|
||||||
item_id: crate_def_id.into(),
|
item_id: crate_def_id.into(),
|
||||||
visibility: ty_vis.clean(cx),
|
visibility: clean_visibility(ty_vis),
|
||||||
kind: box ExternCrateItem { src: orig_name },
|
kind: box ExternCrateItem { src: orig_name },
|
||||||
cfg: attrs.cfg(cx.tcx, &cx.cache.hidden_cfg),
|
cfg: attrs.cfg(cx.tcx, &cx.cache.hidden_cfg),
|
||||||
}]
|
}]
|
||||||
|
@ -37,7 +37,7 @@ use crate::clean::cfg::Cfg;
|
|||||||
use crate::clean::external_path;
|
use crate::clean::external_path;
|
||||||
use crate::clean::inline::{self, print_inlined_const};
|
use crate::clean::inline::{self, print_inlined_const};
|
||||||
use crate::clean::utils::{is_literal_expr, print_const_expr, print_evaluated_const};
|
use crate::clean::utils::{is_literal_expr, print_const_expr, print_evaluated_const};
|
||||||
use crate::clean::Clean;
|
use crate::clean::{clean_visibility, Clean};
|
||||||
use crate::core::DocContext;
|
use crate::core::DocContext;
|
||||||
use crate::formats::cache::Cache;
|
use crate::formats::cache::Cache;
|
||||||
use crate::formats::item_type::ItemType;
|
use crate::formats::item_type::ItemType;
|
||||||
@ -499,7 +499,7 @@ impl Item {
|
|||||||
let visibility = if matches!(&kind, ItemKind::KeywordItem | ItemKind::PrimitiveItem(..)) {
|
let visibility = if matches!(&kind, ItemKind::KeywordItem | ItemKind::PrimitiveItem(..)) {
|
||||||
Visibility::Public
|
Visibility::Public
|
||||||
} else {
|
} else {
|
||||||
cx.tcx.visibility(def_id).clean(cx)
|
clean_visibility(cx.tcx.visibility(def_id))
|
||||||
};
|
};
|
||||||
|
|
||||||
Item { item_id: def_id.into(), kind: box kind, name, attrs, visibility, cfg }
|
Item { item_id: def_id.into(), kind: box kind, name, attrs, visibility, cfg }
|
||||||
|
Loading…
Reference in New Issue
Block a user