Skip to content

Commit

Permalink
Rollup merge of #99638 - GuillaumeGomez:rm-clean-trait, r=notriddle
Browse files Browse the repository at this point in the history
Remove Clean trait implementation for hir::Ty and middle::Ty

While going through the code, I realized that the "remove the Clean trait" effort which was started a while ago was never finished.

The idea behind it was to make it much simpler to go through the different clean steps (which is definitely not easy when you just have `something.clean(cx)`).

I'm planning to finish this effort.

cc `@camelid`
r? `@notriddle`
  • Loading branch information
GuillaumeGomez authored Jul 23, 2022
2 parents 866f330 + 7a9f307 commit 0408e79
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 136 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 @@ -121,7 +121,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
unsafety: hir::Unsafety::Normal,
generics: new_generics,
trait_: Some(trait_ref.clean(self.cx)),
for_: ty.clean(self.cx),
for_: clean_middle_ty(ty, self.cx, None),
items: Vec::new(),
polarity,
kind: ImplKind::Auto,
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/clean/blanket_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
// FIXME(eddyb) compute both `trait_` and `for_` from
// the post-inference `trait_ref`, as it's more accurate.
trait_: Some(trait_ref.0.clean(cx)),
for_: ty.0.clean(cx),
for_: clean_middle_ty(ty.0, cx, None),
items: cx.tcx
.associated_items(impl_def_id)
.in_definition_order()
.map(|x| x.clean(cx))
.collect::<Vec<_>>(),
polarity: ty::ImplPolarity::Positive,
kind: ImplKind::Blanket(Box::new(trait_ref.0.self_ty().clean(cx))),
kind: ImplKind::Blanket(Box::new(clean_middle_ty(trait_ref.0.self_ty(), cx, None))),
})),
cfg: None,
});
Expand Down
14 changes: 7 additions & 7 deletions src/librustdoc/clean/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use rustc_span::hygiene::MacroKind;
use rustc_span::symbol::{kw, sym, Symbol};

use crate::clean::{
self, clean_fn_decl_from_did_and_sig, clean_ty_generics, utils, Attributes, AttributesExt,
Clean, ImplKind, ItemId, Type, Visibility,
self, clean_fn_decl_from_did_and_sig, clean_middle_ty, clean_ty, clean_ty_generics, utils,
Attributes, AttributesExt, Clean, ImplKind, ItemId, Type, Visibility,
};
use crate::core::DocContext;
use crate::formats::item_type::ItemType;
Expand Down Expand Up @@ -261,7 +261,7 @@ fn build_union(cx: &mut DocContext<'_>, did: DefId) -> clean::Union {

fn build_type_alias(cx: &mut DocContext<'_>, did: DefId) -> clean::Typedef {
let predicates = cx.tcx.explicit_predicates_of(did);
let type_ = cx.tcx.type_of(did).clean(cx);
let type_ = clean_middle_ty(cx.tcx.type_of(did), cx, Some(did));

clean::Typedef {
type_,
Expand Down Expand Up @@ -357,8 +357,8 @@ pub(crate) fn build_impl(
};

let for_ = match &impl_item {
Some(impl_) => impl_.self_ty.clean(cx),
None => tcx.type_of(did).clean(cx),
Some(impl_) => clean_ty(impl_.self_ty, cx),
None => clean_middle_ty(tcx.type_of(did), cx, Some(did)),
};

// Only inline impl if the implementing type is
Expand Down Expand Up @@ -577,14 +577,14 @@ pub(crate) fn print_inlined_const(tcx: TyCtxt<'_>, did: DefId) -> String {

fn build_const(cx: &mut DocContext<'_>, def_id: DefId) -> clean::Constant {
clean::Constant {
type_: cx.tcx.type_of(def_id).clean(cx),
type_: clean_middle_ty(cx.tcx.type_of(def_id), cx, Some(def_id)),
kind: clean::ConstantKind::Extern { def_id },
}
}

fn build_static(cx: &mut DocContext<'_>, did: DefId, mutable: bool) -> clean::Static {
clean::Static {
type_: cx.tcx.type_of(did).clean(cx),
type_: clean_middle_ty(cx.tcx.type_of(did), cx, Some(did)),
mutability: if mutable { Mutability::Mut } else { Mutability::Not },
expr: None,
}
Expand Down
Loading

0 comments on commit 0408e79

Please sign in to comment.