Skip to content

Commit

Permalink
Rollup merge of rust-lang#64443 - Mark-Simulacrum:rustdoc-clean-1, r=…
Browse files Browse the repository at this point in the history
…GuillaumeGomez

rustdoc: general cleanup

Review should be conducted commit-by-commit.

There are some general cleanup commits in the end, which are somewhat related but can be easily split into another PR, so just let me know.
  • Loading branch information
Centril authored Sep 24, 2019
2 parents e74d953 + 059163f commit 4a58b14
Show file tree
Hide file tree
Showing 15 changed files with 1,480 additions and 1,450 deletions.
2 changes: 1 addition & 1 deletion src/librustdoc/clean/auto_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
source: Span::empty(),
name: None,
attrs: Default::default(),
visibility: None,
visibility: Inherited,
def_id: self.cx.next_def_id(param_env_def_id.krate),
stability: None,
deprecation: None,
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/blanket_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
source: self.cx.tcx.def_span(impl_def_id).clean(self.cx),
name: None,
attrs: Default::default(),
visibility: None,
visibility: Inherited,
def_id: self.cx.next_def_id(impl_def_id.krate),
stability: None,
deprecation: None,
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/clean/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub fn try_inline(
name: Some(name.clean(cx)),
attrs,
inner,
visibility: Some(clean::Public),
visibility: clean::Public,
stability: cx.tcx.lookup_stability(did).clean(cx),
deprecation: cx.tcx.lookup_deprecation(did).clean(cx),
def_id: did,
Expand Down Expand Up @@ -418,7 +418,7 @@ pub fn build_impl(cx: &DocContext<'_>, did: DefId, attrs: Option<Attrs<'_>>,
source: tcx.def_span(did).clean(cx),
name: None,
attrs,
visibility: Some(clean::Inherited),
visibility: clean::Inherited,
stability: tcx.lookup_stability(did).clean(cx),
deprecation: tcx.lookup_deprecation(did).clean(cx),
def_id: did,
Expand Down
46 changes: 18 additions & 28 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ pub fn krate(mut cx: &mut DocContext<'_>) -> Crate {
source: Span::empty(),
name: Some(prim.to_url_str().to_string()),
attrs: attrs.clone(),
visibility: Some(Public),
visibility: Public,
stability: get_stability(cx, def_id),
deprecation: get_deprecation(cx, def_id),
def_id,
Expand All @@ -199,7 +199,7 @@ pub fn krate(mut cx: &mut DocContext<'_>) -> Crate {
source: Span::empty(),
name: Some(kw.clone()),
attrs: attrs,
visibility: Some(Public),
visibility: Public,
stability: get_stability(cx, def_id),
deprecation: get_deprecation(cx, def_id),
def_id,
Expand Down Expand Up @@ -361,7 +361,7 @@ pub struct Item {
pub name: Option<String>,
pub attrs: Attributes,
pub inner: ItemEnum,
pub visibility: Option<Visibility>,
pub visibility: Visibility,
pub def_id: DefId,
pub stability: Option<Stability>,
pub deprecation: Option<Deprecation>,
Expand Down Expand Up @@ -1849,7 +1849,7 @@ fn get_real_types(
cx: &DocContext<'_>,
recurse: i32,
) -> FxHashSet<Type> {
let arg_s = arg.to_string();
let arg_s = arg.print().to_string();
let mut res = FxHashSet::default();
if recurse >= 10 { // FIXME: remove this whole recurse thing when the recursion bug is fixed
return res;
Expand Down Expand Up @@ -2311,7 +2311,7 @@ impl Clean<Item> for hir::TraitItem {
attrs: self.attrs.clean(cx),
source: self.span.clean(cx),
def_id: local_did,
visibility: None,
visibility: Visibility::Inherited,
stability: get_stability(cx, local_did),
deprecation: get_deprecation(cx, local_did),
inner,
Expand Down Expand Up @@ -2496,7 +2496,7 @@ impl Clean<Item> for ty::AssocItem {

let visibility = match self.container {
ty::ImplContainer(_) => self.vis.clean(cx),
ty::TraitContainer(_) => None,
ty::TraitContainer(_) => Inherited,
};

Item {
Expand Down Expand Up @@ -3293,9 +3293,9 @@ pub enum Visibility {
Restricted(DefId, Path),
}

impl Clean<Option<Visibility>> for hir::Visibility {
fn clean(&self, cx: &DocContext<'_>) -> Option<Visibility> {
Some(match self.node {
impl Clean<Visibility> for hir::Visibility {
fn clean(&self, cx: &DocContext<'_>) -> Visibility {
match self.node {
hir::VisibilityKind::Public => Visibility::Public,
hir::VisibilityKind::Inherited => Visibility::Inherited,
hir::VisibilityKind::Crate(_) => Visibility::Crate,
Expand All @@ -3304,13 +3304,13 @@ impl Clean<Option<Visibility>> for hir::Visibility {
let did = register_res(cx, path.res);
Visibility::Restricted(did, path)
}
})
}
}
}

impl Clean<Option<Visibility>> for ty::Visibility {
fn clean(&self, _: &DocContext<'_>) -> Option<Visibility> {
Some(if *self == ty::Visibility::Public { Public } else { Inherited })
impl Clean<Visibility> for ty::Visibility {
fn clean(&self, _: &DocContext<'_>) -> Visibility {
if *self == ty::Visibility::Public { Public } else { Inherited }
}
}

Expand Down Expand Up @@ -3427,7 +3427,7 @@ impl Clean<Item> for doctree::Variant<'_> {
name: Some(self.name.clean(cx)),
attrs: self.attrs.clean(cx),
source: self.whence.clean(cx),
visibility: None,
visibility: Inherited,
stability: cx.stability(self.id).clean(cx),
deprecation: cx.deprecation(self.id).clean(cx),
def_id: cx.tcx.hir().local_def_id(self.id),
Expand Down Expand Up @@ -3470,7 +3470,7 @@ impl Clean<Item> for ty::VariantDef {
name: Some(self.ident.clean(cx)),
attrs: inline::load_attrs(cx, self.def_id).clean(cx),
source: cx.tcx.def_span(self.def_id).clean(cx),
visibility: Some(Inherited),
visibility: Inherited,
def_id: self.def_id,
inner: VariantItem(Variant { kind }),
stability: get_stability(cx, self.def_id),
Expand Down Expand Up @@ -3573,16 +3573,6 @@ pub enum GenericArg {
Const(Constant),
}

impl fmt::Display for GenericArg {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
GenericArg::Lifetime(lt) => lt.fmt(f),
GenericArg::Type(ty) => ty.fmt(f),
GenericArg::Const(ct) => ct.fmt(f),
}
}
}

#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub enum GenericArgs {
AngleBracketed {
Expand Down Expand Up @@ -4274,7 +4264,7 @@ fn resolve_type(cx: &DocContext<'_>,
return Generic(kw::SelfUpper.to_string());
}
Res::Def(DefKind::TyParam, _) if path.segments.len() == 1 => {
return Generic(format!("{:#}", path));
return Generic(format!("{:#}", path.print()));
}
Res::SelfTy(..)
| Res::Def(DefKind::TyParam, _)
Expand Down Expand Up @@ -4343,7 +4333,7 @@ impl Clean<Item> for doctree::Macro<'_> {
name: Some(name.clone()),
attrs: self.attrs.clean(cx),
source: self.whence.clean(cx),
visibility: Some(Public),
visibility: Public,
stability: cx.stability(self.hid).clean(cx),
deprecation: cx.deprecation(self.hid).clean(cx),
def_id: self.def_id,
Expand Down Expand Up @@ -4371,7 +4361,7 @@ impl Clean<Item> for doctree::ProcMacro<'_> {
name: Some(self.name.clean(cx)),
attrs: self.attrs.clean(cx),
source: self.whence.clean(cx),
visibility: Some(Public),
visibility: Public,
stability: cx.stability(self.id).clean(cx),
deprecation: cx.deprecation(self.id).clean(cx),
def_id: cx.tcx.hir().local_def_id(self.id),
Expand Down
Loading

0 comments on commit 4a58b14

Please sign in to comment.