rust-lang / rustdoc-types

Rustdoc's JSON output interface
Apache License 2.0
28 stars 15 forks source link

New Release #8

Closed aDotInTheVoid closed 2 years ago

aDotInTheVoid commented 2 years ago

https://github.com/rust-lang/rust/pull/93803

aDotInTheVoid commented 2 years ago

Looks like they ended up spliting where and paramus in clean, so no change for us!

aDotInTheVoid commented 2 years ago

Although it might be worth thinking about putting all the bounds in where anyway, and none in params

aDotInTheVoid commented 2 years ago

Something like:

#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq)]
pub struct Generics {
    pub params: Vec<GenericParamDef>,
    pub where_predicates: Vec<WherePredicate>,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct GenericParamDef {
    pub name: String,
    pub kind: GenericParamDefKind,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum GenericParamDefKind {
    Lifetime,
    Type { default: Option<Type> },
    Const { ty: Type, default: Option<String> },
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum WherePredicate {
    BoundPredicate { ty: Type, bounds: Vec<GenericBound> },
    RegionPredicate { lifetime: String, bounds: Vec<GenericBound> },
    EqPredicate { lhs: Type, rhs: Term },
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum GenericBound {
    TraitBound {
        #[serde(rename = "trait")]
        trait_: Type,
        /// Used for HRTBs
        generic_params: Vec<GenericParamDef>,
        modifier: TraitBoundModifier,
    },
    Outlives(String),
}

so GenericParamDefKind doesn't store GenericBounds

aDotInTheVoid commented 2 years ago

https://github.com/rust-lang/rust/pull/96680