about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2023-10-12 17:14:19 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2023-10-12 17:14:19 +0000
commit6724f9926c9e8c2d37e3e68e44238897bd89fddf (patch)
treeb07e4f7891609af30fc75de89db1216dfeffde75
parentcfb6afa2965a1504f366eb258193219c4a820141 (diff)
downloadrust-6724f9926c9e8c2d37e3e68e44238897bd89fddf.tar.gz
rust-6724f9926c9e8c2d37e3e68e44238897bd89fddf.zip
hide `host` param from generic parameter list of `~const` bounds
-rw-r--r--src/librustdoc/clean/mod.rs23
-rw-r--r--src/librustdoc/clean/utils.rs1
-rw-r--r--src/librustdoc/lib.rs1
-rw-r--r--tests/rustdoc/const-effect-param.rs2
4 files changed, 18 insertions, 9 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 1f52afc0022..0ee2232d1fe 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -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();
diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs
index 01078504b71..3b4f869dab4 100644
--- a/src/librustdoc/clean/utils.rs
+++ b/src/librustdoc/clean/utils.rs
@@ -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))))
             }
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index fc2acb6eaa3..67f5ea5d98b 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -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)]
diff --git a/tests/rustdoc/const-effect-param.rs b/tests/rustdoc/const-effect-param.rs
index b1155dd9d8f..f50a9b96d81 100644
--- a/tests/rustdoc/const-effect-param.rs
+++ b/tests/rustdoc/const-effect-param.rs
@@ -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>() {}