diff --git a/compiler/pavexc/src/compiler/analyses/application_state/cloning.rs b/compiler/pavexc/src/compiler/analyses/application_state/cloning.rs index 02782d988..437769d0d 100644 --- a/compiler/pavexc/src/compiler/analyses/application_state/cloning.rs +++ b/compiler/pavexc/src/compiler/analyses/application_state/cloning.rs @@ -61,7 +61,7 @@ pub(crate) fn runtime_singletons_can_be_cloned_if_needed<'a>( | Type::FunctionPointer(_) => { return None; } - Type::Path(_) | Type::Tuple(_) => {} + Type::Path(_) | Type::TypeAlias(_) | Type::Tuple(_) => {} Type::Generic(_) => unreachable!(), }; let InputParameterSource::Component(id) = source else { diff --git a/compiler/pavexc/src/compiler/analyses/application_state/mod.rs b/compiler/pavexc/src/compiler/analyses/application_state/mod.rs index 955dde895..bf31cffa7 100644 --- a/compiler/pavexc/src/compiler/analyses/application_state/mod.rs +++ b/compiler/pavexc/src/compiler/analyses/application_state/mod.rs @@ -226,7 +226,7 @@ fn field_name_candidate(ty_: &Type, strategy: NamingStrategy) -> String { fn _field_name_candidate(ty_: &Type, strategy: NamingStrategy, candidate: &mut String) { match ty_ { - Type::Path(path_type) => match strategy { + Type::Path(path_type) | Type::TypeAlias(path_type) => match strategy { NamingStrategy::LastSegment => { let last = path_type .base_type diff --git a/compiler/pavexc/src/compiler/analyses/processing_pipeline/codegen.rs b/compiler/pavexc/src/compiler/analyses/processing_pipeline/codegen.rs index 770834d54..16ed81d7f 100644 --- a/compiler/pavexc/src/compiler/analyses/processing_pipeline/codegen.rs +++ b/compiler/pavexc/src/compiler/analyses/processing_pipeline/codegen.rs @@ -393,6 +393,7 @@ impl CodegenedRequestHandlerPipeline { Type::Slice(_) | Type::Array(_) | Type::Path(_) + | Type::TypeAlias(_) | Type::Tuple(_) | Type::ScalarPrimitive(_) | Type::RawPointer(_) diff --git a/compiler/pavexc/src/compiler/analyses/processing_pipeline/pipeline.rs b/compiler/pavexc/src/compiler/analyses/processing_pipeline/pipeline.rs index 47e4a4331..cb2025cac 100644 --- a/compiler/pavexc/src/compiler/analyses/processing_pipeline/pipeline.rs +++ b/compiler/pavexc/src/compiler/analyses/processing_pipeline/pipeline.rs @@ -507,6 +507,7 @@ impl RequestHandlerPipeline { } } Type::Path(_) | + Type::TypeAlias(_) | Type::Tuple(_) | Type::Array(_) => { type2info.entry(ty.clone()).or_default().consumed_by.push(ConsumerInfo { middleware_index: index, component_id }); diff --git a/compiler/pavexc/src/compiler/analyses/user_components/annotations/mod.rs b/compiler/pavexc/src/compiler/analyses/user_components/annotations/mod.rs index 21751d439..2b204458f 100644 --- a/compiler/pavexc/src/compiler/analyses/user_components/annotations/mod.rs +++ b/compiler/pavexc/src/compiler/analyses/user_components/annotations/mod.rs @@ -33,8 +33,8 @@ use pavex_bp_schema::{CloningPolicy, Lifecycle, Lint, LintSetting}; use pavexc_attr_parser::{AnnotationKind, AnnotationProperties}; use rustdoc_ext::RustdocKindExt; use rustdoc_resolver::{ - resolve_free_function, rustdoc_method2callable, rustdoc_new_type_def2type, - rustdoc_type_alias2type, + TypeAliasResolution, resolve_free_function, rustdoc_method2callable, + rustdoc_new_type_def2type, rustdoc_type_alias2type, }; use rustdoc_types::{Item, ItemEnum}; @@ -521,7 +521,7 @@ fn rustdoc_item_def2type( Err(()) } }, - ItemEnum::TypeAlias(_) => match rustdoc_type_alias2type(item, krate, krate_collection) { + ItemEnum::TypeAlias(_) => match rustdoc_type_alias2type(item, krate, krate_collection, TypeAliasResolution::ResolveThrough) { Ok(t) => Ok(t), Err(e) => { type_resolution_error(e, item, diagnostics); diff --git a/compiler/pavexc/src/compiler/codegen/mod.rs b/compiler/pavexc/src/compiler/codegen/mod.rs index a2192c7ff..6a1613538 100644 --- a/compiler/pavexc/src/compiler/codegen/mod.rs +++ b/compiler/pavexc/src/compiler/codegen/mod.rs @@ -459,7 +459,7 @@ fn collect_callable_package_ids(package_ids: &mut IndexSet, c: &Calla fn collect_type_package_ids(package_ids: &mut IndexSet, t: &Type) { match t { - Type::Path(t) => { + Type::Path(t) | Type::TypeAlias(t) => { package_ids.insert(t.package_id.clone()); for generic in &t.generic_arguments { match generic { diff --git a/compiler/pavexc/src/compiler/codegen/state.rs b/compiler/pavexc/src/compiler/codegen/state.rs index 9571ee000..d756fd519 100644 --- a/compiler/pavexc/src/compiler/codegen/state.rs +++ b/compiler/pavexc/src/compiler/codegen/state.rs @@ -134,6 +134,7 @@ pub(super) fn get_application_state_new( Type::Slice(_) | Type::Array(_) | Type::Path(_) + | Type::TypeAlias(_) | Type::Tuple(_) | Type::ScalarPrimitive(_) | Type::RawPointer(_) diff --git a/compiler/pavexc/src/compiler/framework_rustdoc.rs b/compiler/pavexc/src/compiler/framework_rustdoc.rs index 4eb42fab0..57cf9a018 100644 --- a/compiler/pavexc/src/compiler/framework_rustdoc.rs +++ b/compiler/pavexc/src/compiler/framework_rustdoc.rs @@ -10,7 +10,7 @@ use crate::rustdoc::{CannotGetCrateData, CrateCollection}; use rustdoc_ext::GlobalItemId; use rustdoc_ir::{CallableInput, FnHeader, RustIdentifier, TraitMethod, TraitMethodPath}; use rustdoc_processor::queries::Crate; -use rustdoc_resolver::{GenericBindings, resolve_type}; +use rustdoc_resolver::{GenericBindings, TypeAliasResolution, resolve_type}; use super::app::PAVEX_VERSION; @@ -157,6 +157,7 @@ pub(crate) fn resolve_type_path(raw_path: &str, krate_collection: &CrateCollecti &global_id.package_id, krate_collection, &GenericBindings::default(), + TypeAliasResolution::ResolveThrough, ) .expect("Failed to resolve default generic type"); GenericArgument::TypeParameter(default) @@ -334,6 +335,7 @@ pub(crate) fn resolve_framework_trait_method( &krate.core.package_id, krate_collection, &generic_bindings, + TypeAliasResolution::ResolveThrough, ) .map_err(|e| { anyhow::anyhow!( @@ -357,6 +359,7 @@ pub(crate) fn resolve_framework_trait_method( &krate.core.package_id, krate_collection, &generic_bindings, + TypeAliasResolution::ResolveThrough, ) .map_err(|e| { anyhow::anyhow!( diff --git a/compiler/pavexc/src/compiler/path_parameters.rs b/compiler/pavexc/src/compiler/path_parameters.rs index d04bcadbe..eed092e04 100644 --- a/compiler/pavexc/src/compiler/path_parameters.rs +++ b/compiler/pavexc/src/compiler/path_parameters.rs @@ -266,7 +266,7 @@ fn must_be_a_plain_struct( extracted_type: &Type, ) -> Result { let error_suffix = match extracted_type { - Type::Path(t) => { + Type::Path(t) | Type::TypeAlias(t) => { let Some(item_id) = t.rustdoc_id else { unreachable!() }; diff --git a/compiler/pavexc/src/compiler/traits.rs b/compiler/pavexc/src/compiler/traits.rs index fcc25e226..9e2234b6e 100644 --- a/compiler/pavexc/src/compiler/traits.rs +++ b/compiler/pavexc/src/compiler/traits.rs @@ -5,7 +5,7 @@ use rustdoc_types::{GenericParamDefKind, ItemEnum, Type as RustdocType}; use crate::language::{PathType, Type}; use crate::rustdoc::{Crate, CrateCollection}; -use rustdoc_resolver::{GenericBindings, resolve_type}; +use rustdoc_resolver::{GenericBindings, TypeAliasResolution, resolve_type}; /// It returns an error if `type_` doesn't implement the specified trait. /// @@ -81,7 +81,7 @@ pub(crate) fn implements_trait( // We start by checking if there is a trait implementation for this type in the crate where the // type was defined. match type_ { - Type::Path(our_path_type) => { + Type::Path(our_path_type) | Type::TypeAlias(our_path_type) => { let type_definition_crate = get_crate_by_package_id(krate_collection, &our_path_type.package_id)?; let type_id = type_definition_crate @@ -102,6 +102,7 @@ pub(crate) fn implements_trait( &our_path_type.package_id, krate_collection, &generic_bindings, + TypeAliasResolution::ResolveThrough, )?; generic_bindings .types @@ -122,6 +123,7 @@ pub(crate) fn implements_trait( &our_path_type.package_id, krate_collection, &generic_bindings, + TypeAliasResolution::ResolveThrough, )?; if implements_trait(krate_collection, &type_, expected_trait)? { return Ok(true); diff --git a/rustdoc/rustdoc_ir/src/lib.rs b/rustdoc/rustdoc_ir/src/lib.rs index 77f8f488a..70ce01bb0 100644 --- a/rustdoc/rustdoc_ir/src/lib.rs +++ b/rustdoc/rustdoc_ir/src/lib.rs @@ -59,4 +59,7 @@ pub enum Type { FunctionPointer(FunctionPointer), /// An unassigned generic type parameter, e.g. `T`. Generic(Generic), + /// A type alias, preserving the alias identity rather than resolving through. + /// Contains the alias's path (package, base_type, generic arguments). + TypeAlias(PathType), } diff --git a/rustdoc/rustdoc_ir/src/render.rs b/rustdoc/rustdoc_ir/src/render.rs index d11bc4847..487bb4e09 100644 --- a/rustdoc/rustdoc_ir/src/render.rs +++ b/rustdoc/rustdoc_ir/src/render.rs @@ -134,7 +134,7 @@ impl Type { /// [`Type::render_with_inferred_lifetimes_into`], and [`Type::display_for_error_into`]. pub(crate) fn render_into(&self, config: &RenderConfig<'_>, buffer: &mut W) { match self { - Type::Path(t) => { + Type::Path(t) | Type::TypeAlias(t) => { match config.path { PathStyle::CrateLookup(id2name) => { let crate_name = id2name diff --git a/rustdoc/rustdoc_ir/src/type_.rs b/rustdoc/rustdoc_ir/src/type_.rs index fe3afffb5..a367ed138 100644 --- a/rustdoc/rustdoc_ir/src/type_.rs +++ b/rustdoc/rustdoc_ir/src/type_.rs @@ -60,7 +60,8 @@ impl Type { /// `t`. You are not required to bind all of them. pub fn bind_generic_type_parameters(&self, bindings: &HashMap) -> Type { match self { - Type::Path(t) => { + Type::Path(t) | Type::TypeAlias(t) => { + let is_alias = matches!(self, Type::TypeAlias(_)); let mut bound_generics = Vec::with_capacity(t.generic_arguments.len()); for generic in &t.generic_arguments { let bound_generic = match generic { @@ -71,13 +72,14 @@ impl Type { }; bound_generics.push(bound_generic); } - Type::Path(PathType { + let path = PathType { package_id: t.package_id.clone(), // Should we set this to `None`? rustdoc_id: t.rustdoc_id, base_type: t.base_type.clone(), generic_arguments: bound_generics, - }) + }; + if is_alias { Type::TypeAlias(path) } else { Type::Path(path) } } Type::Reference(r) => Type::Reference(TypeReference { is_mutable: r.is_mutable, @@ -131,7 +133,7 @@ impl Type { /// Check if a type can be used as a "template"—i.e. if it has any unassigned generic parameters. pub fn is_a_template(&self) -> bool { match self { - Type::Path(path) => path.generic_arguments.iter().any(|arg| match arg { + Type::Path(path) | Type::TypeAlias(path) => path.generic_arguments.iter().any(|arg| match arg { GenericArgument::TypeParameter(g) => g.is_a_template(), GenericArgument::Lifetime( GenericLifetimeParameter::Static @@ -164,7 +166,7 @@ impl Type { fn _unassigned_generic_type_parameters(&self, set: &mut IndexSet) { match self { - Type::Path(path) => { + Type::Path(path) | Type::TypeAlias(path) => { for arg in &path.generic_arguments { match arg { GenericArgument::TypeParameter(g) => { @@ -225,7 +227,8 @@ impl Type { } use Type::*; match (concrete_type, self) { - (Path(concrete_path), Path(templated_path)) => { + (Path(concrete_path), Path(templated_path)) + | (TypeAlias(concrete_path), TypeAlias(templated_path)) => { templated_path._is_a_resolved_path_type_template_for(concrete_path, bindings) } (Slice(concrete_slice), Slice(templated_slice)) => templated_slice @@ -331,7 +334,8 @@ impl Type { ) -> bool { use Type::*; match (self, other) { - (Path(self_path), Path(other_path)) => { + (Path(self_path), Path(other_path)) + | (TypeAlias(self_path), TypeAlias(other_path)) => { self_path._is_equivalent_to(other_path, self_id_gen, other_id_gen) } (Slice(self_slice), Slice(other_slice)) => self_slice.element_type._is_equivalent_to( @@ -404,7 +408,7 @@ impl Type { /// E.g. `&'_ str` and `&str` would both return `true`. `&'static str` or `&'a str` wouldn't. pub fn has_implicit_lifetime_parameters(&self) -> bool { match self { - Type::Path(path) => path.generic_arguments.iter().any(|arg| match arg { + Type::Path(path) | Type::TypeAlias(path) => path.generic_arguments.iter().any(|arg| match arg { GenericArgument::TypeParameter(g) => g.has_implicit_lifetime_parameters(), GenericArgument::Lifetime(GenericLifetimeParameter::Inferred) => true, GenericArgument::Lifetime( @@ -448,7 +452,7 @@ impl Type { /// the provided named lifetime. pub fn set_implicit_lifetimes(&mut self, inferred_lifetime: String) { match self { - Type::Path(path) => { + Type::Path(path) | Type::TypeAlias(path) => { for arg in path.generic_arguments.iter_mut() { match arg { GenericArgument::Lifetime(lifetime) => { @@ -499,7 +503,7 @@ impl Type { /// You don't need to provide a mapping for lifetimes that you don't want to rename. pub fn rename_lifetime_parameters(&mut self, original2renamed: &IndexMap) { match self { - Type::Path(t) => { + Type::Path(t) | Type::TypeAlias(t) => { for arg in t.generic_arguments.iter_mut() { match arg { GenericArgument::TypeParameter(tp) => { @@ -561,7 +565,7 @@ impl Type { fn _lifetime_parameters(&self, set: &mut IndexSet) { match self { - Type::Path(path) => { + Type::Path(path) | Type::TypeAlias(path) => { for arg in &path.generic_arguments { match arg { GenericArgument::TypeParameter(g) => { @@ -606,7 +610,7 @@ impl Type { fn _named_lifetime_parameters(&self, set: &mut IndexSet) { match self { - Type::Path(path) => { + Type::Path(path) | Type::TypeAlias(path) => { for arg in &path.generic_arguments { match arg { GenericArgument::TypeParameter(g) => { @@ -726,7 +730,8 @@ impl Type { } match self { - Type::Path(t) => { + Type::Path(t) | Type::TypeAlias(t) => { + let is_alias = matches!(self, Type::TypeAlias(_)); let generic_arguments = t .generic_arguments .iter() @@ -743,12 +748,13 @@ impl Type { ), }) .collect(); - Type::Path(PathType { + let path = PathType { package_id: t.package_id.clone(), rustdoc_id: t.rustdoc_id, base_type: t.base_type.clone(), generic_arguments, - }) + }; + if is_alias { Type::TypeAlias(path) } else { Type::Path(path) } } Type::Reference(r) => Type::Reference(TypeReference { is_mutable: r.is_mutable, @@ -818,7 +824,7 @@ impl Type { impl Debug for Type { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match self { - Type::Path(t) => write!(f, "{t:?}"), + Type::Path(t) | Type::TypeAlias(t) => write!(f, "{t:?}"), Type::Reference(r) => write!(f, "{r:?}"), Type::Tuple(t) => write!(f, "{t:?}"), Type::ScalarPrimitive(s) => write!(f, "{s:?}"), diff --git a/rustdoc/rustdoc_resolver/src/free_fn.rs b/rustdoc/rustdoc_resolver/src/free_fn.rs index 830f5e8ca..de7fd74c2 100644 --- a/rustdoc/rustdoc_resolver/src/free_fn.rs +++ b/rustdoc/rustdoc_resolver/src/free_fn.rs @@ -11,7 +11,7 @@ use rustdoc_processor::indexing::CrateIndexer; use rustdoc_processor::queries::Crate; use crate::errors::*; -use crate::resolve_type::resolve_type; +use crate::resolve_type::{TypeAliasResolution, resolve_type}; /// Convert a free function from `rustdoc_types` into a [`FreeFunction`]. pub fn resolve_free_function( @@ -35,6 +35,7 @@ pub fn resolve_free_function( &krate.core.package_id, krate_collection, &Default::default(), + TypeAliasResolution::ResolveThrough, ) { Ok(t) => { inputs.push(CallableInput { @@ -62,6 +63,7 @@ pub fn resolve_free_function( &krate.core.package_id, krate_collection, &Default::default(), + TypeAliasResolution::ResolveThrough, ) { Ok(t) => Some(t), Err(e) => { diff --git a/rustdoc/rustdoc_resolver/src/lib.rs b/rustdoc/rustdoc_resolver/src/lib.rs index 71bf99482..37dd6cc57 100644 --- a/rustdoc/rustdoc_resolver/src/lib.rs +++ b/rustdoc/rustdoc_resolver/src/lib.rs @@ -13,7 +13,7 @@ mod type_def; pub use errors::*; pub use free_fn::resolve_free_function; pub use method::rustdoc_method2callable; -pub use resolve_type::resolve_type; +pub use resolve_type::{TypeAliasResolution, resolve_type}; pub use type_def::{rustdoc_new_type_def2type, rustdoc_type_alias2type}; use ahash::HashMap; diff --git a/rustdoc/rustdoc_resolver/src/method.rs b/rustdoc/rustdoc_resolver/src/method.rs index 03c643cdf..f007a0c63 100644 --- a/rustdoc/rustdoc_resolver/src/method.rs +++ b/rustdoc/rustdoc_resolver/src/method.rs @@ -16,7 +16,7 @@ use rustdoc_processor::queries::Crate; use crate::GenericBindings; use crate::errors::*; -use crate::resolve_type::resolve_type; +use crate::resolve_type::{TypeAliasResolution, resolve_type}; /// Convert a method item retrieved from `rustdoc`'s JSON output to Pavex's internal /// representation for callables (i.e. methods and functions). @@ -50,6 +50,7 @@ pub fn rustdoc_method2callable( &krate.core.package_id, krate_collection, &generic_bindings, + TypeAliasResolution::ResolveThrough, ) { Ok(t) => t, Err(e) => { @@ -110,6 +111,7 @@ pub fn rustdoc_method2callable( &krate.core.package_id, krate_collection, &generic_bindings, + TypeAliasResolution::ResolveThrough, ) else { todo!() }; @@ -178,6 +180,7 @@ pub fn rustdoc_method2callable( &krate.core.package_id, krate_collection, &generic_bindings, + TypeAliasResolution::ResolveThrough, ) { Ok(t) => { inputs.push(CallableInput { @@ -205,6 +208,7 @@ pub fn rustdoc_method2callable( &krate.core.package_id, krate_collection, &generic_bindings, + TypeAliasResolution::ResolveThrough, ) { Ok(t) => Some(t), Err(e) => { diff --git a/rustdoc/rustdoc_resolver/src/resolve_type.rs b/rustdoc/rustdoc_resolver/src/resolve_type.rs index b2c26e529..20d266a7e 100644 --- a/rustdoc/rustdoc_resolver/src/resolve_type.rs +++ b/rustdoc/rustdoc_resolver/src/resolve_type.rs @@ -16,6 +16,15 @@ use rustdoc_processor::indexing::CrateIndexer; use crate::GenericBindings; use crate::errors::*; +/// Controls whether `resolve_type` resolves through type aliases or preserves them. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum TypeAliasResolution { + /// Resolve through type aliases, returning the underlying type (current default). + ResolveThrough, + /// Stop at type aliases, returning `Type::TypeAlias(PathType)`. + Preserve, +} + /// Convert a `rustdoc_types::Type` into a `rustdoc_ir::Type`, recursively resolving /// through type aliases and substituting generic bindings. pub fn resolve_type( @@ -25,12 +34,14 @@ pub fn resolve_type( used_by_package_id: &PackageId, krate_collection: &CrateCollection, generic_bindings: &GenericBindings, + alias_resolution: TypeAliasResolution, ) -> Result { _resolve_type( type_, used_by_package_id, krate_collection, generic_bindings, + alias_resolution, ) .map_err(|details| TypeResolutionError { ty: type_.to_owned(), @@ -45,6 +56,7 @@ fn _resolve_type( used_by_package_id: &PackageId, krate_collection: &CrateCollection, generic_bindings: &GenericBindings, + alias_resolution: TypeAliasResolution, ) -> Result { match type_ { RustdocType::ResolvedPath(rustdoc_types::Path { @@ -94,6 +106,11 @@ fn _resolve_type( // The generic parameters that have been defined for the type alias. // E.g. `T` in `type Foo = Bar;` let generic_param_defs = &type_alias.generics.params; + + // When preserving, we need to resolve the generic arguments + // for the alias's own identity, but we don't resolve through. + let mut resolved_alias_generics = vec![]; + for (i, generic_param_def) in generic_param_defs.iter().enumerate() { match &generic_param_def.kind { GenericParamDefKind::Type { default, .. } => { @@ -105,6 +122,7 @@ fn _resolve_type( used_by_package_id, krate_collection, generic_bindings, + alias_resolution, ) .map_err(|source| { TypeResolutionErrorDetails::TypePartResolutionError( @@ -138,6 +156,7 @@ fn _resolve_type( &global_type_id.package_id, krate_collection, generic_bindings, + alias_resolution, ) .map_err(|source| { TypeResolutionErrorDetails::TypePartResolutionError(Box::new( @@ -162,7 +181,8 @@ fn _resolve_type( }; alias_generic_bindings .types - .insert(generic_param_def.name.to_string(), generic_type); + .insert(generic_param_def.name.to_string(), generic_type.clone()); + resolved_alias_generics.push(GenericArgument::TypeParameter(generic_type)); } GenericParamDefKind::Lifetime { .. } => { let provided_arg = generic_args.and_then(|v| v.get(i)); @@ -190,7 +210,10 @@ fn _resolve_type( .to_owned(); alias_generic_bindings .lifetimes - .insert(generic_param_def.name.to_string(), lifetime); + .insert(generic_param_def.name.to_string(), lifetime.clone()); + resolved_alias_generics.push(GenericArgument::Lifetime( + GenericLifetimeParameter::from_name(lifetime), + )); } GenericParamDefKind::Const { .. } => { return Err(TypeResolutionErrorDetails::UnsupportedConstGeneric( @@ -201,11 +224,23 @@ fn _resolve_type( } } } + + if alias_resolution == TypeAliasResolution::Preserve { + let alias_path = PathType { + package_id: global_type_id.package_id().to_owned(), + rustdoc_id: Some(global_type_id.rustdoc_item_id), + base_type: base_type.to_vec(), + generic_arguments: resolved_alias_generics, + }; + return Ok(Type::TypeAlias(alias_path)); + } + let type_ = resolve_type( &type_alias.type_, &global_type_id.package_id, krate_collection, &alias_generic_bindings, + alias_resolution, ) .map_err(|source| { TypeResolutionErrorDetails::TypePartResolutionError(Box::new( @@ -277,6 +312,7 @@ fn _resolve_type( used_by_package_id, krate_collection, generic_bindings, + alias_resolution, ) .map_err(|source| { TypeResolutionErrorDetails::TypePartResolutionError( @@ -296,6 +332,7 @@ fn _resolve_type( &global_type_id.package_id, krate_collection, generic_bindings, + alias_resolution, ) .map_err(|source| { TypeResolutionErrorDetails::TypePartResolutionError( @@ -363,6 +400,7 @@ fn _resolve_type( used_by_package_id, krate_collection, generic_bindings, + alias_resolution, ) .map_err(|source| { TypeResolutionErrorDetails::TypePartResolutionError(Box::new( @@ -394,6 +432,7 @@ fn _resolve_type( used_by_package_id, krate_collection, generic_bindings, + alias_resolution, ) .map_err(|source| { TypeResolutionErrorDetails::TypePartResolutionError(Box::new( @@ -418,6 +457,7 @@ fn _resolve_type( used_by_package_id, krate_collection, generic_bindings, + alias_resolution, ) .map_err(|source| { TypeResolutionErrorDetails::TypePartResolutionError(Box::new( @@ -443,6 +483,7 @@ fn _resolve_type( used_by_package_id, krate_collection, generic_bindings, + alias_resolution, ) .map_err(|source| { TypeResolutionErrorDetails::TypePartResolutionError(Box::new( @@ -475,7 +516,7 @@ fn _resolve_type( .iter() .enumerate() .map(|(i, (_, ty))| { - resolve_type(ty, used_by_package_id, krate_collection, generic_bindings) + resolve_type(ty, used_by_package_id, krate_collection, generic_bindings, alias_resolution) .map_err(|source| { TypeResolutionErrorDetails::TypePartResolutionError(Box::new( TypePartResolutionError { @@ -492,7 +533,7 @@ fn _resolve_type( .output .as_ref() .map(|ty| { - resolve_type(ty, used_by_package_id, krate_collection, generic_bindings) + resolve_type(ty, used_by_package_id, krate_collection, generic_bindings, alias_resolution) .map_err(|source| { TypeResolutionErrorDetails::TypePartResolutionError(Box::new( TypePartResolutionError { @@ -528,6 +569,7 @@ fn _resolve_type( used_by_package_id, krate_collection, generic_bindings, + alias_resolution, ) .map_err(|source| { TypeResolutionErrorDetails::TypePartResolutionError(Box::new( diff --git a/rustdoc/rustdoc_resolver/src/type_def.rs b/rustdoc/rustdoc_resolver/src/type_def.rs index d353940e4..81a880c94 100644 --- a/rustdoc/rustdoc_resolver/src/type_def.rs +++ b/rustdoc/rustdoc_resolver/src/type_def.rs @@ -10,7 +10,7 @@ use rustdoc_processor::queries::Crate; use crate::GenericBindings; use crate::errors::{TypeResolutionError, UnsupportedConstGeneric}; -use crate::resolve_type::resolve_type; +use crate::resolve_type::{TypeAliasResolution, resolve_type}; /// Convert an enum or a struct definition from the JSON documentation /// for a crate into our own representation for types. @@ -69,6 +69,7 @@ pub fn rustdoc_type_alias2type( item: &Item, krate: &Crate, krate_collection: &CrateCollection, + alias_resolution: TypeAliasResolution, ) -> Result { let ItemEnum::TypeAlias(inner) = &item.inner else { unreachable!( @@ -81,6 +82,7 @@ pub fn rustdoc_type_alias2type( &krate.core.package_id, krate_collection, &GenericBindings::default(), + alias_resolution, )?; Ok(resolved) }