diff --git a/src/adapter/mod.rs b/src/adapter/mod.rs index 62af68f..aaac2cf 100644 --- a/src/adapter/mod.rs +++ b/src/adapter/mod.rs @@ -129,9 +129,7 @@ impl<'a> Adapter<'a> for RustdocAdapter<'a> { properties::resolve_implemented_trait_property(contexts, property_name) } "Static" => properties::resolve_static_property(contexts, property_name), - "RawType" | "ResolvedPathType" | "PrimitiveType" - if matches!(property_name.as_ref(), "name") => - { + "RawType" | "ResolvedPathType" if matches!(property_name.as_ref(), "name") => { // fields from "RawType" properties::resolve_raw_type_property(contexts, property_name) } @@ -231,7 +229,7 @@ impl<'a> Adapter<'a> for RustdocAdapter<'a> { let coerce_to_type = coerce_to_type.clone(); match type_name.as_ref() { "Item" | "Variant" | "FunctionLike" | "Importable" | "ImplOwner" | "RawType" - | "ResolvedPathType" | "GlobalValue" => { + | "GlobalValue" => { resolve_coercion_with(contexts, move |vertex| { let actual_type_name = vertex.typename(); @@ -241,9 +239,6 @@ impl<'a> Adapter<'a> for RustdocAdapter<'a> { "PlainVariant" | "TupleVariant" | "StructVariant" ), "ImplOwner" => matches!(actual_type_name, "Struct" | "Enum"), - "ResolvedPathType" => { - matches!(actual_type_name, "ResolvedPathType" | "ImplementedTrait") - } "GlobalValue" => matches!(actual_type_name, "Constant" | "Static",), _ => { // The remaining types are final (don't have any subtypes) diff --git a/src/adapter/vertex.rs b/src/adapter/vertex.rs index 4a84187..53e2b30 100644 --- a/src/adapter/vertex.rs +++ b/src/adapter/vertex.rs @@ -70,8 +70,7 @@ impl<'a> Typename for Vertex<'a> { VertexKind::ImplementedTrait(..) => "ImplementedTrait", VertexKind::RawType(ty) => match ty { rustdoc_types::Type::ResolvedPath { .. } => "ResolvedPathType", - rustdoc_types::Type::Primitive(..) => "PrimitiveType", - _ => "OtherType", + _ => "RawType", }, VertexKind::FunctionParameter(..) => "FunctionParameter", VertexKind::FunctionAbi(..) => "FunctionAbi", diff --git a/src/rustdoc_schema.graphql b/src/rustdoc_schema.graphql index 9efb36d..8c898d6 100644 --- a/src/rustdoc_schema.graphql +++ b/src/rustdoc_schema.graphql @@ -126,6 +126,9 @@ type StructField implements Item { # edges from Item span: Span attribute: [Attribute!] + + # own edges + raw_type: RawType } """ @@ -843,3 +846,33 @@ type AssociatedConstant implements Item { span: Span attribute: [Attribute!] } + +""" +A type represented in the "raw" rustdoc JSON representation. + +Copiously detailed, but not the easiest to use due to its complexity. + +This interface is a temporary, perma-unstable type intended to be used +only until the rustdoc JSON format is stabilized and until subsequently +we are able to design a better, more permanent representation for +Rust types in this schema. + +https://docs.rs/rustdoc-types/latest/rustdoc_types/enum.Type.html +""" +interface RawType { + name: String! +} + +""" +Represents a struct, enum, or trait. + +https://docs.rs/rustdoc-types/latest/rustdoc_types/enum.Type.html#variant.ResolvedPath +""" +type ResolvedPathType implements RawType { + """ + The fully-qualified canonical name of the type. + + For example: "core::marker::PhantomData" or "std::marker::PhantomData" + """ + name: String! +}