Skip to content

Commit

Permalink
rustdoc-json: Fix HRTBs for WherePredicate::BoundPredicate
Browse files Browse the repository at this point in the history
  • Loading branch information
Enselic committed May 4, 2022
1 parent b712135 commit 1f15ce5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/librustdoc/json/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
10 changes: 9 additions & 1 deletion src/rustdoc-json-types/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 1f15ce5

Please sign in to comment.