Skip to content

Commit 059621d

Browse files
oli-obkcuviper
authored andcommitted
Hide host effect params from docs
(cherry picked from commit c4e61fa)
1 parent dbbf377 commit 059621d

File tree

5 files changed

+19
-15
lines changed

5 files changed

+19
-15
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ fn clean_generic_param_def<'tcx>(
542542
},
543543
)
544544
}
545-
ty::GenericParamDefKind::Const { has_default, .. } => (
545+
ty::GenericParamDefKind::Const { has_default, is_host_effect } => (
546546
def.name,
547547
GenericParamDefKind::Const {
548548
ty: Box::new(clean_middle_ty(
@@ -562,6 +562,7 @@ fn clean_generic_param_def<'tcx>(
562562
)),
563563
false => None,
564564
},
565+
is_host_effect,
565566
},
566567
),
567568
};
@@ -618,6 +619,7 @@ fn clean_generic_param<'tcx>(
618619
ty: Box::new(clean_ty(ty, cx)),
619620
default: default
620621
.map(|ct| Box::new(ty::Const::from_anon_const(cx.tcx, ct.def_id).to_string())),
622+
is_host_effect: cx.tcx.has_attr(param.def_id, sym::rustc_host),
621623
},
622624
),
623625
};

src/librustdoc/clean/types.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ impl WherePredicate {
13151315
pub(crate) enum GenericParamDefKind {
13161316
Lifetime { outlives: Vec<Lifetime> },
13171317
Type { did: DefId, bounds: Vec<GenericBound>, default: Option<Box<Type>>, synthetic: bool },
1318-
Const { ty: Box<Type>, default: Option<Box<String>> },
1318+
Const { ty: Box<Type>, default: Option<Box<String>>, is_host_effect: bool },
13191319
}
13201320

13211321
impl GenericParamDefKind {
@@ -1335,9 +1335,10 @@ impl GenericParamDef {
13351335
Self { name, kind: GenericParamDefKind::Lifetime { outlives: Vec::new() } }
13361336
}
13371337

1338-
pub(crate) fn is_synthetic_type_param(&self) -> bool {
1338+
pub(crate) fn is_synthetic_param(&self) -> bool {
13391339
match self.kind {
1340-
GenericParamDefKind::Lifetime { .. } | GenericParamDefKind::Const { .. } => false,
1340+
GenericParamDefKind::Lifetime { .. } => false,
1341+
GenericParamDefKind::Const { is_host_effect, .. } => is_host_effect,
13411342
GenericParamDefKind::Type { synthetic, .. } => synthetic,
13421343
}
13431344
}

src/librustdoc/html/format.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,7 @@ impl clean::Generics {
250250
cx: &'a Context<'tcx>,
251251
) -> impl fmt::Display + 'a + Captures<'tcx> {
252252
display_fn(move |f| {
253-
let mut real_params =
254-
self.params.iter().filter(|p| !p.is_synthetic_type_param()).peekable();
253+
let mut real_params = self.params.iter().filter(|p| !p.is_synthetic_param()).peekable();
255254
if real_params.peek().is_none() {
256255
return Ok(());
257256
}

src/librustdoc/json/conversions.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ impl FromWithTcx<clean::GenericParamDefKind> for GenericParamDefKind {
453453
default: default.map(|x| (*x).into_tcx(tcx)),
454454
synthetic,
455455
},
456-
Const { ty, default } => GenericParamDefKind::Const {
456+
Const { ty, default, is_host_effect: _ } => GenericParamDefKind::Const {
457457
type_: (*ty).into_tcx(tcx),
458458
default: default.map(|x| *x),
459459
},
@@ -491,12 +491,14 @@ impl FromWithTcx<clean::WherePredicate> for WherePredicate {
491491
default: default.map(|ty| (*ty).into_tcx(tcx)),
492492
synthetic,
493493
},
494-
clean::GenericParamDefKind::Const { ty, default } => {
495-
GenericParamDefKind::Const {
496-
type_: (*ty).into_tcx(tcx),
497-
default: default.map(|d| *d),
498-
}
499-
}
494+
clean::GenericParamDefKind::Const {
495+
ty,
496+
default,
497+
is_host_effect: _,
498+
} => GenericParamDefKind::Const {
499+
type_: (*ty).into_tcx(tcx),
500+
default: default.map(|d| *d),
501+
},
500502
};
501503
GenericParamDef { name, kind }
502504
})

tests/rustdoc/const-fn-effects.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
#![feature(effects)]
33

44
// @has foo/fn.bar.html
5-
// @has - '//pre[@class="rust item-decl"]' 'pub const fn bar<const host: bool = true>() -> '
5+
// @has - '//pre[@class="rust item-decl"]' 'pub const fn bar() -> '
66
/// foo
77
pub const fn bar() -> usize {
88
2
99
}
1010

1111
// @has foo/struct.Foo.html
12-
// @has - '//*[@class="method"]' 'const fn new<const host: bool = true>()'
12+
// @has - '//*[@class="method"]' 'const fn new()'
1313
pub struct Foo(usize);
1414

1515
impl Foo {

0 commit comments

Comments
 (0)