Skip to content

Commit 6724f99

Browse files
committed
hide host param from generic parameter list of ~const bounds
1 parent cfb6afa commit 6724f99

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

src/librustdoc/clean/mod.rs

+15-8
Original file line numberDiff line numberDiff line change
@@ -2510,14 +2510,21 @@ fn clean_generic_args<'tcx>(
25102510
let args = generic_args
25112511
.args
25122512
.iter()
2513-
.map(|arg| match arg {
2514-
hir::GenericArg::Lifetime(lt) if !lt.is_anonymous() => {
2515-
GenericArg::Lifetime(clean_lifetime(*lt, cx))
2516-
}
2517-
hir::GenericArg::Lifetime(_) => GenericArg::Lifetime(Lifetime::elided()),
2518-
hir::GenericArg::Type(ty) => GenericArg::Type(clean_ty(ty, cx)),
2519-
hir::GenericArg::Const(ct) => GenericArg::Const(Box::new(clean_const(ct, cx))),
2520-
hir::GenericArg::Infer(_inf) => GenericArg::Infer,
2513+
.filter_map(|arg| {
2514+
Some(match arg {
2515+
hir::GenericArg::Lifetime(lt) if !lt.is_anonymous() => {
2516+
GenericArg::Lifetime(clean_lifetime(*lt, cx))
2517+
}
2518+
hir::GenericArg::Lifetime(_) => GenericArg::Lifetime(Lifetime::elided()),
2519+
hir::GenericArg::Type(ty) => GenericArg::Type(clean_ty(ty, cx)),
2520+
hir::GenericArg::Const(ct)
2521+
if cx.tcx.has_attr(ct.value.def_id, sym::rustc_host) =>
2522+
{
2523+
return None;
2524+
}
2525+
hir::GenericArg::Const(ct) => GenericArg::Const(Box::new(clean_const(ct, cx))),
2526+
hir::GenericArg::Infer(_inf) => GenericArg::Infer,
2527+
})
25212528
})
25222529
.collect::<Vec<_>>()
25232530
.into();

src/librustdoc/clean/utils.rs

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ pub(crate) fn ty_args_to_args<'tcx>(
104104
arg: index,
105105
}),
106106
))),
107+
GenericArgKind::Const(ct) if let ty::ConstKind::Param(p) = ct.kind() && p.name == sym::host => None,
107108
GenericArgKind::Const(ct) => {
108109
Some(GenericArg::Const(Box::new(clean_middle_const(kind.rebind(ct), cx))))
109110
}

src/librustdoc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#![feature(array_methods)]
77
#![feature(assert_matches)]
88
#![feature(box_patterns)]
9+
#![feature(if_let_guard)]
910
#![feature(impl_trait_in_assoc_type)]
1011
#![feature(iter_intersperse)]
1112
#![feature(lazy_cell)]

tests/rustdoc/const-effect-param.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ pub trait Tr {
77
}
88

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

0 commit comments

Comments
 (0)