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: 2 additions & 0 deletions compiler/ui_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ members = [
"reflection/local_glob_reexports_are_supported/generated_app",
"reflection/non_static_methods_are_supported",
"reflection/non_static_methods_are_supported/generated_app",
"reflection/nonnull_is_supported",
"reflection/nonnull_is_supported/generated_app",
"reflection/output_parameter_cannot_be_handled",
"reflection/output_parameter_cannot_be_handled/generated_app",
"reflection/pattern_bindings_in_input_parameters_are_supported",
Expand Down
17 changes: 17 additions & 0 deletions compiler/ui_tests/reflection/nonnull_is_supported/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "app_5680a8e5"
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
41 changes: 41 additions & 0 deletions compiler/ui_tests/reflection/nonnull_is_supported/diagnostics.dot
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_5680a8e5::non_null() -> core::ptr::NonNull<u8>"]
1 [ label = "1| app_5680a8e5::handler(core::ptr::NonNull<u8>) -> pavex::Response"]
2 [ label = "2| <pavex::Response as pavex::IntoResponse>::into_response(pavex::Response) -> pavex::Response"]
0 -> 1 [ ]
1 -> 2 [ ]
}

digraph app_state {
0 [ label = "0| crate::ApplicationState() -> crate::ApplicationState"]
}
172 changes: 172 additions & 0 deletions compiler/ui_tests/reflection/nonnull_is_supported/expectations/app.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
//! 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::non_null();
let v1 = app::handler(v0);
<pavex::Response as pavex::IntoResponse>::into_response(v1)
}
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,37 @@
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::non_null() -> core::ptr::NonNull<u8>"]
1 [ label = "1| app::handler(core::ptr::NonNull<u8>) -> pavex::Response"]
2 [ label = "2| <pavex::Response as pavex::IntoResponse>::into_response(pavex::Response) -> pavex::Response"]
0 -> 1 [ ]
1 -> 2 [ ]
}
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_5680a8e5"
version = "0.1.0"
edition = "2024"

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

[dependencies]
app_5680a8e5 = { 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 }
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "application_5680a8e5"
version = "0.1.0"
edition = "2021"

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