Skip to content

Commit c4e61fa

Browse files
committed
Hide host effect params from docs
1 parent 20363f4 commit c4e61fa

File tree

5 files changed

+19
-15
lines changed

5 files changed

+19
-15
lines changed

src/librustdoc/clean/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ fn clean_generic_param_def<'tcx>(
521521
},
522522
)
523523
}
524-
ty::GenericParamDefKind::Const { has_default, .. } => (
524+
ty::GenericParamDefKind::Const { has_default, is_host_effect } => (
525525
def.name,
526526
GenericParamDefKind::Const {
527527
ty: Box::new(clean_middle_ty(
@@ -541,6 +541,7 @@ fn clean_generic_param_def<'tcx>(
541541
)),
542542
false => None,
543543
},
544+
is_host_effect,
544545
},
545546
),
546547
};
@@ -597,6 +598,7 @@ fn clean_generic_param<'tcx>(
597598
ty: Box::new(clean_ty(ty, cx)),
598599
default: default
599600
.map(|ct| Box::new(ty::Const::from_anon_const(cx.tcx, ct.def_id).to_string())),
601+
is_host_effect: cx.tcx.has_attr(param.def_id, sym::rustc_host),
600602
},
601603
),
602604
};

src/librustdoc/clean/types.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,7 @@ impl WherePredicate {
13061306
pub(crate) enum GenericParamDefKind {
13071307
Lifetime { outlives: Vec<Lifetime> },
13081308
Type { did: DefId, bounds: Vec<GenericBound>, default: Option<Box<Type>>, synthetic: bool },
1309-
Const { ty: Box<Type>, default: Option<Box<String>> },
1309+
Const { ty: Box<Type>, default: Option<Box<String>>, is_host_effect: bool },
13101310
}
13111311

13121312
impl GenericParamDefKind {
@@ -1326,9 +1326,10 @@ impl GenericParamDef {
13261326
Self { name, kind: GenericParamDefKind::Lifetime { outlives: Vec::new() } }
13271327
}
13281328

1329-
pub(crate) fn is_synthetic_type_param(&self) -> bool {
1329+
pub(crate) fn is_synthetic_param(&self) -> bool {
13301330
match self.kind {
1331-
GenericParamDefKind::Lifetime { .. } | GenericParamDefKind::Const { .. } => false,
1331+
GenericParamDefKind::Lifetime { .. } => false,
1332+
GenericParamDefKind::Const { is_host_effect, .. } => is_host_effect,
13321333
GenericParamDefKind::Type { synthetic, .. } => synthetic,
13331334
}
13341335
}

src/librustdoc/html/format.rs

+1-2
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

+9-7
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

+2-2
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)