1
Fork 0

hide host param from generic parameter list of ~const bounds

This commit is contained in:
Oli Scherer 2023-10-12 17:14:19 +00:00
parent cfb6afa296
commit 6724f9926c
4 changed files with 18 additions and 9 deletions

View file

@ -2510,15 +2510,22 @@ fn clean_generic_args<'tcx>(
let args = generic_args let args = generic_args
.args .args
.iter() .iter()
.map(|arg| match arg { .filter_map(|arg| {
Some(match arg {
hir::GenericArg::Lifetime(lt) if !lt.is_anonymous() => { hir::GenericArg::Lifetime(lt) if !lt.is_anonymous() => {
GenericArg::Lifetime(clean_lifetime(*lt, cx)) GenericArg::Lifetime(clean_lifetime(*lt, cx))
} }
hir::GenericArg::Lifetime(_) => GenericArg::Lifetime(Lifetime::elided()), hir::GenericArg::Lifetime(_) => GenericArg::Lifetime(Lifetime::elided()),
hir::GenericArg::Type(ty) => GenericArg::Type(clean_ty(ty, cx)), 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::Const(ct) => GenericArg::Const(Box::new(clean_const(ct, cx))),
hir::GenericArg::Infer(_inf) => GenericArg::Infer, hir::GenericArg::Infer(_inf) => GenericArg::Infer,
}) })
})
.collect::<Vec<_>>() .collect::<Vec<_>>()
.into(); .into();
let bindings = let bindings =

View file

@ -104,6 +104,7 @@ pub(crate) fn ty_args_to_args<'tcx>(
arg: index, arg: index,
}), }),
))), ))),
GenericArgKind::Const(ct) if let ty::ConstKind::Param(p) = ct.kind() && p.name == sym::host => None,
GenericArgKind::Const(ct) => { GenericArgKind::Const(ct) => {
Some(GenericArg::Const(Box::new(clean_middle_const(kind.rebind(ct), cx)))) Some(GenericArg::Const(Box::new(clean_middle_const(kind.rebind(ct), cx))))
} }

View file

@ -6,6 +6,7 @@
#![feature(array_methods)] #![feature(array_methods)]
#![feature(assert_matches)] #![feature(assert_matches)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(if_let_guard)]
#![feature(impl_trait_in_assoc_type)] #![feature(impl_trait_in_assoc_type)]
#![feature(iter_intersperse)] #![feature(iter_intersperse)]
#![feature(lazy_cell)] #![feature(lazy_cell)]

View file

@ -7,6 +7,6 @@ pub trait Tr {
} }
// @has foo/fn.g.html // @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 /// foo
pub const fn g<T: ~const Tr>() {} pub const fn g<T: ~const Tr>() {}