Skip to content

Commit

Permalink
hide host param from generic parameter list of ~const bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Oct 12, 2023
1 parent cfb6afa commit 6724f99
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
23 changes: 15 additions & 8 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2510,14 +2510,21 @@ fn clean_generic_args<'tcx>(
let args = generic_args
.args
.iter()
.map(|arg| match arg {
hir::GenericArg::Lifetime(lt) if !lt.is_anonymous() => {
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::Infer(_inf) => GenericArg::Infer,
.filter_map(|arg| {
Some(match arg {
hir::GenericArg::Lifetime(lt) if !lt.is_anonymous() => {
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)
if cx.tcx.has_attr(ct.value.def_id, sym::rustc_host) =>
{
return None;
}
hir::GenericArg::Const(ct) => GenericArg::Const(Box::new(clean_const(ct, cx))),
hir::GenericArg::Infer(_inf) => GenericArg::Infer,
})
})
.collect::<Vec<_>>()
.into();
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/clean/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ pub(crate) fn ty_args_to_args<'tcx>(
arg: index,
}),
))),
GenericArgKind::Const(ct) if let ty::ConstKind::Param(p) = ct.kind() && p.name == sym::host => None,
GenericArgKind::Const(ct) => {
Some(GenericArg::Const(Box::new(clean_middle_const(kind.rebind(ct), cx))))
}
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#![feature(array_methods)]
#![feature(assert_matches)]
#![feature(box_patterns)]
#![feature(if_let_guard)]
#![feature(impl_trait_in_assoc_type)]
#![feature(iter_intersperse)]
#![feature(lazy_cell)]
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc/const-effect-param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ pub trait Tr {
}

// @has foo/fn.g.html
// @has - '//pre[@class="rust item-decl"]' 'pub const fn g<T: Tr<host>>()'
// @has - '//pre[@class="rust item-decl"]' 'pub const fn g<T: Tr>()'
/// foo
pub const fn g<T: ~const Tr>() {}

0 comments on commit 6724f99

Please sign in to comment.