Skip to content

Commit 537b869

Browse files
oli-obkfee1-dead
authored andcommitted
rustdoc
1 parent 7d3ee99 commit 537b869

File tree

7 files changed

+18
-3
lines changed

7 files changed

+18
-3
lines changed

src/librustdoc/clean/auto_trait.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
4040
discard_positive_impl: bool,
4141
) -> Option<Item> {
4242
let tcx = self.cx.tcx;
43-
let trait_ref = ty::TraitRef { def_id: trait_def_id, substs: tcx.mk_substs_trait(ty, &[]) };
43+
let trait_ref = ty::TraitRef {
44+
def_id: trait_def_id,
45+
substs: tcx.mk_substs_trait(ty, &[], ty::ConstnessArg::Not),
46+
};
4447
if !self.cx.generated_synthetics.insert((ty, trait_def_id)) {
4548
debug!("get_auto_trait_impl_for({:?}): already generated, aborting", trait_ref);
4649
return None;
@@ -625,6 +628,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
625628
}
626629
}
627630
GenericParamDefKind::Lifetime { .. } => {}
631+
GenericParamDefKind::Constness => {}
628632
GenericParamDefKind::Const { ref mut default, .. } => {
629633
// We never want something like `impl<const N: usize = 10>`
630634
default.take();

src/librustdoc/clean/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ impl<'tcx> Clean<'tcx, Option<WherePredicate>> for ty::Predicate<'tcx> {
308308
impl<'tcx> Clean<'tcx, Option<WherePredicate>> for ty::PolyTraitPredicate<'tcx> {
309309
fn clean(&self, cx: &mut DocContext<'tcx>) -> Option<WherePredicate> {
310310
// `T: ~const Destruct` is hidden because `T: Destruct` is a no-op.
311-
if self.skip_binder().constness == ty::BoundConstness::ConstIfConst
311+
if self.skip_binder().constness() != ty::ConstnessArg::Not
312312
&& Some(self.skip_binder().def_id()) == cx.tcx.lang_items().destruct_trait()
313313
{
314314
return None;
@@ -439,6 +439,7 @@ fn projection_to_path_segment<'tcx>(
439439
impl<'tcx> Clean<'tcx, GenericParamDef> for ty::GenericParamDef {
440440
fn clean(&self, cx: &mut DocContext<'tcx>) -> GenericParamDef {
441441
let (name, kind) = match self.kind {
442+
ty::GenericParamDefKind::Constness => (self.name, GenericParamDefKind::Constness),
442443
ty::GenericParamDefKind::Lifetime => {
443444
(self.name, GenericParamDefKind::Lifetime { outlives: vec![] })
444445
}
@@ -561,6 +562,7 @@ impl<'tcx> Clean<'tcx, Generics> for hir::Generics<'tcx> {
561562
.map(|param| {
562563
let param = clean_generic_param(cx, Some(self), param);
563564
match param.kind {
565+
GenericParamDefKind::Constness => unreachable!(),
564566
GenericParamDefKind::Lifetime { .. } => unreachable!(),
565567
GenericParamDefKind::Type { did, ref bounds, .. } => {
566568
cx.impl_trait_bounds.insert(did.into(), bounds.clone());
@@ -594,6 +596,7 @@ impl<'tcx> Clean<'tcx, Generics> for hir::Generics<'tcx> {
594596
if bounds.is_empty() {
595597
for param in &mut generics.params {
596598
match param.kind {
599+
GenericParamDefKind::Constness => {}
597600
GenericParamDefKind::Lifetime { .. } => {}
598601
GenericParamDefKind::Type { bounds: ref mut ty_bounds, .. } => {
599602
if &param.name == name {
@@ -642,6 +645,7 @@ fn clean_ty_generics<'tcx>(
642645
}
643646
Some(param.clean(cx))
644647
}
648+
ty::GenericParamDefKind::Constness => None,
645649
ty::GenericParamDefKind::Const { .. } => Some(param.clean(cx)),
646650
})
647651
.collect::<Vec<GenericParamDef>>();

src/librustdoc/clean/types.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,7 @@ impl WherePredicate {
13621362

13631363
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
13641364
pub(crate) enum GenericParamDefKind {
1365+
Constness,
13651366
Lifetime { outlives: Vec<Lifetime> },
13661367
Type { did: DefId, bounds: Vec<GenericBound>, default: Option<Box<Type>>, synthetic: bool },
13671368
Const { did: DefId, ty: Box<Type>, default: Option<Box<String>> },
@@ -1386,7 +1387,9 @@ rustc_data_structures::static_assert_size!(GenericParamDef, 56);
13861387
impl GenericParamDef {
13871388
pub(crate) fn is_synthetic_type_param(&self) -> bool {
13881389
match self.kind {
1389-
GenericParamDefKind::Lifetime { .. } | GenericParamDefKind::Const { .. } => false,
1390+
GenericParamDefKind::Constness
1391+
| GenericParamDefKind::Lifetime { .. }
1392+
| GenericParamDefKind::Const { .. } => false,
13901393
GenericParamDefKind::Type { synthetic, .. } => synthetic,
13911394
}
13921395
}

src/librustdoc/clean/utils.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ pub(crate) fn substs_to_args<'tcx>(
8484
let mut ret_val =
8585
Vec::with_capacity(substs.len().saturating_sub(if skip_first { 1 } else { 0 }));
8686
ret_val.extend(substs.iter().filter_map(|kind| match kind.unpack() {
87+
GenericArgKind::Constness(_) => None,
8788
GenericArgKind::Lifetime(lt) => {
8889
Some(GenericArg::Lifetime(lt.clean(cx).unwrap_or(Lifetime::elided())))
8990
}

src/librustdoc/html/format.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ impl clean::GenericParamDef {
190190
cx: &'a Context<'tcx>,
191191
) -> impl fmt::Display + 'a + Captures<'tcx> {
192192
display_fn(move |f| match &self.kind {
193+
clean::GenericParamDefKind::Constness => Ok(()),
193194
clean::GenericParamDefKind::Lifetime { outlives } => {
194195
write!(f, "{}", self.name)?;
195196

src/librustdoc/json/conversions.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ impl FromWithTcx<clean::GenericParamDefKind> for GenericParamDefKind {
363363
type_: (*ty).into_tcx(tcx),
364364
default: default.map(|x| *x),
365365
},
366+
Constness => GenericParamDefKind::Constness,
366367
}
367368
}
368369
}

src/rustdoc-json-types/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ pub enum GenericParamDefKind {
382382
type_: Type,
383383
default: Option<String>,
384384
},
385+
Constness,
385386
}
386387

387388
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]

0 commit comments

Comments
 (0)