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
2 changes: 1 addition & 1 deletion compiler/pavexc/src/compiler/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ fn collect_type_package_ids(package_ids: &mut IndexSet<PackageId>, t: &Type) {
for generic in &t.generic_arguments {
match generic {
GenericArgument::TypeParameter(t) => collect_type_package_ids(package_ids, t),
GenericArgument::Lifetime(_) => {}
GenericArgument::Lifetime(_) | GenericArgument::Const(_) => {}
}
}
}
Expand Down
12 changes: 10 additions & 2 deletions compiler/pavexc/src/compiler/framework_rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,16 @@ pub(crate) fn resolve_type_path(raw_path: &str, krate_collection: &CrateCollecti
}))
}
}
rustdoc_types::GenericParamDefKind::Const { .. } => {
unimplemented!("const generic parameters are not supported yet")
rustdoc_types::GenericParamDefKind::Const { default, .. } => {
if let Some(default) = default {
GenericArgument::Const(rustdoc_ir::ConstGenericArgument {
value: default.clone(),
})
} else {
GenericArgument::Const(rustdoc_ir::ConstGenericArgument {
value: generic_def.name.clone(),
})
}
}
};
generic_arguments.push(arg);
Expand Down
2 changes: 2 additions & 0 deletions compiler/ui_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ members = [
"reflection/bitflags_are_supported/generated_app",
"reflection/common_response_types_are_supported",
"reflection/common_response_types_are_supported/generated_app",
"reflection/const_generics_are_supported",
"reflection/const_generics_are_supported/generated_app",
"reflection/crate_resolution/dependencies_can_register_local_items",
"reflection/crate_resolution/dependencies_can_register_local_items/generated_app",
"reflection/crate_resolution/multiple_versions_for_the_same_crate_are_supported",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "app_e22d4bbe"
version = "0.1.0"
edition.workspace = true

[lints.rust.unexpected_cfgs]
level = "allow"
check-cfg = ["cfg(pavex_ide_hint)"]

[dependencies]
workspace_hack = { version = "0.1", path = "../../workspace_hack" }

[dependencies.pavex]
workspace = true

[dependencies.pavex_cli_client]
workspace = true
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
digraph "* * - 0" {
0 [ label = "0| &pavex::router::AllowedMethods"]
1 [ label = "1| crate::route_0::Next0(&'a pavex::router::AllowedMethods) -> crate::route_0::Next0<'a>"]
2 [ label = "2| pavex::middleware::Next::new(crate::route_0::Next0<'a>) -> pavex::middleware::Next<crate::route_0::Next0<'a>>"]
3 [ label = "3| pavex::middleware::wrap_noop(pavex::middleware::Next<crate::route_0::Next0<'a>>) -> pavex::Response"]
4 [ label = "4| <pavex::Response as pavex::IntoResponse>::into_response(pavex::Response) -> pavex::Response"]
2 -> 3 [ ]
1 -> 2 [ ]
3 -> 4 [ ]
0 -> 1 [ ]
}

digraph "* * - 1" {
0 [ label = "0| &pavex::router::AllowedMethods"]
1 [ label = "1| pavex::router::default_fallback(&pavex::router::AllowedMethods) -> pavex::Response"]
2 [ label = "2| <pavex::Response as pavex::IntoResponse>::into_response(pavex::Response) -> pavex::Response"]
1 -> 2 [ ]
0 -> 1 [ ]
}

digraph "GET / - 0" {
0 [ label = "0| crate::route_1::Next0() -> crate::route_1::Next0"]
1 [ label = "1| pavex::middleware::Next::new(crate::route_1::Next0) -> pavex::middleware::Next<crate::route_1::Next0>"]
2 [ label = "2| pavex::middleware::wrap_noop(pavex::middleware::Next<crate::route_1::Next0>) -> pavex::Response"]
3 [ label = "3| <pavex::Response as pavex::IntoResponse>::into_response(pavex::Response) -> pavex::Response"]
1 -> 2 [ ]
0 -> 1 [ ]
2 -> 3 [ ]
}

digraph "GET / - 1" {
0 [ label = "0| app_e22d4bbe::character() -> app_e22d4bbe::CharConst<'a'>"]
1 [ label = "1| app_e22d4bbe::boolean() -> app_e22d4bbe::BoolConst<true>"]
2 [ label = "2| app_e22d4bbe::numeric() -> app_e22d4bbe::NumericConst<8>"]
3 [ label = "3| app_e22d4bbe::handler(app_e22d4bbe::NumericConst<8>, app_e22d4bbe::BoolConst<true>, app_e22d4bbe::CharConst<'a'>) -> pavex::Response"]
4 [ label = "4| <pavex::Response as pavex::IntoResponse>::into_response(pavex::Response) -> pavex::Response"]
0 -> 3 [ ]
1 -> 3 [ ]
2 -> 3 [ ]
3 -> 4 [ ]
}

digraph app_state {
0 [ label = "0| crate::ApplicationState() -> crate::ApplicationState"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
//! Do NOT edit this code.
//! It was automatically generated by Pavex.
//! All manual edits will be lost next time the code is generated.
extern crate alloc;
struct ServerState {
router: Router,
#[allow(dead_code)]
application_state: ApplicationState,
}
#[derive(Debug, Clone, serde::Deserialize)]
pub struct ApplicationConfig {}
pub struct ApplicationState {}
impl ApplicationState {
pub async fn new(
_app_config: crate::ApplicationConfig,
) -> Result<crate::ApplicationState, crate::ApplicationStateError> {
Ok(Self::_new().await)
}
async fn _new() -> crate::ApplicationState {
crate::ApplicationState {}
}
}
#[derive(Debug, thiserror::Error)]
pub enum ApplicationStateError {}
pub fn run(
server_builder: pavex::server::Server,
application_state: ApplicationState,
) -> pavex::server::ServerHandle {
async fn handler(
request: http::Request<hyper::body::Incoming>,
connection_info: Option<pavex::connection::ConnectionInfo>,
server_state: std::sync::Arc<ServerState>,
) -> pavex::Response {
let (router, state) = (&server_state.router, &server_state.application_state);
router.route(request, connection_info, state).await
}
let router = Router::new();
let server_state = std::sync::Arc::new(ServerState {
router,
application_state,
});
server_builder.serve(handler, server_state)
}
struct Router {
router: matchit::Router<u32>,
}
impl Router {
/// Create a new router instance.
///
/// This method is invoked once, when the server starts.
pub fn new() -> Self {
Self { router: Self::router() }
}
fn router() -> matchit::Router<u32> {
let mut router = matchit::Router::new();
router.insert("/", 0u32).unwrap();
router
}
pub async fn route(
&self,
request: http::Request<hyper::body::Incoming>,
_connection_info: Option<pavex::connection::ConnectionInfo>,
#[allow(unused)]
state: &ApplicationState,
) -> pavex::Response {
let (request_head, _) = request.into_parts();
let request_head: pavex::request::RequestHead = request_head.into();
let Ok(matched_route) = self.router.at(&request_head.target.path()) else {
let allowed_methods: pavex::router::AllowedMethods = pavex::router::MethodAllowList::from_iter(
vec![],
)
.into();
return route_0::entrypoint(&allowed_methods).await;
};
match matched_route.value {
0u32 => {
match &request_head.method {
&pavex::http::Method::GET => route_1::entrypoint().await,
_ => {
let allowed_methods: pavex::router::AllowedMethods = pavex::router::MethodAllowList::from_iter([
pavex::http::Method::GET,
])
.into();
route_0::entrypoint(&allowed_methods).await
}
}
}
i => unreachable!("Unknown route id: {}", i),
}
}
}
pub mod route_0 {
pub async fn entrypoint<'a>(
s_0: &'a pavex::router::AllowedMethods,
) -> pavex::Response {
let response = wrapping_0(s_0).await;
response
}
async fn stage_1<'a>(s_0: &'a pavex::router::AllowedMethods) -> pavex::Response {
let response = handler(s_0).await;
response
}
async fn wrapping_0(v0: &pavex::router::AllowedMethods) -> pavex::Response {
let v1 = crate::route_0::Next0 {
s_0: v0,
next: stage_1,
};
let v2 = pavex::middleware::Next::new(v1);
let v3 = pavex::middleware::wrap_noop(v2).await;
<pavex::Response as pavex::IntoResponse>::into_response(v3)
}
async fn handler(v0: &pavex::router::AllowedMethods) -> pavex::Response {
let v1 = pavex::router::default_fallback(v0).await;
<pavex::Response as pavex::IntoResponse>::into_response(v1)
}
struct Next0<'a, T>
where
T: std::future::Future<Output = pavex::Response>,
{
s_0: &'a pavex::router::AllowedMethods,
next: fn(&'a pavex::router::AllowedMethods) -> T,
}
impl<'a, T> std::future::IntoFuture for Next0<'a, T>
where
T: std::future::Future<Output = pavex::Response>,
{
type Output = pavex::Response;
type IntoFuture = T;
fn into_future(self) -> Self::IntoFuture {
(self.next)(self.s_0)
}
}
}
pub mod route_1 {
pub async fn entrypoint() -> pavex::Response {
let response = wrapping_0().await;
response
}
async fn stage_1() -> pavex::Response {
let response = handler().await;
response
}
async fn wrapping_0() -> pavex::Response {
let v0 = crate::route_1::Next0 {
next: stage_1,
};
let v1 = pavex::middleware::Next::new(v0);
let v2 = pavex::middleware::wrap_noop(v1).await;
<pavex::Response as pavex::IntoResponse>::into_response(v2)
}
async fn handler() -> pavex::Response {
let v0 = app::character();
let v1 = app::boolean();
let v2 = app::numeric();
let v3 = app::handler(v2, v1, v0);
<pavex::Response as pavex::IntoResponse>::into_response(v3)
}
struct Next0<T>
where
T: std::future::Future<Output = pavex::Response>,
{
next: fn() -> T,
}
impl<T> std::future::IntoFuture for Next0<T>
where
T: std::future::Future<Output = pavex::Response>,
{
type Output = pavex::Response;
type IntoFuture = T;
fn into_future(self) -> Self::IntoFuture {
(self.next)()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
digraph "* * - 0" {
0 [ label = "0| &pavex::router::AllowedMethods"]
1 [ label = "1| crate::route_0::Next0(&'a pavex::router::AllowedMethods) -> crate::route_0::Next0<'a>"]
2 [ label = "2| pavex::middleware::Next::new(crate::route_0::Next0<'a>) -> pavex::middleware::Next<crate::route_0::Next0<'a>>"]
3 [ label = "3| pavex::middleware::wrap_noop(pavex::middleware::Next<crate::route_0::Next0<'a>>) -> pavex::Response"]
4 [ label = "4| <pavex::Response as pavex::IntoResponse>::into_response(pavex::Response) -> pavex::Response"]
2 -> 3 [ ]
1 -> 2 [ ]
3 -> 4 [ ]
0 -> 1 [ ]
}
digraph "* * - 1" {
0 [ label = "0| &pavex::router::AllowedMethods"]
1 [ label = "1| pavex::router::default_fallback(&pavex::router::AllowedMethods) -> pavex::Response"]
2 [ label = "2| <pavex::Response as pavex::IntoResponse>::into_response(pavex::Response) -> pavex::Response"]
1 -> 2 [ ]
0 -> 1 [ ]
}
digraph "GET / - 0" {
0 [ label = "0| crate::route_1::Next0() -> crate::route_1::Next0"]
1 [ label = "1| pavex::middleware::Next::new(crate::route_1::Next0) -> pavex::middleware::Next<crate::route_1::Next0>"]
2 [ label = "2| pavex::middleware::wrap_noop(pavex::middleware::Next<crate::route_1::Next0>) -> pavex::Response"]
3 [ label = "3| <pavex::Response as pavex::IntoResponse>::into_response(pavex::Response) -> pavex::Response"]
1 -> 2 [ ]
0 -> 1 [ ]
2 -> 3 [ ]
}
digraph "GET / - 1" {
0 [ label = "0| app::character() -> app::CharConst<'a'>"]
1 [ label = "1| app::boolean() -> app::BoolConst<true>"]
2 [ label = "2| app::numeric() -> app::NumericConst<8>"]
3 [ label = "3| app::handler(app::NumericConst<8>, app::BoolConst<true>, app::CharConst<'a'>) -> pavex::Response"]
4 [ label = "4| <pavex::Response as pavex::IntoResponse>::into_response(pavex::Response) -> pavex::Response"]
0 -> 3 [ ]
1 -> 3 [ ]
2 -> 3 [ ]
3 -> 4 [ ]
}
digraph app_state {
0 [ label = "0| crate::ApplicationState() -> crate::ApplicationState"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "application_e22d4bbe"
version = "0.1.0"
edition = "2024"

[package.metadata.px.generate]
generator_type = "cargo_workspace_binary"
generator_name = "app_e22d4bbe"

[dependencies]
app_e22d4bbe = { version = "0.1", path = "..", default-features = false }
http = { version = "1", default-features = false }
hyper = { version = "1", default-features = false }
matchit = { version = "0.9", default-features = false }
pavex = { version = "0.2", path = "../../../../../runtime/pavex", default-features = false }
serde = { version = "1", default-features = false }
thiserror = { version = "2", default-features = false }
Loading
Loading