diff --git a/.config/hakari.toml b/.config/hakari.toml index 6541383eb..0def1d2cc 100644 --- a/.config/hakari.toml +++ b/.config/hakari.toml @@ -31,3 +31,6 @@ third-party = [ # `rustls` entirely. { name = "rustls" } ] + +[final-excludes] +workspace-members = ["rustdoc_types", "rustdoc_ir", "rustdoc_ext", "rustdoc_processor"] diff --git a/Cargo.lock b/Cargo.lock index c770e6c31..198dca605 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4242,7 +4242,6 @@ dependencies = [ name = "rustdoc_ext" version = "0.2.10" dependencies = [ - "px_workspace_hack", "rustdoc_types", ] @@ -4255,7 +4254,6 @@ dependencies = [ "bimap", "guppy", "indexmap", - "px_workspace_hack", "rustdoc_types", "serde", "syn", @@ -4278,7 +4276,6 @@ dependencies = [ "itertools 0.14.0", "num_cpus", "once_cell", - "px_workspace_hack", "r2d2", "r2d2_sqlite", "rayon", @@ -4302,7 +4299,6 @@ name = "rustdoc_types" version = "0.2.10" dependencies = [ "bincode", - "px_workspace_hack", "rkyv", "rustc-hash", "serde", diff --git a/compiler/pavexc/src/compiler/analyses/application_state/mod.rs b/compiler/pavexc/src/compiler/analyses/application_state/mod.rs index 4f1d0cac5..db44f3df2 100644 --- a/compiler/pavexc/src/compiler/analyses/application_state/mod.rs +++ b/compiler/pavexc/src/compiler/analyses/application_state/mod.rs @@ -19,7 +19,9 @@ use super::{ }; use crate::{ compiler::app::GENERATED_APP_PACKAGE_ID, - language::{Callable, GenericArgument, InvocationStyle, PathTypeExt, Type}, + language::{ + Callable, CallableInput, GenericArgument, InvocationStyle, ParameterName, PathTypeExt, Type, + }, rustdoc::CrateCollection, }; use indexmap::{IndexMap, IndexSet}; @@ -193,17 +195,21 @@ impl ApplicationState { inputs: { // Ensure that the inputs are sorted by name. let b = self.bindings.iter().collect::>(); - b.into_values().cloned().collect() + b.into_iter() + .map(|(name, type_)| CallableInput { + name: ParameterName::new(name.to_string()), + type_: type_.clone(), + }) + .collect() }, invocation_style: InvocationStyle::StructLiteral { - field_names: self - .bindings - .iter() - .map(|(ident, type_)| (ident.to_string(), type_.to_owned())) - .collect(), extra_field2default_value: Default::default(), }, source_coordinates: None, + abi: rustdoc_types::Abi::Rust, + is_unsafe: false, + is_c_variadic: false, + symbol_name: None, } } diff --git a/compiler/pavexc/src/compiler/analyses/call_graph/application_state.rs b/compiler/pavexc/src/compiler/analyses/call_graph/application_state.rs index 014adaa80..1a180bfd3 100644 --- a/compiler/pavexc/src/compiler/analyses/call_graph/application_state.rs +++ b/compiler/pavexc/src/compiler/analyses/call_graph/application_state.rs @@ -23,8 +23,8 @@ use crate::compiler::analyses::framework_items::FrameworkItemDb; use crate::compiler::app::GENERATED_APP_PACKAGE_ID; use crate::compiler::computation::{Computation, MatchResultVariant}; use crate::language::{ - Callable, FQPath, FQPathSegment, GenericArgument, InvocationStyle, PathType, PathTypeExt, - Type, + Callable, CallableInput, FQPath, FQPathSegment, GenericArgument, InvocationStyle, + ParameterName, PathType, PathTypeExt, Type, }; use crate::rustdoc::{CORE_PACKAGE_ID_REPR, CrateCollection}; @@ -165,9 +165,13 @@ pub(crate) fn application_state_call_graph( qualified_self: None, package_id: PackageId::new(CORE_PACKAGE_ID_REPR), }, - inputs: vec![application_state.type_().into()], + inputs: vec![CallableInput { name: ParameterName::new("_0".into()), type_: application_state.type_().into() }], invocation_style: InvocationStyle::FunctionCall, source_coordinates: None, + abi: rustdoc_types::Abi::Rust, + is_unsafe: false, + is_c_variadic: false, + symbol_name: None, } }; let err_wrapper = { @@ -188,9 +192,13 @@ pub(crate) fn application_state_call_graph( qualified_self: None, package_id: PackageId::new(CORE_PACKAGE_ID_REPR), }, - inputs: vec![error_enum.clone().into()], + inputs: vec![CallableInput { name: ParameterName::new("_0".into()), type_: error_enum.clone().into() }], invocation_style: InvocationStyle::FunctionCall, source_coordinates: None, + abi: rustdoc_types::Abi::Rust, + is_unsafe: false, + is_c_variadic: false, + symbol_name: None, } }; component_db.get_or_intern_transformer( @@ -275,9 +283,13 @@ pub(crate) fn application_state_call_graph( package_id: PackageId::new(GENERATED_APP_PACKAGE_ID), }, output: Some(error_enum.clone().into()), - inputs: vec![error_type.to_owned()], + inputs: vec![CallableInput { name: ParameterName::new("_0".into()), type_: error_type.to_owned() }], invocation_style: InvocationStyle::FunctionCall, source_coordinates: None, + abi: rustdoc_types::Abi::Rust, + is_unsafe: false, + is_c_variadic: false, + symbol_name: None, }; let transformer_id = component_db.get_or_intern_transformer( computation_db.get_or_intern(error_variant_constructor.clone()), diff --git a/compiler/pavexc/src/compiler/analyses/call_graph/borrow_checker/clone.rs b/compiler/pavexc/src/compiler/analyses/call_graph/borrow_checker/clone.rs index 131bd206a..b70f783c6 100644 --- a/compiler/pavexc/src/compiler/analyses/call_graph/borrow_checker/clone.rs +++ b/compiler/pavexc/src/compiler/analyses/call_graph/borrow_checker/clone.rs @@ -13,8 +13,8 @@ use crate::compiler::analyses::user_components::ScopeId; use crate::compiler::computation::Computation; use crate::compiler::utils::resolve_type_path; use crate::language::{ - Callable, FQPath, FQPathSegment, FQQualifiedSelf, InvocationStyle, Lifetime, PathType, - PathTypeExt, Type, TypeReference, + Callable, CallableInput, FQPath, FQPathSegment, FQQualifiedSelf, InvocationStyle, Lifetime, + ParameterName, PathType, PathTypeExt, Type, TypeReference, }; use crate::rustdoc::CrateCollection; @@ -75,13 +75,20 @@ pub(super) fn get_clone_component_id( takes_self_as_ref: true, output: Some(output.clone()), path: type_clone_path, - inputs: vec![Type::Reference(TypeReference { - is_mutable: false, - lifetime: Lifetime::Elided, - inner: Box::new(output), - })], + inputs: vec![CallableInput { + name: ParameterName::new("_0".into()), + type_: Type::Reference(TypeReference { + is_mutable: false, + lifetime: Lifetime::Elided, + inner: Box::new(output), + }), + }], invocation_style: InvocationStyle::FunctionCall, source_coordinates: None, + abi: rustdoc_types::Abi::Rust, + is_unsafe: false, + is_c_variadic: false, + symbol_name: None, }; let clone_computation_id = diff --git a/compiler/pavexc/src/compiler/analyses/call_graph/borrow_checker/move_while_borrowed.rs b/compiler/pavexc/src/compiler/analyses/call_graph/borrow_checker/move_while_borrowed.rs index 665dafdde..6699b45f7 100644 --- a/compiler/pavexc/src/compiler/analyses/call_graph/borrow_checker/move_while_borrowed.rs +++ b/compiler/pavexc/src/compiler/analyses/call_graph/borrow_checker/move_while_borrowed.rs @@ -75,7 +75,7 @@ pub(super) fn move_while_borrowed( .inputs_that_output_borrows_immutably_from() .iter() .map(|&i| { - let t = &callable.inputs[i]; + let t = &callable.inputs[i].type_; if let Type::Reference(r) = t { r.inner.deref().to_owned() } else { @@ -87,7 +87,7 @@ pub(super) fn move_while_borrowed( .inputs_with_lifetime_tied_with_output() .iter() .map(|&i| { - let t = &callable.inputs[i]; + let t = &callable.inputs[i].type_; if let Type::Reference(r) = t { r.inner.deref().to_owned() } else { diff --git a/compiler/pavexc/src/compiler/analyses/call_graph/core_graph.rs b/compiler/pavexc/src/compiler/analyses/call_graph/core_graph.rs index e4e665547..420c1403f 100644 --- a/compiler/pavexc/src/compiler/analyses/call_graph/core_graph.rs +++ b/compiler/pavexc/src/compiler/analyses/call_graph/core_graph.rs @@ -191,25 +191,25 @@ where // We need to recursively build the input types for all our compute components; if let CallGraphNode::Compute { component_id, .. } = call_graph[current_index].clone() { let component = component_db.hydrated_component(component_id, computation_db); - let input_types = match component { + let input_types: Vec = match component { HydratedComponent::Constructor(constructor) => { - constructor.input_types().to_vec() + constructor.input_types().into_iter().cloned().collect() } HydratedComponent::ConfigType(..) | HydratedComponent::PrebuiltType(..) => { vec![] } - HydratedComponent::RequestHandler(r) => r.input_types().to_vec(), - HydratedComponent::PostProcessingMiddleware(pp) => pp.input_types().to_vec(), - HydratedComponent::PreProcessingMiddleware(pp) => pp.input_types().to_vec(), + HydratedComponent::RequestHandler(r) => r.input_types().into_iter().cloned().collect(), + HydratedComponent::PostProcessingMiddleware(pp) => pp.input_types().into_iter().cloned().collect(), + HydratedComponent::PreProcessingMiddleware(pp) => pp.input_types().into_iter().cloned().collect(), HydratedComponent::Transformer(c, info) => { - let mut inputs = c.input_types().to_vec(); + let mut inputs: Vec<_> = c.input_types().into_iter().cloned().collect(); // The component we are transforming must have been added to the graph // before the transformer. inputs.remove(info.input_index); inputs } HydratedComponent::WrappingMiddleware(mw) => { - let mut input_types = mw.input_types().to_vec(); + let mut input_types: Vec<_> = mw.input_types().into_iter().cloned().collect(); let next_type = &input_types[mw.next_input_index()]; if !next_type.unassigned_generic_type_parameters().is_empty() { // If we haven't assigned a concrete type to the `Next` type parameter, @@ -220,7 +220,7 @@ where input_types } HydratedComponent::ErrorObserver(eo) => { - let mut inputs: Vec<_> = eo.input_types().to_vec(); + let mut inputs: Vec<_> = eo.input_types().into_iter().cloned().collect(); inputs.remove(eo.error_input_index); inputs } diff --git a/compiler/pavexc/src/compiler/analyses/call_graph/dependency_graph.rs b/compiler/pavexc/src/compiler/analyses/call_graph/dependency_graph.rs index d6dc10021..15a402979 100644 --- a/compiler/pavexc/src/compiler/analyses/call_graph/dependency_graph.rs +++ b/compiler/pavexc/src/compiler/analyses/call_graph/dependency_graph.rs @@ -124,16 +124,16 @@ impl DependencyGraph { { let component = component_db.hydrated_component(component_id, computation_db); let component_scope = component_db.scope_id(component_id); - let input_types = match component { + let input_types: Vec = match component { HydratedComponent::Constructor(constructor) => { - constructor.input_types().to_vec() + constructor.input_types().into_iter().cloned().collect() } HydratedComponent::ConfigType(..) | HydratedComponent::PrebuiltType(..) => { vec![] } - HydratedComponent::RequestHandler(r) => r.input_types().to_vec(), + HydratedComponent::RequestHandler(r) => r.input_types().into_iter().cloned().collect(), HydratedComponent::PostProcessingMiddleware(pp) => { - let mut input_types = pp.input_types().to_vec(); + let mut input_types: Vec<_> = pp.input_types().into_iter().cloned().collect(); // `Response` doesn't matter when it comes to verifying that we don't // have cyclic dependencies, so we can skip it. input_types @@ -141,26 +141,26 @@ impl DependencyGraph { input_types } HydratedComponent::Transformer(t, info) => { - let mut input_types = t.input_types().to_vec(); + let mut input_types: Vec<_> = t.input_types().into_iter().cloned().collect(); // We have already added the transformed -> transformer edge at this stage. input_types.remove(info.input_index); input_types } HydratedComponent::WrappingMiddleware(mw) => { - let mut input_types = mw.input_types().to_vec(); + let mut input_types: Vec<_> = mw.input_types().into_iter().cloned().collect(); // `Next` doesn't matter when it comes to verifying that we don't // have cyclic dependencies, so we can skip it. input_types.remove(mw.next_input_index()); input_types } HydratedComponent::ErrorObserver(eo) => { - let mut input_types = eo.input_types().to_vec(); + let mut input_types: Vec<_> = eo.input_types().into_iter().cloned().collect(); // `Error` doesn't matter when it comes to verifying that we don't // have cyclic dependencies, so we can skip it. input_types.remove(eo.error_input_index); input_types } - HydratedComponent::PreProcessingMiddleware(p) => p.input_types().to_vec(), + HydratedComponent::PreProcessingMiddleware(p) => p.input_types().into_iter().cloned().collect(), }; for input_type in input_types { if let Some((constructor_id, _)) = constructible_db.get( diff --git a/compiler/pavexc/src/compiler/analyses/call_graph/request_scoped.rs b/compiler/pavexc/src/compiler/analyses/call_graph/request_scoped.rs index 30efb0b67..efc0bd265 100644 --- a/compiler/pavexc/src/compiler/analyses/call_graph/request_scoped.rs +++ b/compiler/pavexc/src/compiler/analyses/call_graph/request_scoped.rs @@ -15,7 +15,9 @@ use crate::compiler::analyses::components::{ use crate::compiler::analyses::computations::ComputationDb; use crate::compiler::analyses::constructibles::ConstructibleDb; use crate::compiler::computation::Computation; -use crate::language::{Callable, FQPath, FQPathSegment, InvocationStyle, Type}; +use crate::language::{ + Callable, CallableInput, FQPath, FQPathSegment, InvocationStyle, ParameterName, Type, +}; use crate::rustdoc::CrateCollection; /// Build an [`OrderedCallGraph`] for a computation that gets trigger on a per-request basis @@ -204,9 +206,13 @@ fn augment_preprocessing_graph( qualified_self: None, package_id: processing_path.package_id.clone(), }, - inputs: vec![output_type.to_owned()], + inputs: vec![CallableInput { name: ParameterName::new("_0".into()), type_: output_type.to_owned() }], invocation_style: InvocationStyle::FunctionCall, source_coordinates: None, + abi: rustdoc_types::Abi::Rust, + is_unsafe: false, + is_c_variadic: false, + symbol_name: None, }; component_db.get_or_intern_transformer( computation_db.get_or_intern(wrapper), diff --git a/compiler/pavexc/src/compiler/analyses/components/db/mod.rs b/compiler/pavexc/src/compiler/analyses/components/db/mod.rs index 0ba261ec2..3bf0f687b 100644 --- a/compiler/pavexc/src/compiler/analyses/components/db/mod.rs +++ b/compiler/pavexc/src/compiler/analyses/components/db/mod.rs @@ -1172,10 +1172,10 @@ impl ComponentDb { error_handlers_db.insert(e, scope_id, error_handler_user_component_id); } Err(e) => { - if let Some(error_type_ref) = + if let Some(error_input) = error_handler_callable.inputs.get(error_ref_input_index) { - error_handlers_db.insert_invalid(error_type_ref, scope_id); + error_handlers_db.insert_invalid(&error_input.type_, scope_id); } Self::invalid_error_handler( e, @@ -2019,7 +2019,7 @@ impl ComponentDb { .output_type() .unwrap() .to_owned(); - let transformer_input_type = &computation.input_types()[info.input_index]; + let transformer_input_type = computation.input_types()[info.input_index]; let unbound_transformed_output = match info.transformation_mode { ConsumptionMode::Move => unbound_transformed_output, ConsumptionMode::SharedBorrow => Type::Reference(TypeReference { diff --git a/compiler/pavexc/src/compiler/analyses/components/hydrated.rs b/compiler/pavexc/src/compiler/analyses/components/hydrated.rs index ed9466b00..ac984b89d 100644 --- a/compiler/pavexc/src/compiler/analyses/components/hydrated.rs +++ b/compiler/pavexc/src/compiler/analyses/components/hydrated.rs @@ -22,17 +22,17 @@ pub(crate) enum HydratedComponent<'a> { } impl<'a> HydratedComponent<'a> { - pub(crate) fn input_types(&self) -> Cow<'_, [Type]> { + pub(crate) fn input_types(&self) -> Vec<&Type> { match self { HydratedComponent::Constructor(c) => c.input_types(), - HydratedComponent::RequestHandler(r) => Cow::Borrowed(r.input_types()), + HydratedComponent::RequestHandler(r) => r.input_types(), HydratedComponent::Transformer(c, ..) => c.input_types(), - HydratedComponent::WrappingMiddleware(c) => Cow::Borrowed(c.input_types()), - HydratedComponent::PostProcessingMiddleware(p) => Cow::Borrowed(p.input_types()), - HydratedComponent::PreProcessingMiddleware(p) => Cow::Borrowed(p.input_types()), - HydratedComponent::ErrorObserver(eo) => Cow::Borrowed(eo.input_types()), + HydratedComponent::WrappingMiddleware(c) => c.input_types(), + HydratedComponent::PostProcessingMiddleware(p) => p.input_types(), + HydratedComponent::PreProcessingMiddleware(p) => p.input_types(), + HydratedComponent::ErrorObserver(eo) => eo.input_types(), HydratedComponent::ConfigType(..) | HydratedComponent::PrebuiltType(_) => { - Cow::Owned(vec![]) + vec![] } } } diff --git a/compiler/pavexc/src/compiler/analyses/constructibles.rs b/compiler/pavexc/src/compiler/analyses/constructibles.rs index d97e6999f..c999b460a 100644 --- a/compiler/pavexc/src/compiler/analyses/constructibles.rs +++ b/compiler/pavexc/src/compiler/analyses/constructibles.rs @@ -164,8 +164,8 @@ impl ConstructibleDb { let input_types = { let mut input_types: Vec> = resolved_component .input_types() - .iter() - .map(|i| Some(i.to_owned())) + .into_iter() + .map(|i| Some(i.clone())) .collect(); match &resolved_component { // `Next` is a special case: it's not a pre-determined type, but rather @@ -474,7 +474,7 @@ impl ConstructibleDb { } let component = component_db.hydrated_component(component_id, computation_db); let component_scope = component_db.scope_id(component_id); - for input_type in component.input_types().iter() { + for input_type in component.input_types() { if let Some((input_constructor_id, _)) = self.get(component_scope, input_type, component_db.scope_graph()) && component_db.lifecycle(input_constructor_id) == Lifecycle::RequestScoped @@ -516,13 +516,13 @@ impl ConstructibleDb { }; let mut queue = eo .input_types() - .iter() + .into_iter() .enumerate() .filter_map(|(i, input)| { if i == eo.error_input_index { return None; } - Some((input.to_owned(), IndexSet::::new())) + Some((input.clone(), IndexSet::::new())) }) .collect_vec(); 'inner: while let Some((input, mut dependency_chain)) = queue.pop() { @@ -560,8 +560,8 @@ impl ConstructibleDb { // We just break to avoid infinite loops. continue 'inner; } - for input in c.input_types().iter() { - queue.push((input.to_owned(), dependency_chain.clone())); + for input in c.input_types() { + queue.push((input.clone(), dependency_chain.clone())); } } } diff --git a/compiler/pavexc/src/compiler/analyses/into_error.rs b/compiler/pavexc/src/compiler/analyses/into_error.rs index 75f57ced8..15893167f 100644 --- a/compiler/pavexc/src/compiler/analyses/into_error.rs +++ b/compiler/pavexc/src/compiler/analyses/into_error.rs @@ -6,7 +6,8 @@ use crate::compiler::analyses::computations::ComputationDb; use crate::compiler::analyses::user_components::ScopeId; use crate::compiler::computation::{Computation, MatchResultVariant}; use crate::language::{ - Callable, FQPath, FQPathSegment, InvocationStyle, PathTypeExt, Type, + Callable, CallableInput, FQPath, FQPathSegment, InvocationStyle, ParameterName, PathTypeExt, + Type, }; /// Returns the [`ComponentId`] for a transformer component that calls `pavex::Error::new` on the @@ -53,9 +54,13 @@ pub(super) fn register_error_new_transformer( takes_self_as_ref: true, output: Some(pavex_error.clone().into()), path: pavex_error_new_path, - inputs: vec![error.to_owned()], + inputs: vec![CallableInput { name: ParameterName::new("_0".into()), type_: error.to_owned() }], invocation_style: InvocationStyle::FunctionCall, source_coordinates: None, + abi: rustdoc_types::Abi::Rust, + is_unsafe: false, + is_c_variadic: false, + symbol_name: None, }; let computation_id = diff --git a/compiler/pavexc/src/compiler/analyses/processing_pipeline/pipeline.rs b/compiler/pavexc/src/compiler/analyses/processing_pipeline/pipeline.rs index 56cdb54d9..7bebff1b6 100644 --- a/compiler/pavexc/src/compiler/analyses/processing_pipeline/pipeline.rs +++ b/compiler/pavexc/src/compiler/analyses/processing_pipeline/pipeline.rs @@ -24,8 +24,8 @@ use crate::compiler::computation::Computation; use crate::compiler::utils::LifetimeGenerator; use crate::diagnostic::{AnnotatedSource, CompilerDiagnostic, HelpWithSnippet}; use crate::language::{ - Callable, GenericArgument, GenericLifetimeParameter, InvocationStyle, Lifetime, - PathType, PathTypeExt, Type, TypeReference, + Callable, CallableInput, GenericArgument, GenericLifetimeParameter, InvocationStyle, Lifetime, + ParameterName, PathType, PathTypeExt, Type, TypeReference, }; use crate::rustdoc::CrateCollection; @@ -698,19 +698,22 @@ impl RequestHandlerPipeline { output: Some(next_state_type.clone().into()), inputs: next_state_parameters .iter() - .map(|input| input.type_.clone()) + .map(|input| CallableInput { + name: ParameterName::new(input.ident.clone()), + type_: input.type_.clone(), + }) .collect(), invocation_style: InvocationStyle::StructLiteral { - field_names: next_state_parameters - .iter() - .map(|input| (input.ident.clone(), input.type_.clone())) - .collect::>(), // TODO: remove when TAIT stabilises extra_field2default_value: { BTreeMap::from([("next".into(), stage_names[wrapping_id + 1].clone())]) }, }, source_coordinates: None, + abi: rustdoc_types::Abi::Rust, + is_unsafe: false, + is_c_variadic: false, + symbol_name: None, }; let next_state_callable_id = computation_db.get_or_intern(next_state_constructor); let next_state_scope_id = component_db.scope_id(middleware_id); @@ -733,7 +736,7 @@ impl RequestHandlerPipeline { else { unreachable!() }; - let next_input = &mw.input_types()[mw.next_input_index()]; + let next_input = mw.input_types()[mw.next_input_index()]; let next_generic_parameters = next_input.unassigned_generic_type_parameters(); #[cfg(debug_assertions)] 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 e2b4df8c8..affc67525 100644 --- a/compiler/pavexc/src/compiler/analyses/user_components/annotations/mod.rs +++ b/compiler/pavexc/src/compiler/analyses/user_components/annotations/mod.rs @@ -31,9 +31,9 @@ use crate::{ }, diagnostic::{ComponentKind, DiagnosticSink, Registration}, language::{ - Callable, FQGenericArgument, FQPath, FQPathSegment, FQQualifiedSelf, Generic, - GenericArgument, GenericLifetimeParameter, InvocationStyle, PathType, - ResolvedPathLifetime, Type, + Callable, CallableInput, FQGenericArgument, FQPath, FQPathSegment, FQQualifiedSelf, + Generic, GenericArgument, GenericLifetimeParameter, InvocationStyle, ParameterName, + PathType, ResolvedPathLifetime, Type, }, rustdoc::{AnnotationCoordinates, Crate, CrateCollection, GlobalItemId, ImplInfo}, }; @@ -647,7 +647,7 @@ fn rustdoc_free_fn2callable( }; let mut inputs = Vec::new(); - for (parameter_index, (_, input_ty)) in inner.sig.inputs.iter().enumerate() { + for (parameter_index, (param_name, input_ty)) in inner.sig.inputs.iter().enumerate() { match resolve_type( input_ty, &krate.core.package_id, @@ -655,7 +655,10 @@ fn rustdoc_free_fn2callable( &Default::default(), ) { Ok(t) => { - inputs.push(t); + inputs.push(CallableInput { + name: ParameterName::new(param_name.clone()), + type_: t, + }); } Err(e) => { return Err(InputParameterResolutionError { @@ -693,6 +696,12 @@ fn rustdoc_free_fn2callable( None => None, }; + let symbol_name = item.attrs.iter().find_map(|attr| match attr { + rustdoc_types::Attribute::NoMangle => item.name.clone(), + rustdoc_types::Attribute::ExportName(name) => Some(name.clone()), + _ => None, + }); + Ok(Callable { is_async: inner.header.is_async, // It's a free function, there's no `self`. @@ -705,6 +714,10 @@ fn rustdoc_free_fn2callable( rustdoc_item_id: item.id, package_id: krate.core.package_id.clone(), }), + abi: inner.header.abi.clone(), + is_unsafe: inner.header.is_unsafe, + is_c_variadic: inner.sig.is_c_variadic, + symbol_name, }) } @@ -847,7 +860,7 @@ fn rustdoc_method2callable( let mut inputs = Vec::new(); let mut takes_self_as_ref = false; - for (parameter_index, (_, parameter_type)) in inner.sig.inputs.iter().enumerate() { + for (parameter_index, (param_name, parameter_type)) in inner.sig.inputs.iter().enumerate() { if parameter_index == 0 { // The first parameter might be `&self` or `&mut self`. // This is important to know for carrying out further analysis doing the line, @@ -867,7 +880,10 @@ fn rustdoc_method2callable( &generic_bindings, ) { Ok(t) => { - inputs.push(t); + inputs.push(CallableInput { + name: ParameterName::new(param_name.clone()), + type_: t, + }); } Err(e) => { return Err(InputParameterResolutionError { @@ -905,6 +921,12 @@ fn rustdoc_method2callable( None => None, }; + let symbol_name = method_item.attrs.iter().find_map(|attr| match attr { + rustdoc_types::Attribute::NoMangle => method_item.name.clone(), + rustdoc_types::Attribute::ExportName(name) => Some(name.clone()), + _ => None, + }); + Ok(Callable { is_async: inner.header.is_async, takes_self_as_ref, @@ -916,5 +938,9 @@ fn rustdoc_method2callable( rustdoc_item_id: method_item.id, package_id: krate.core.package_id.clone(), }), + abi: inner.header.abi.clone(), + is_unsafe: inner.header.is_unsafe, + is_c_variadic: inner.sig.is_c_variadic, + symbol_name, }) } diff --git a/compiler/pavexc/src/compiler/codegen/mod.rs b/compiler/pavexc/src/compiler/codegen/mod.rs index 1828186f4..9aef369b3 100644 --- a/compiler/pavexc/src/compiler/codegen/mod.rs +++ b/compiler/pavexc/src/compiler/codegen/mod.rs @@ -449,7 +449,7 @@ fn collect_call_graph_package_ids<'a>( fn collect_callable_package_ids(package_ids: &mut IndexSet, c: &Callable) { package_ids.insert(c.path.package_id.clone()); - for input in &c.inputs { + for input in c.input_types() { collect_type_package_ids(package_ids, input); } if let Some(output) = c.output.as_ref() { diff --git a/compiler/pavexc/src/compiler/codegen_utils.rs b/compiler/pavexc/src/compiler/codegen_utils.rs index cf54311cb..2c2091891 100644 --- a/compiler/pavexc/src/compiler/codegen_utils.rs +++ b/compiler/pavexc/src/compiler/codegen_utils.rs @@ -179,7 +179,7 @@ pub(crate) fn codegen_call( }; let mut invocation = match &callable.invocation_style { InvocationStyle::FunctionCall => { - let parameters = callable.inputs.iter().map(|i| { + let parameters = callable.input_types().map(|i| { match variable_bindings.get(i) { Some(tokens) => tokens, None => { @@ -200,14 +200,13 @@ pub(crate) fn codegen_call( } } InvocationStyle::StructLiteral { - field_names, extra_field2default_value, } => { - let fields = field_names + let fields = callable.inputs .iter() - .map(|(field_name, field_type)| { - let field_name = format_ident!("{}", field_name); - let binding = match variable_bindings.get(field_type) { + .map(|input| { + let field_name = format_ident!("{}", input.name.as_str()); + let binding = match variable_bindings.get(&input.type_) { Some(tokens) => tokens, None => { use std::fmt::Write as _; @@ -217,7 +216,8 @@ pub(crate) fn codegen_call( let _ = writeln!(&mut msg, "- {ty:?}`"); } panic!( - "There is no variable with type {field_type:?} in scope.\nTypes of bound variables:\n{msg}", + "There is no variable with type {:?} in scope.\nTypes of bound variables:\n{msg}", + input.type_, ) } }; diff --git a/compiler/pavexc/src/compiler/component/constructor.rs b/compiler/pavexc/src/compiler/component/constructor.rs index f540c55ea..20c070b2b 100644 --- a/compiler/pavexc/src/compiler/component/constructor.rs +++ b/compiler/pavexc/src/compiler/component/constructor.rs @@ -1,5 +1,3 @@ -use std::borrow::Cow; - use crate::compiler::analyses::framework_items::FrameworkItemDb; use crate::compiler::component::CannotTakeMutReferenceError; use indexmap::IndexSet; @@ -87,7 +85,7 @@ impl<'a> Constructor<'a> { let output_unassigned_generic_parameters = output_type.unassigned_generic_type_parameters(); let mut free_parameters = IndexSet::new(); - for input in c.input_types().as_ref() { + for input in c.input_types() { free_parameters.extend( input .unassigned_generic_type_parameters() @@ -120,7 +118,7 @@ impl Constructor<'_> { } /// The inputs types used by this constructor. - pub fn input_types(&self) -> Cow<'_, [Type]> { + pub fn input_types(&self) -> Vec<&Type> { self.0.input_types() } diff --git a/compiler/pavexc/src/compiler/component/error_handler.rs b/compiler/pavexc/src/compiler/component/error_handler.rs index 489f94878..e13a9d999 100644 --- a/compiler/pavexc/src/compiler/component/error_handler.rs +++ b/compiler/pavexc/src/compiler/component/error_handler.rs @@ -28,7 +28,7 @@ impl ErrorHandler { Self::check_generic_params( &error_handler, error_ref_input_index, - &error_handler.inputs[error_ref_input_index], + &error_handler.inputs[error_ref_input_index].type_, )?; Ok(Self { callable: error_handler, @@ -46,10 +46,9 @@ impl ErrorHandler { let error_type = get_err_variant(fallible_callable.output.as_ref().unwrap()); let (error_ref_input_index, error_ref) = error_handler - .inputs - .iter() + .input_types() .find_position(|t| { - if let Type::Reference(t) = t { + if let Type::Reference(t) = *t { !t.is_mutable && (t.lifetime != Lifetime::Static) && (t.inner.as_ref() == error_type || t.inner.as_ref() == pavex_error) @@ -80,7 +79,7 @@ impl ErrorHandler { /// This is a **reference** to the error type returned by the fallible callable /// that this is error handler is associated with. pub(crate) fn error_type_ref(&self) -> &Type { - &self.callable.inputs[self.error_ref_input_index] + &self.callable.inputs[self.error_ref_input_index].type_ } /// Replace all unassigned generic type parameters in this error handler with the @@ -122,7 +121,7 @@ impl ErrorHandler { let error_ref_unassigned_generic_parameters = error_ref.unassigned_generic_type_parameters(); let mut free_parameters = IndexSet::new(); - for (i, input) in h.inputs.iter().enumerate() { + for (i, input) in h.input_types().enumerate() { if i == error_ref_index { continue; } diff --git a/compiler/pavexc/src/compiler/component/error_observer.rs b/compiler/pavexc/src/compiler/component/error_observer.rs index f2676f533..b0ecbdaeb 100644 --- a/compiler/pavexc/src/compiler/component/error_observer.rs +++ b/compiler/pavexc/src/compiler/component/error_observer.rs @@ -29,8 +29,7 @@ impl<'a> ErrorObserver<'a> { // TODO: return a more specific error if the error observer takes the error input // parameter by value instead of taking it by reference. let error_input_index = error_observer - .inputs - .iter() + .input_types() .position(|i| i == pavex_error_ref) .ok_or_else( || ErrorObserverValidationError::DoesNotTakeErrorReferenceAsInput { @@ -46,7 +45,7 @@ impl<'a> ErrorObserver<'a> { // because they might/will be dictated by the fallible callable that this error handler // is associated with. let mut free_parameters = IndexSet::new(); - for input in &error_observer.inputs { + for input in error_observer.input_types() { free_parameters.extend(input.unassigned_generic_type_parameters()); } if !free_parameters.is_empty() { @@ -69,8 +68,8 @@ impl<'a> ErrorObserver<'a> { } } - pub fn input_types(&self) -> &[Type] { - self.callable.inputs.as_slice() + pub fn input_types(&self) -> Vec<&Type> { + self.callable.input_types().collect() } } diff --git a/compiler/pavexc/src/compiler/component/mod.rs b/compiler/pavexc/src/compiler/component/mod.rs index 283537600..11541ba74 100644 --- a/compiler/pavexc/src/compiler/component/mod.rs +++ b/compiler/pavexc/src/compiler/component/mod.rs @@ -38,7 +38,7 @@ pub(crate) struct CannotTakeMutReferenceError { impl CannotTakeMutReferenceError { pub(crate) fn check_callable(c: &Callable) -> Result<(), Self> { - for (i, input_type) in c.inputs.iter().enumerate() { + for (i, input_type) in c.input_types().enumerate() { if let Type::Reference(input_type) = input_type && input_type.is_mutable { diff --git a/compiler/pavexc/src/compiler/component/post_processing_middleware.rs b/compiler/pavexc/src/compiler/component/post_processing_middleware.rs index c519d1158..f2d99ceef 100644 --- a/compiler/pavexc/src/compiler/component/post_processing_middleware.rs +++ b/compiler/pavexc/src/compiler/component/post_processing_middleware.rs @@ -48,7 +48,7 @@ impl<'a> PostProcessingMiddleware<'a> { // We verify that exactly one of the input parameters is a `Response`. { let response_parameters: Vec<_> = - c.inputs.iter().filter(|t| *t == response_type).collect(); + c.input_types().filter(|t| *t == response_type).collect(); if response_parameters.is_empty() { return Err(MustTakeResponseAsInputParameter); } @@ -59,7 +59,7 @@ impl<'a> PostProcessingMiddleware<'a> { // We make sure that the callable doesn't have any unassigned generic type parameters. let mut free_parameters = IndexSet::new(); - for input in c.inputs.iter() { + for input in c.input_types() { free_parameters.extend(input.unassigned_generic_type_parameters()); } if !free_parameters.is_empty() { @@ -75,15 +75,14 @@ impl<'a> PostProcessingMiddleware<'a> { self.callable.output.as_ref().unwrap() } - pub fn input_types(&self) -> &[Type] { - self.callable.inputs.as_slice() + pub fn input_types(&self) -> Vec<&Type> { + self.callable.input_types().collect() } /// Returns the index of the input parameter that is a `Response`. pub fn response_input_index(&self, response_type: &Type) -> usize { self.callable - .inputs - .iter() + .input_types() .position(|t| t == response_type) .unwrap() } diff --git a/compiler/pavexc/src/compiler/component/pre_processing_middleware.rs b/compiler/pavexc/src/compiler/component/pre_processing_middleware.rs index 51bfcd497..9f8ba1365 100644 --- a/compiler/pavexc/src/compiler/component/pre_processing_middleware.rs +++ b/compiler/pavexc/src/compiler/component/pre_processing_middleware.rs @@ -45,7 +45,7 @@ impl<'a> PreProcessingMiddleware<'a> { // We make sure that the callable doesn't have any unassigned generic type parameters. let mut free_parameters = IndexSet::new(); - for input in c.inputs.iter() { + for input in c.input_types() { free_parameters.extend(input.unassigned_generic_type_parameters()); } if !free_parameters.is_empty() { @@ -61,8 +61,8 @@ impl<'a> PreProcessingMiddleware<'a> { self.callable.output.as_ref().unwrap() } - pub fn input_types(&self) -> &[Type] { - self.callable.inputs.as_slice() + pub fn input_types(&self) -> Vec<&Type> { + self.callable.input_types().collect() } pub fn into_owned(self) -> PreProcessingMiddleware<'static> { diff --git a/compiler/pavexc/src/compiler/component/request_handler.rs b/compiler/pavexc/src/compiler/component/request_handler.rs index 5e1785ee1..330b44aaa 100644 --- a/compiler/pavexc/src/compiler/component/request_handler.rs +++ b/compiler/pavexc/src/compiler/component/request_handler.rs @@ -33,7 +33,7 @@ impl<'a> RequestHandler<'a> { } let mut free_parameters = IndexSet::new(); - for input in c.inputs.iter() { + for input in c.input_types() { free_parameters.extend(input.unassigned_generic_type_parameters()); } if !free_parameters.is_empty() { @@ -51,8 +51,8 @@ impl<'a> RequestHandler<'a> { self.callable.output.as_ref().unwrap() } - pub fn input_types(&self) -> &[Type] { - self.callable.inputs.as_slice() + pub fn input_types(&self) -> Vec<&Type> { + self.callable.input_types().collect() } pub fn into_owned(self) -> RequestHandler<'static> { diff --git a/compiler/pavexc/src/compiler/component/wrapping_middleware.rs b/compiler/pavexc/src/compiler/component/wrapping_middleware.rs index 4b1923436..5ffae17ca 100644 --- a/compiler/pavexc/src/compiler/component/wrapping_middleware.rs +++ b/compiler/pavexc/src/compiler/component/wrapping_middleware.rs @@ -47,7 +47,7 @@ impl<'a> WrappingMiddleware<'a> { // We verify that exactly one of the input parameters is a `Next<_>`. let next_type = { - let next_parameters: Vec<_> = c.inputs.iter().filter(|t| is_next(t)).collect(); + let next_parameters: Vec<_> = c.input_types().filter(|t| is_next(t)).collect(); if next_parameters.is_empty() { return Err(MustTakeNextAsInputParameter); } @@ -77,7 +77,7 @@ impl<'a> WrappingMiddleware<'a> { // apart from the one used in Next. let allowed_unassigned_generic_parameters = next_type.unassigned_generic_type_parameters(); let mut free_parameters = IndexSet::new(); - for input in c.inputs.iter() { + for input in c.input_types() { free_parameters.extend( input .unassigned_generic_type_parameters() @@ -98,18 +98,18 @@ impl<'a> WrappingMiddleware<'a> { self.callable.output.as_ref().unwrap() } - pub fn input_types(&self) -> &[Type] { - self.callable.inputs.as_slice() + pub fn input_types(&self) -> Vec<&Type> { + self.callable.input_types().collect() } /// Returns the index of the input parameter that is a `Next<_>`. pub fn next_input_index(&self) -> usize { - self.callable.inputs.iter().position(is_next).unwrap() + self.callable.input_types().position(is_next).unwrap() } /// Returns the type of the input parameter that is a `Next<_>`. pub fn next_input_type(&self) -> &Type { - &self.callable.inputs[self.next_input_index()] + &self.callable.inputs[self.next_input_index()].type_ } pub fn into_owned(self) -> WrappingMiddleware<'static> { diff --git a/compiler/pavexc/src/compiler/computation/mod.rs b/compiler/pavexc/src/compiler/computation/mod.rs index 00b83cce4..49c5399da 100644 --- a/compiler/pavexc/src/compiler/computation/mod.rs +++ b/compiler/pavexc/src/compiler/computation/mod.rs @@ -58,11 +58,11 @@ impl Computation<'_> { } /// The types required as input parameters by this computation. - pub fn input_types(&self) -> Cow<'_, [Type]> { + pub fn input_types(&self) -> Vec<&Type> { match self { - Computation::Callable(c) => Cow::Borrowed(c.inputs.as_slice()), - Computation::MatchResult(m) => Cow::Owned(vec![m.input.clone()]), - Computation::PrebuiltType(_) => Cow::Owned(vec![]), + Computation::Callable(c) => c.input_types().collect(), + Computation::MatchResult(m) => vec![&m.input], + Computation::PrebuiltType(_) => vec![], } } diff --git a/compiler/pavexc/src/compiler/resolvers.rs b/compiler/pavexc/src/compiler/resolvers.rs index aa8ea5617..669e73998 100644 --- a/compiler/pavexc/src/compiler/resolvers.rs +++ b/compiler/pavexc/src/compiler/resolvers.rs @@ -11,9 +11,9 @@ use rustdoc_types::{GenericArg, GenericArgs, GenericParamDefKind, ItemEnum, Type use tracing_log_error::log_error; use crate::language::{ - Array, Callable, CallableItem, FQGenericArgument, FQPath, FQPathSegment, FQPathType, Generic, - GenericArgument, GenericLifetimeParameter, InvocationStyle, PathType, - RawPointer, Type, Slice, Tuple, TypeReference, UnknownPath, UnknownPrimitive, + Array, Callable, CallableInput, CallableItem, FQGenericArgument, FQPath, FQPathSegment, + FQPathType, Generic, GenericArgument, GenericLifetimeParameter, InvocationStyle, ParameterName, + PathType, RawPointer, Type, Slice, Tuple, TypeReference, UnknownPath, UnknownPrimitive, }; use crate::rustdoc::{CannotGetCrateData, CrateCollection, ResolvedItem}; use rustdoc_ext::RustdocKindExt; @@ -742,7 +742,7 @@ pub(crate) fn resolve_callable( let mut resolved_parameter_types = Vec::with_capacity(decl.inputs.len()); let mut takes_self_as_ref = false; - for (parameter_index, (_, parameter_type)) in decl.inputs.iter().enumerate() { + for (parameter_index, (parameter_name, parameter_type)) in decl.inputs.iter().enumerate() { if parameter_index == 0 { // The first parameter might be `&self` or `&mut self`. // This is important to know for carrying out further analysis doing the line, @@ -760,7 +760,10 @@ pub(crate) fn resolve_callable( krate_collection, &generic_bindings, ) { - Ok(p) => resolved_parameter_types.push(p), + Ok(p) => resolved_parameter_types.push(CallableInput { + name: ParameterName::new(parameter_name.clone()), + type_: p, + }), Err(e) => { return Err(InputParameterResolutionError { parameter_type: parameter_type.to_owned(), @@ -894,6 +897,15 @@ pub(crate) fn resolve_callable( } }; + let symbol_name = callable_item.item.attrs.iter().find_map(|attr| match attr { + rustdoc_types::Attribute::NoMangle => callable_item + .item + .name + .clone(), + rustdoc_types::Attribute::ExportName(name) => Some(name.clone()), + _ => None, + }); + let callable = Callable { is_async: header.is_async, takes_self_as_ref, @@ -902,6 +914,10 @@ pub(crate) fn resolve_callable( inputs: resolved_parameter_types, invocation_style, source_coordinates: Some(callable_item.item_id.clone()), + abi: header.abi.clone(), + is_unsafe: header.is_unsafe, + is_c_variadic: decl.is_c_variadic, + symbol_name, }; Ok(callable) } diff --git a/compiler/pavexc/src/language/callable.rs b/compiler/pavexc/src/language/callable.rs index 2b934fc45..135915b64 100644 --- a/compiler/pavexc/src/language/callable.rs +++ b/compiler/pavexc/src/language/callable.rs @@ -11,6 +11,51 @@ use indexmap::IndexSet; use crate::language::{FQPath, Lifetime, Type}; use crate::rustdoc::GlobalItemId; +/// A validated parameter name that is guaranteed to be a valid Rust identifier. +#[derive(Clone, Hash, Eq, PartialEq, Debug)] +pub struct ParameterName(String); + +impl ParameterName { + /// Create a new `ParameterName`, validating that it is a valid Rust identifier. + /// + /// # Panics + /// Panics if `name` is not a valid Rust identifier (`[a-zA-Z_][a-zA-Z0-9_]*`). + pub fn new(name: String) -> Self { + assert!( + Self::is_valid_identifier(&name), + "Invalid parameter name: `{name}`" + ); + Self(name) + } + + /// Returns `true` if `name` matches `[a-zA-Z_][a-zA-Z0-9_]*`. + fn is_valid_identifier(name: &str) -> bool { + let mut chars = name.chars(); + match chars.next() { + Some(c) if c.is_ascii_alphabetic() || c == '_' => {} + _ => return false, + } + chars.all(|c| c.is_ascii_alphanumeric() || c == '_') + } + + pub fn as_str(&self) -> &str { + &self.0 + } +} + +impl std::fmt::Display for ParameterName { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(&self.0) + } +} + +/// A named input parameter of a [`Callable`]. +#[derive(Clone, Hash, Eq, PartialEq, Debug)] +pub struct CallableInput { + pub name: ParameterName, + pub type_: Type, +} + #[derive(Clone, Hash, Eq, PartialEq)] /// A Rust type that can be invoked—e.g. a function, a method, a struct literal constructor. pub struct Callable { @@ -34,10 +79,10 @@ pub struct Callable { /// /// E.g. `std::vec::Vec::new` for `Vec::new()`. pub path: FQPath, - /// The types of the callable input parameter types. + /// The input parameters of the callable. /// The list is ordered, matching the order in the callable declaration—this is relevant /// to ensure correct invocations. - pub inputs: Vec, + pub inputs: Vec, /// Rust supports different types of callables which rely on different invocation syntax. /// See [`InvocationStyle`] for more details. pub invocation_style: InvocationStyle, @@ -50,6 +95,14 @@ pub struct Callable { /// callables that don't exist yet—i.e. that we will code-generate into the new server SDK /// crate. pub source_coordinates: Option, + /// The ABI (calling convention) of this callable. + pub abi: rustdoc_types::Abi, + /// `true` if the callable is declared as `unsafe`. + pub is_unsafe: bool, + /// `true` if the callable accepts C-style variadic arguments (`...`). + pub is_c_variadic: bool, + /// The export symbol name, from `#[no_mangle]` or `#[export_name = "..."]`. + pub symbol_name: Option, } impl Callable { @@ -57,6 +110,11 @@ impl Callable { /// concrete types specified in `bindings`. /// /// The newly "bound" callable will be returned. + /// Returns an iterator over the types of the input parameters. + pub fn input_types(&self) -> impl Iterator + '_ { + self.inputs.iter().map(|i| &i.type_) + } + pub fn bind_generic_type_parameters( &self, bindings: &HashMap, @@ -65,7 +123,10 @@ impl Callable { let inputs = self .inputs .iter() - .map(|t| t.bind_generic_type_parameters(bindings)) + .map(|i| CallableInput { + name: i.name.clone(), + type_: i.type_.bind_generic_type_parameters(bindings), + }) .collect(); let output = self .output @@ -84,7 +145,7 @@ impl Callable { #[allow(unused)] pub(crate) fn unassigned_generic_type_parameters(&self) -> IndexSet { let mut result = IndexSet::new(); - for input in &self.inputs { + for input in self.input_types() { result.extend(input.unassigned_generic_type_parameters()); } if let Some(output) = &self.output { @@ -123,10 +184,10 @@ impl Callable { let mut elided_output_lifetime: String = "elided".to_string(); let mut inputs = self.inputs.clone(); for input in inputs.iter_mut() { - if input.has_implicit_lifetime_parameters() { + if input.type_.has_implicit_lifetime_parameters() { elided_output_lifetime = { let mut named_lifetime_parameters = BTreeSet::new(); - for input in &self.inputs { + for input in self.input_types() { named_lifetime_parameters.extend(input.named_lifetime_parameters()); } named_lifetime_parameters.extend(output.named_lifetime_parameters()); @@ -142,11 +203,11 @@ impl Callable { } }; - input.set_implicit_lifetimes(elided_output_lifetime.clone()); + input.type_.set_implicit_lifetimes(elided_output_lifetime.clone()); break; } - let named_params = input.named_lifetime_parameters(); + let named_params = input.type_.named_lifetime_parameters(); if !named_params.is_empty() { elided_output_lifetime = named_params.first().unwrap().to_string(); break; @@ -157,13 +218,9 @@ impl Callable { output.set_implicit_lifetimes(elided_output_lifetime); Self { - is_async: self.is_async, - takes_self_as_ref: self.takes_self_as_ref, output: Some(output), - path: self.path.clone(), inputs, - invocation_style: self.invocation_style.clone(), - source_coordinates: self.source_coordinates.clone(), + ..self.clone() } } @@ -180,7 +237,7 @@ impl Callable { let output_lifetime_parameters = output.named_lifetime_parameters(); let mut borrowed_indexes = vec![]; - for (i, input) in c.inputs.iter().enumerate() { + for (i, input) in c.input_types().enumerate() { let Type::Reference(ref_ty) = input else { continue; }; @@ -209,7 +266,7 @@ impl Callable { let output_lifetime_parameters = output.named_lifetime_parameters(); let mut borrowed_indexes = vec![]; - for (i, input) in c.inputs.iter().enumerate() { + for (i, input) in c.input_types().enumerate() { if input .named_lifetime_parameters() .intersection(&output_lifetime_parameters) @@ -234,8 +291,6 @@ pub enum InvocationStyle { /// ` { : , ...}` /// An available option to build structs **if all their fields are public**. StructLiteral { - /// A map associating each field name to its type. - field_names: BTreeMap, /// Rust does not have default values for struct fields. /// This is hack to allow us to inject the `next` field in the state we generate for /// `Next` where the `next` field is not part of the struct definition and it must @@ -251,7 +306,7 @@ impl Callable { let mut buffer = String::new(); write!(&mut buffer, "{}", self.path).unwrap(); write!(&mut buffer, "(").unwrap(); - let mut inputs = self.inputs.iter().peekable(); + let mut inputs = self.input_types().peekable(); while let Some(input) = inputs.next() { write!(&mut buffer, "{}", input.render_type(package_ids2names)).unwrap(); if inputs.peek().is_some() { @@ -270,7 +325,7 @@ impl std::fmt::Debug for Callable { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.path)?; write!(f, "(")?; - let mut inputs = self.inputs.iter().peekable(); + let mut inputs = self.input_types().peekable(); while let Some(input) = inputs.next() { write!(f, "{input:?}")?; if inputs.peek().is_some() { diff --git a/compiler/pavexc/src/language/mod.rs b/compiler/pavexc/src/language/mod.rs index 1d3c6f6cc..4223527e6 100644 --- a/compiler/pavexc/src/language/mod.rs +++ b/compiler/pavexc/src/language/mod.rs @@ -1,4 +1,4 @@ -pub(crate) use callable::{Callable, InvocationStyle}; +pub(crate) use callable::{Callable, CallableInput, InvocationStyle, ParameterName}; pub(crate) use callable_path::{CallPath, InvalidCallPath}; pub(crate) use fq_path::{ CallableItem, FQGenericArgument, FQPath, FQPathSegment, FQPathType, FQQualifiedSelf, PathKind, diff --git a/rustdoc/rustdoc_ext/Cargo.toml b/rustdoc/rustdoc_ext/Cargo.toml index d5b163b9d..00a1c0cba 100644 --- a/rustdoc/rustdoc_ext/Cargo.toml +++ b/rustdoc/rustdoc_ext/Cargo.toml @@ -9,5 +9,3 @@ version.workspace = true [dependencies] rustdoc-types = { workspace = true } - -px_workspace_hack = { version = "0.1", path = "../../px_workspace_hack" } diff --git a/rustdoc/rustdoc_ir/Cargo.toml b/rustdoc/rustdoc_ir/Cargo.toml index 07d156380..1c82c368a 100644 --- a/rustdoc/rustdoc_ir/Cargo.toml +++ b/rustdoc/rustdoc_ir/Cargo.toml @@ -18,4 +18,3 @@ syn = { workspace = true } rustdoc-types = { workspace = true } thiserror = { workspace = true } tracing = { workspace = true } -px_workspace_hack = { version = "0.1", path = "../../px_workspace_hack" } diff --git a/rustdoc/rustdoc_processor/Cargo.toml b/rustdoc/rustdoc_processor/Cargo.toml index cc4b6000d..ff13c48bc 100644 --- a/rustdoc/rustdoc_processor/Cargo.toml +++ b/rustdoc/rustdoc_processor/Cargo.toml @@ -49,5 +49,3 @@ rustc-hash = { workspace = true } ahash = { workspace = true } toml = { workspace = true } once_cell = { workspace = true } - -px_workspace_hack = { version = "0.1", path = "../../px_workspace_hack" } diff --git a/rustdoc/rustdoc_types/Cargo.toml b/rustdoc/rustdoc_types/Cargo.toml index 05c8cece5..220d0ed51 100644 --- a/rustdoc/rustdoc_types/Cargo.toml +++ b/rustdoc/rustdoc_types/Cargo.toml @@ -12,7 +12,6 @@ serde_derive = {version="1.0.186"} rustc-hash = {version="2", optional=true} bincode = "2" rkyv = { version = "0.8", default-features = false, features = ["std"] } -px_workspace_hack = { version = "0.1", path = "../../px_workspace_hack" } [features] default = []