1
Fork 0

rustdoc-json: Fix HRTBs for WherePredicate::BoundPredicate

This commit is contained in:
Martin Nordholts 2022-05-02 20:34:12 +02:00
parent b712135575
commit 1f15ce5f97
2 changed files with 17 additions and 3 deletions

View file

@ -350,10 +350,16 @@ impl FromWithTcx<clean::WherePredicate> for WherePredicate {
fn from_tcx(predicate: clean::WherePredicate, tcx: TyCtxt<'_>) -> Self {
use clean::WherePredicate::*;
match predicate {
BoundPredicate { ty, bounds, .. } => WherePredicate::BoundPredicate {
BoundPredicate { ty, bounds, bound_params } => WherePredicate::BoundPredicate {
type_: ty.into_tcx(tcx),
bounds: bounds.into_iter().map(|x| x.into_tcx(tcx)).collect(),
// FIXME: add `bound_params` to rustdoc-json-params?
generic_params: bound_params
.into_iter()
.map(|x| GenericParamDef {
name: x.0.to_string(),
kind: GenericParamDefKind::Lifetime { outlives: vec![] },
})
.collect(),
},
RegionPredicate { lifetime, bounds } => WherePredicate::RegionPredicate {
lifetime: lifetime.0.to_string(),

View file

@ -9,7 +9,7 @@ use std::path::PathBuf;
use serde::{Deserialize, Serialize};
/// rustdoc format-version.
pub const FORMAT_VERSION: u32 = 14;
pub const FORMAT_VERSION: u32 = 15;
/// A `Crate` is the root of the emitted JSON blob. It contains all type/documentation information
/// about the language items in the local crate, as well as info about external items to allow
@ -391,6 +391,14 @@ pub enum WherePredicate {
#[serde(rename = "type")]
type_: Type,
bounds: Vec<GenericBound>,
/// Used for Higher-Rank Trait Bounds (HRTBs)
/// ```plain
/// where for<'a> &'a T: Iterator,"
/// ^^^^^^^
/// |
/// this part
/// ```
generic_params: Vec<GenericParamDef>,
},
RegionPredicate {
lifetime: String,