Skip to content

Commit e9abb39

Browse files
oli-obkcuviper
authored andcommitted
hide host param from generic parameter list of ~const bounds
(cherry picked from commit 6724f99)
1 parent 0570067 commit e9abb39

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2542,14 +2542,21 @@ fn clean_generic_args<'tcx>(
25422542
let args = generic_args
25432543
.args
25442544
.iter()
2545-
.map(|arg| match arg {
2546-
hir::GenericArg::Lifetime(lt) if !lt.is_anonymous() => {
2547-
GenericArg::Lifetime(clean_lifetime(*lt, cx))
2548-
}
2549-
hir::GenericArg::Lifetime(_) => GenericArg::Lifetime(Lifetime::elided()),
2550-
hir::GenericArg::Type(ty) => GenericArg::Type(clean_ty(ty, cx)),
2551-
hir::GenericArg::Const(ct) => GenericArg::Const(Box::new(clean_const(ct, cx))),
2552-
hir::GenericArg::Infer(_inf) => GenericArg::Infer,
2545+
.filter_map(|arg| {
2546+
Some(match arg {
2547+
hir::GenericArg::Lifetime(lt) if !lt.is_anonymous() => {
2548+
GenericArg::Lifetime(clean_lifetime(*lt, cx))
2549+
}
2550+
hir::GenericArg::Lifetime(_) => GenericArg::Lifetime(Lifetime::elided()),
2551+
hir::GenericArg::Type(ty) => GenericArg::Type(clean_ty(ty, cx)),
2552+
hir::GenericArg::Const(ct)
2553+
if cx.tcx.has_attr(ct.value.def_id, sym::rustc_host) =>
2554+
{
2555+
return None;
2556+
}
2557+
hir::GenericArg::Const(ct) => GenericArg::Const(Box::new(clean_const(ct, cx))),
2558+
hir::GenericArg::Infer(_inf) => GenericArg::Infer,
2559+
})
25532560
})
25542561
.collect::<Vec<_>>()
25552562
.into();

src/librustdoc/clean/utils.rs

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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)