Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .config/hakari.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ third-party = [
# `rustls` entirely.
{ name = "rustls" }
]

[final-excludes]
workspace-members = ["rustdoc_types", "rustdoc_ir", "rustdoc_ext", "rustdoc_processor"]
4 changes: 0 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 13 additions & 7 deletions compiler/pavexc/src/compiler/analyses/application_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -193,17 +195,21 @@ impl ApplicationState {
inputs: {
// Ensure that the inputs are sorted by name.
let b = self.bindings.iter().collect::<BTreeMap<_, _>>();
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,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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 = {
Expand All @@ -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(
Expand Down Expand Up @@ -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()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
16 changes: 8 additions & 8 deletions compiler/pavexc/src/compiler/analyses/call_graph/core_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Type> = 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,
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,43 +124,43 @@ 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<Type> = 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
.remove(pp.response_input_index(&component_db.pavex_response));
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down
6 changes: 3 additions & 3 deletions compiler/pavexc/src/compiler/analyses/components/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions compiler/pavexc/src/compiler/analyses/components/hydrated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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![]
}
}
}
Expand Down
Loading
Loading