Skip to content

Commit

Permalink
barely trying rustdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
BoxyUwU committed Jan 9, 2025
1 parent c19e8c3 commit d53cf04
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
24 changes: 16 additions & 8 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1770,7 +1770,7 @@ fn maybe_expand_private_type_alias<'tcx>(
}
indices.lifetimes += 1;
}
hir::GenericParamKind::Type { ref default, .. } => {
hir::GenericParamKind::Type { default, .. } => {
let mut j = 0;
let type_ = generic_args.args.iter().find_map(|arg| match arg {
hir::GenericArg::Type(ty) => {
Expand All @@ -1782,8 +1782,11 @@ fn maybe_expand_private_type_alias<'tcx>(
}
_ => None,
});
if let Some(ty) = type_.or(*default) {
args.insert(param.def_id.to_def_id(), GenericArg::Type(clean_ty(ty, cx)));
if let Some(ty) = type_.or(default.map(|d| d.as_ambig_ty())) {
args.insert(
param.def_id.to_def_id(),
GenericArg::Type(clean_ty(ty.as_unambig_ty(), cx)),
);
}
indices.types += 1;
}
Expand Down Expand Up @@ -1839,16 +1842,19 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
TyKind::Path(_) => clean_qpath(ty, cx),
TyKind::TraitObject(bounds, lifetime) => {
let bounds = bounds.iter().map(|bound| clean_poly_trait_ref(bound, cx)).collect();
let lifetime =
if !lifetime.is_elided() { Some(clean_lifetime(lifetime.pointer(), cx)) } else { None };
let lifetime = if !lifetime.is_elided() {
Some(clean_lifetime(lifetime.pointer(), cx))
} else {
None
};
DynTrait(bounds, lifetime)
}
TyKind::BareFn(barefn) => BareFunction(Box::new(clean_bare_fn_ty(barefn, cx))),
TyKind::UnsafeBinder(unsafe_binder_ty) => {
UnsafeBinder(Box::new(clean_unsafe_binder_ty(unsafe_binder_ty, cx)))
}
// Rustdoc handles `TyKind::Err`s by turning them into `Type::Infer`s.
TyKind::Infer
TyKind::Infer(_)
| TyKind::Err(_)
| TyKind::Typeof(..)
| TyKind::InferDelegation(..)
Expand Down Expand Up @@ -2527,8 +2533,10 @@ fn clean_generic_args<'tcx>(
GenericArg::Lifetime(clean_lifetime(lt, cx))
}
hir::GenericArg::Lifetime(_) => GenericArg::Lifetime(Lifetime::elided()),
hir::GenericArg::Type(ty) => GenericArg::Type(clean_ty(ty, cx)),
hir::GenericArg::Const(ct) => GenericArg::Const(Box::new(clean_const(ct, cx))),
hir::GenericArg::Type(ty) => GenericArg::Type(clean_ty(ty.as_unambig_ty(), cx)),
hir::GenericArg::Const(ct) => {
GenericArg::Const(Box::new(clean_const(ct.as_unambig_ct(), cx)))
}
hir::GenericArg::Infer(_inf) => GenericArg::Infer,
})
.collect::<Vec<_>>()
Expand Down
4 changes: 0 additions & 4 deletions src/librustdoc/visit_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,10 +598,6 @@ impl<'tcx> Visitor<'tcx> for RustdocVisitor<'_, 'tcx> {
// Unneeded.
}

fn visit_infer(&mut self, _: &hir::InferArg) {
// Unneeded.
}

fn visit_lifetime(&mut self, _: &hir::Lifetime) {
// Unneeded.
}
Expand Down

0 comments on commit d53cf04

Please sign in to comment.