Skip to content

Commit 8ea7223

Browse files
chore: Remove CallableMetadata
1 parent ccdc9e7 commit 8ea7223

12 files changed

Lines changed: 161 additions & 162 deletions

File tree

compiler/pavexc/src/compiler/analyses/application_state/mod.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use super::{
2020
use crate::{
2121
compiler::app::GENERATED_APP_PACKAGE_ID,
2222
language::{
23-
Callable, CallableInput, CallableMetadata, GenericArgument, PathTypeExt, RustIdentifier,
24-
StructLiteralInit, Type,
23+
Callable, CallableInput, GenericArgument, PathTypeExt, RustIdentifier, StructLiteralInit,
24+
Type,
2525
},
2626
rustdoc::CrateCollection,
2727
};
@@ -188,20 +188,18 @@ impl ApplicationState {
188188

189189
Callable::StructLiteralInit(StructLiteralInit {
190190
path: ty_.callable_struct_literal_path(),
191-
metadata: CallableMetadata {
192-
output: Some(ty_.into()),
193-
inputs: {
194-
// Ensure that the inputs are sorted by name.
195-
let b = self.bindings.iter().collect::<BTreeMap<_, _>>();
196-
b.into_iter()
197-
.map(|(name, type_)| CallableInput {
198-
name: RustIdentifier::new(name.to_string()),
199-
type_: type_.clone(),
200-
})
201-
.collect()
202-
},
203-
source_coordinates: None,
191+
self_: Some(ty_.into()),
192+
fields: {
193+
// Ensure that the inputs are sorted by name.
194+
let b = self.bindings.iter().collect::<BTreeMap<_, _>>();
195+
b.into_iter()
196+
.map(|(name, type_)| CallableInput {
197+
name: RustIdentifier::new(name.to_string()),
198+
type_: type_.clone(),
199+
})
200+
.collect()
204201
},
202+
source_coordinates: None,
205203
extra_field2default_value: Default::default(),
206204
})
207205
}

compiler/pavexc/src/compiler/analyses/call_graph/application_state.rs

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ use crate::compiler::analyses::framework_items::FrameworkItemDb;
2323
use crate::compiler::app::GENERATED_APP_PACKAGE_ID;
2424
use crate::compiler::computation::{Computation, MatchResultVariant};
2525
use crate::language::{
26-
Callable, CallableInput, CallableMetadata, EnumVariantConstructorPath, EnumVariantInit,
27-
GenericArgument, PathType, RustIdentifier, Type,
26+
Callable, CallableInput, EnumVariantConstructorPath, EnumVariantInit, GenericArgument, PathType,
27+
RustIdentifier, Type,
2828
};
2929
use crate::rustdoc::{CORE_PACKAGE_ID_REPR, CrateCollection};
3030

@@ -157,14 +157,12 @@ pub(crate) fn application_state_call_graph(
157157
enum_generics: vec![],
158158
variant_name: "Ok".into(),
159159
},
160-
metadata: CallableMetadata {
161-
output: Some(application_state_result.clone().into()),
162-
inputs: vec![CallableInput {
163-
name: RustIdentifier::new("_0".into()),
164-
type_: application_state.type_().into(),
165-
}],
166-
source_coordinates: None,
167-
},
160+
self_: Some(application_state_result.clone().into()),
161+
fields: vec![CallableInput {
162+
name: RustIdentifier::new("_0".into()),
163+
type_: application_state.type_().into(),
164+
}],
165+
source_coordinates: None,
168166
})
169167
};
170168
let err_wrapper = {
@@ -177,14 +175,12 @@ pub(crate) fn application_state_call_graph(
177175
enum_generics: vec![],
178176
variant_name: "Err".into(),
179177
},
180-
metadata: CallableMetadata {
181-
output: Some(application_state_result.into()),
182-
inputs: vec![CallableInput {
183-
name: RustIdentifier::new("_0".into()),
184-
type_: error_enum.clone().into(),
185-
}],
186-
source_coordinates: None,
187-
},
178+
self_: Some(application_state_result.into()),
179+
fields: vec![CallableInput {
180+
name: RustIdentifier::new("_0".into()),
181+
type_: error_enum.clone().into(),
182+
}],
183+
source_coordinates: None,
188184
})
189185
};
190186
component_db.get_or_intern_transformer(
@@ -263,14 +259,12 @@ pub(crate) fn application_state_call_graph(
263259
enum_generics: vec![],
264260
variant_name: error_type_name.to_owned(),
265261
},
266-
metadata: CallableMetadata {
267-
output: Some(error_enum.clone().into()),
268-
inputs: vec![CallableInput {
269-
name: RustIdentifier::new("_0".into()),
270-
type_: error_type.to_owned(),
271-
}],
272-
source_coordinates: None,
273-
},
262+
self_: Some(error_enum.clone().into()),
263+
fields: vec![CallableInput {
264+
name: RustIdentifier::new("_0".into()),
265+
type_: error_type.to_owned(),
266+
}],
267+
source_coordinates: None,
274268
});
275269
let transformer_id = component_db.get_or_intern_transformer(
276270
computation_db.get_or_intern(error_variant_constructor.clone()),

compiler/pavexc/src/compiler/analyses/call_graph/borrow_checker/clone.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use crate::compiler::analyses::user_components::ScopeId;
1313
use crate::compiler::computation::Computation;
1414
use crate::compiler::utils::resolve_type_path;
1515
use crate::language::{
16-
Callable, CallableInput, CallableMetadata, FnHeader, Lifetime, RustIdentifier, PathType,
17-
TraitMethod, TraitMethodPath, Type, TypeReference,
16+
Callable, CallableInput, FnHeader, Lifetime, RustIdentifier, PathType, TraitMethod,
17+
TraitMethodPath, Type, TypeReference,
1818
};
1919
use crate::rustdoc::CrateCollection;
2020

@@ -71,7 +71,7 @@ pub(super) fn get_clone_component_id(
7171
method_name: "clone".into(),
7272
method_generics: vec![],
7373
},
74-
metadata: CallableMetadata {
74+
header: FnHeader {
7575
output: Some(output.clone()),
7676
inputs: vec![CallableInput {
7777
name: RustIdentifier::new("_0".into()),
@@ -81,15 +81,13 @@ pub(super) fn get_clone_component_id(
8181
inner: Box::new(output),
8282
}),
8383
}],
84-
source_coordinates: None,
85-
},
86-
header: FnHeader {
8784
is_async: false,
8885
abi: rustdoc_types::Abi::Rust,
8986
is_unsafe: false,
9087
is_c_variadic: false,
9188
symbol_name: None,
9289
},
90+
source_coordinates: None,
9391
takes_self_as_ref: true,
9492
});
9593

compiler/pavexc/src/compiler/analyses/call_graph/request_scoped.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ use crate::compiler::analyses::computations::ComputationDb;
1616
use crate::compiler::analyses::constructibles::ConstructibleDb;
1717
use crate::compiler::computation::Computation;
1818
use crate::language::{
19-
Callable, CallableInput, CallableMetadata, EnumVariantConstructorPath, EnumVariantInit,
20-
RustIdentifier, Type,
19+
Callable, CallableInput, EnumVariantConstructorPath, EnumVariantInit, RustIdentifier, Type,
2120
};
2221
use crate::rustdoc::CrateCollection;
2322

@@ -210,14 +209,12 @@ fn augment_preprocessing_graph(
210209
enum_generics: vec![],
211210
variant_name: "EarlyReturn".into(),
212211
},
213-
metadata: CallableMetadata {
214-
output: Some(component_db.pavex_processing.clone()),
215-
inputs: vec![CallableInput {
216-
name: RustIdentifier::new("_0".into()),
217-
type_: output_type.to_owned(),
218-
}],
219-
source_coordinates: None,
220-
},
212+
self_: Some(component_db.pavex_processing.clone()),
213+
fields: vec![CallableInput {
214+
name: RustIdentifier::new("_0".into()),
215+
type_: output_type.to_owned(),
216+
}],
217+
source_coordinates: None,
221218
});
222219
component_db.get_or_intern_transformer(
223220
computation_db.get_or_intern(wrapper),

compiler/pavexc/src/compiler/analyses/into_error.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ use crate::compiler::analyses::computations::ComputationDb;
66
use crate::compiler::analyses::user_components::ScopeId;
77
use crate::compiler::computation::{Computation, MatchResultVariant};
88
use crate::language::{
9-
Callable, CallableInput, CallableMetadata, FnHeader, InherentMethod, InherentMethodPath,
10-
RustIdentifier, Type,
9+
Callable, CallableInput, FnHeader, InherentMethod, InherentMethodPath, RustIdentifier, Type,
1110
};
1211

1312
/// Returns the [`ComponentId`] for a transformer component that calls `pavex::Error::new` on the
@@ -52,21 +51,19 @@ pub(super) fn register_error_new_transformer(
5251
method_name: "new".into(),
5352
method_generics: vec![],
5453
},
55-
metadata: CallableMetadata {
54+
header: FnHeader {
5655
output: Some(pavex_error.clone().into()),
5756
inputs: vec![CallableInput {
5857
name: RustIdentifier::new("_0".into()),
5958
type_: error.to_owned(),
6059
}],
61-
source_coordinates: None,
62-
},
63-
header: FnHeader {
6460
is_async: false,
6561
abi: rustdoc_types::Abi::Rust,
6662
is_unsafe: false,
6763
is_c_variadic: false,
6864
symbol_name: None,
6965
},
66+
source_coordinates: None,
7067
takes_self_as_ref: true,
7168
});
7269

compiler/pavexc/src/compiler/analyses/processing_pipeline/pipeline.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ use crate::compiler::computation::Computation;
2424
use crate::compiler::utils::LifetimeGenerator;
2525
use crate::diagnostic::{AnnotatedSource, CompilerDiagnostic, HelpWithSnippet};
2626
use crate::language::{
27-
Callable, CallableInput, CallableMetadata, CanonicalType, GenericArgument,
28-
GenericLifetimeParameter, Lifetime, RustIdentifier, PathType, PathTypeExt, StructLiteralInit,
29-
Type, TypeReference,
27+
Callable, CallableInput, CanonicalType, GenericArgument, GenericLifetimeParameter, Lifetime,
28+
RustIdentifier, PathType, PathTypeExt, StructLiteralInit, Type, TypeReference,
3029
};
3130
use crate::rustdoc::CrateCollection;
3231

@@ -690,17 +689,15 @@ impl RequestHandlerPipeline {
690689
// `next_type`.
691690
let next_state_constructor = Callable::StructLiteralInit(StructLiteralInit {
692691
path: next_state_type.callable_struct_literal_path(),
693-
metadata: CallableMetadata {
694-
output: Some(next_state_type.clone().into()),
695-
inputs: next_state_parameters
696-
.iter()
697-
.map(|input| CallableInput {
698-
name: RustIdentifier::new(input.ident.clone()),
699-
type_: input.type_.clone(),
700-
})
701-
.collect(),
702-
source_coordinates: None,
703-
},
692+
self_: Some(next_state_type.clone().into()),
693+
fields: next_state_parameters
694+
.iter()
695+
.map(|input| CallableInput {
696+
name: RustIdentifier::new(input.ident.clone()),
697+
type_: input.type_.clone(),
698+
})
699+
.collect(),
700+
source_coordinates: None,
704701
// TODO: remove when TAIT stabilises
705702
extra_field2default_value: BTreeMap::from([(
706703
"next".into(),

compiler/pavexc/src/compiler/resolvers.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ use rustdoc_types::{GenericParamDefKind, ItemEnum, Type as RustdocType};
88
use tracing_log_error::log_error;
99

1010
use crate::language::{
11-
Callable, CallableInput, CallableItem, CallableMetadata, FQGenericArgument, FQPath,
12-
FQPathSegment, FQPathType, FnHeader, FreeFunction, FreeFunctionPath, Generic, GenericArgument,
13-
GenericLifetimeParameter, InherentMethod, InherentMethodPath, RustIdentifier, PathType,
14-
TraitMethod, TraitMethodPath, Type, UnknownPath, find_rustdoc_callable_items,
15-
find_rustdoc_item_type, resolve_fq_path_type,
11+
Callable, CallableInput, CallableItem, FQGenericArgument, FQPath, FQPathSegment, FQPathType,
12+
FnHeader, FreeFunction, FreeFunctionPath, Generic, GenericArgument, GenericLifetimeParameter,
13+
InherentMethod, InherentMethodPath, RustIdentifier, PathType, TraitMethod, TraitMethodPath,
14+
Type, UnknownPath, find_rustdoc_callable_items, find_rustdoc_item_type, resolve_fq_path_type,
1615
};
1716
use crate::rustdoc::{CannotGetCrateData, CrateCollection, ResolvedItem};
1817
use rustdoc_ext::RustdocKindExt;
@@ -277,34 +276,32 @@ pub(crate) fn resolve_callable(
277276
.expect("Failed to convert generic arguments when building callable path");
278277

279278
let fn_header = FnHeader {
279+
output: output_type_path,
280+
inputs: resolved_parameter_types,
280281
is_async: header.is_async,
281282
abi: header.abi.clone(),
282283
is_unsafe: header.is_unsafe,
283284
is_c_variadic: decl.is_c_variadic,
284285
symbol_name,
285286
};
286-
let metadata = CallableMetadata {
287-
output: output_type_path,
288-
inputs: resolved_parameter_types,
289-
source_coordinates: Some(callable_item.item_id.clone()),
290-
};
287+
let source_coordinates = Some(callable_item.item_id.clone());
291288

292289
let callable = match resolved_path {
293290
ResolvedPath::FreeFunction(path) => Callable::FreeFunction(FreeFunction {
294291
path,
295-
metadata,
296292
header: fn_header,
293+
source_coordinates,
297294
}),
298295
ResolvedPath::InherentMethod(path) => Callable::InherentMethod(InherentMethod {
299296
path,
300-
metadata,
301297
header: fn_header,
298+
source_coordinates,
302299
takes_self_as_ref,
303300
}),
304301
ResolvedPath::TraitMethod(path) => Callable::TraitMethod(TraitMethod {
305302
path,
306-
metadata,
307303
header: fn_header,
304+
source_coordinates,
308305
takes_self_as_ref,
309306
}),
310307
};

compiler/pavexc/src/language/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ pub use krate_name::{
1010
};
1111
use pavex_bp_schema::CreatedAt;
1212
pub(crate) use resolved_type::{
13-
Callable, CallableInput, CallableMetadata, CanonicalType, EnumVariantConstructorPath,
14-
EnumVariantInit, FnHeader, FreeFunction, FreeFunctionPath, Generic, GenericArgument,
15-
GenericLifetimeParameter, InherentMethod, InherentMethodPath, Lifetime, RustIdentifier,
16-
PathType, PathTypeExt, RawPointer, StructLiteralInit, TraitMethod, TraitMethodPath, Tuple,
17-
Type, TypeReference,
13+
Callable, CallableInput, CanonicalType, EnumVariantConstructorPath, EnumVariantInit, FnHeader,
14+
FreeFunction, FreeFunctionPath, Generic, GenericArgument, GenericLifetimeParameter,
15+
InherentMethod, InherentMethodPath, Lifetime, RustIdentifier, PathType, PathTypeExt,
16+
RawPointer, StructLiteralInit, TraitMethod, TraitMethodPath, Tuple, Type, TypeReference,
1817
};
1918

2019
mod callable_path;

0 commit comments

Comments
 (0)