From 23726fe83d4f82057b708c34cc2eaf067655a0b9 Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Mon, 14 Oct 2024 13:05:18 +0200 Subject: [PATCH] chore: Fix (some) warnings in UI tests --- .../src/lib.rs | 2 +- .../expectations/stderr.txt | 32 ++++++++--------- .../src/lib.rs | 14 +++----- .../src/lib.rs | 12 ++----- .../src/lib.rs | 18 +++------- .../src/lib.rs | 18 +++------- .../expectations/stderr.txt | 24 ++++++------- .../src/lib.rs | 12 +++---- .../src/lib.rs | 12 ++----- .../src/lib.rs | 15 +++----- .../src/lib.rs | 15 +++----- .../a_copy_type_can_be_moved_twice/src/lib.rs | 15 +++----- .../expectations/stderr.txt | 24 ++++++------- .../src/lib.rs | 10 ++---- .../expectations/stderr.txt | 36 +++++++++---------- .../src/lib.rs | 10 +++--- .../expectations/stderr.txt | 36 +++++++++---------- .../src/lib.rs | 10 +++--- .../expectations/stderr.txt | 20 +++++------ .../src/lib.rs | 10 ++---- .../borrow_checker/mutability/src/lib.rs | 8 ++--- .../expectations/stderr.txt | 12 +++---- .../transitive_borrows/src/lib.rs | 10 +++--- .../src/lib.rs | 10 ++---- .../src/lib.rs | 13 ++----- .../src/lib.rs | 13 ++----- .../src/lib.rs | 13 ++----- .../src/lib.rs | 4 +-- .../expectations/stderr.txt | 12 +++---- .../src/lib.rs | 8 ++--- .../expectations/stderr.txt | 12 +++---- .../src/lib.rs | 8 ++--- .../src/lib.rs | 11 ++---- 33 files changed, 183 insertions(+), 296 deletions(-) diff --git a/libs/ui_tests/borrow_checker/cannot_borrow_clonable_request_scoped_as_mut/src/lib.rs b/libs/ui_tests/borrow_checker/cannot_borrow_clonable_request_scoped_as_mut/src/lib.rs index 35611e1cd..936b7441c 100644 --- a/libs/ui_tests/borrow_checker/cannot_borrow_clonable_request_scoped_as_mut/src/lib.rs +++ b/libs/ui_tests/borrow_checker/cannot_borrow_clonable_request_scoped_as_mut/src/lib.rs @@ -1,4 +1,4 @@ -use pavex::blueprint::{constructor::CloningStrategy, router::GET, Blueprint}; +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; use pavex::response::Response; diff --git a/libs/ui_tests/borrow_checker/control_flow/multiple_consumers_pass_takes_control_flow_into_account_for_errors/expectations/stderr.txt b/libs/ui_tests/borrow_checker/control_flow/multiple_consumers_pass_takes_control_flow_into_account_for_errors/expectations/stderr.txt index 767d965d6..145821d7a 100644 --- a/libs/ui_tests/borrow_checker/control_flow/multiple_consumers_pass_takes_control_flow_into_account_for_errors/expectations/stderr.txt +++ b/libs/ui_tests/borrow_checker/control_flow/multiple_consumers_pass_takes_control_flow_into_account_for_errors/expectations/stderr.txt @@ -14,31 +14,31 @@ โ”‚ You can do so by invoking `.cloning(CloningStrategy::CloneIfNecessary)` โ”‚ on the type returned by `.constructor`. โ”‚ โ˜ž - โ”‚ โ•ญโ”€[borrow_checker/control_flow/multiple_consumers_pass_takes_control_flow_into_account_for_errors/src/lib.rs:65:1] - โ”‚ 65 โ”‚ .error_handler(f!(crate::error_handler)); - โ”‚ 66 โ”‚ bp.constructor(f!(crate::b), Lifecycle::RequestScoped); - โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ - โ”‚ ยท โ•ฐโ”€โ”€ The constructor was registered here - โ”‚ 67 โ”‚ bp.constructor(f!(crate::c), Lifecycle::RequestScoped); + โ”‚ โ•ญโ”€[borrow_checker/control_flow/multiple_consumers_pass_takes_control_flow_into_account_for_errors/src/lib.rs:59:1] + โ”‚ 59 โ”‚ .error_handler(f!(crate::error_handler)); + โ”‚ 60 โ”‚ bp.request_scoped(f!(crate::b)); + โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ + โ”‚ ยท โ•ฐโ”€โ”€ The constructor was registered here + โ”‚ 61 โ”‚ bp.request_scoped(f!(crate::c)); โ”‚ โ•ฐโ”€โ”€โ”€โ”€ โ”‚ help: Considering changing the signature of the components that consume โ”‚ `app::B` by value. โ”‚ Would a shared reference, `&app::B`, be enough? โ”‚ โ˜ž - โ”‚ โ•ญโ”€[borrow_checker/control_flow/multiple_consumers_pass_takes_control_flow_into_account_for_errors/src/lib.rs:67:1] - โ”‚ 67 โ”‚ bp.constructor(f!(crate::c), Lifecycle::RequestScoped); - โ”‚ 68 โ”‚ bp.route(GET, "/home", f!(crate::handler)); + โ”‚ โ•ญโ”€[borrow_checker/control_flow/multiple_consumers_pass_takes_control_flow_into_account_for_errors/src/lib.rs:61:1] + โ”‚ 61 โ”‚ bp.request_scoped(f!(crate::c)); + โ”‚ 62 โ”‚ bp.route(GET, "/home", f!(crate::handler)); โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”‚ ยท One of the consuming request handlers - โ”‚ 69 โ”‚ bp + โ”‚ 63 โ”‚ bp โ”‚ โ•ฐโ”€โ”€โ”€โ”€ โ”‚ โ˜ž - โ”‚ โ•ญโ”€[borrow_checker/control_flow/multiple_consumers_pass_takes_control_flow_into_account_for_errors/src/lib.rs:66:1] - โ”‚ 66 โ”‚ bp.constructor(f!(crate::b), Lifecycle::RequestScoped); - โ”‚ 67 โ”‚ bp.constructor(f!(crate::c), Lifecycle::RequestScoped); - โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ - โ”‚ ยท โ•ฐโ”€โ”€ One of the consuming constructors - โ”‚ 68 โ”‚ bp.route(GET, "/home", f!(crate::handler)); + โ”‚ โ•ญโ”€[borrow_checker/control_flow/multiple_consumers_pass_takes_control_flow_into_account_for_errors/src/lib.rs:60:1] + โ”‚ 60 โ”‚ bp.request_scoped(f!(crate::b)); + โ”‚ 61 โ”‚ bp.request_scoped(f!(crate::c)); + โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ + โ”‚ ยท โ•ฐโ”€โ”€ One of the consuming constructors + โ”‚ 62 โ”‚ bp.route(GET, "/home", f!(crate::handler)); โ”‚ โ•ฐโ”€โ”€โ”€โ”€ โ”‚ help: If `app::B` itself cannot implement `Clone`, consider โ”‚ wrapping it in an `std::sync::Rc` or `std::sync::Arc`. \ No newline at end of file diff --git a/libs/ui_tests/borrow_checker/control_flow/multiple_consumers_pass_takes_control_flow_into_account_for_errors/src/lib.rs b/libs/ui_tests/borrow_checker/control_flow/multiple_consumers_pass_takes_control_flow_into_account_for_errors/src/lib.rs index 4259c83f9..6ecc73c1c 100644 --- a/libs/ui_tests/borrow_checker/control_flow/multiple_consumers_pass_takes_control_flow_into_account_for_errors/src/lib.rs +++ b/libs/ui_tests/borrow_checker/control_flow/multiple_consumers_pass_takes_control_flow_into_account_for_errors/src/lib.rs @@ -1,11 +1,5 @@ -use std::path::PathBuf; - +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; -use pavex::blueprint::{ - constructor::{CloningStrategy, Lifecycle}, - router::GET, - Blueprint, -}; use pavex::response::Response; // The call graph looks like this: @@ -61,10 +55,10 @@ pub fn handler(_b: B, _c: C) -> Response { pub fn blueprint() -> Blueprint { let mut bp = Blueprint::new(); - bp.constructor(f!(crate::a), Lifecycle::RequestScoped) + bp.request_scoped(f!(crate::a)) .error_handler(f!(crate::error_handler)); - bp.constructor(f!(crate::b), Lifecycle::RequestScoped); - bp.constructor(f!(crate::c), Lifecycle::RequestScoped); + bp.request_scoped(f!(crate::b)); + bp.request_scoped(f!(crate::c)); bp.route(GET, "/home", f!(crate::handler)); bp } diff --git a/libs/ui_tests/borrow_checker/control_flow/you_can_consume_a_non_cloneable_type_from_two_different_control_flow_branches/src/lib.rs b/libs/ui_tests/borrow_checker/control_flow/you_can_consume_a_non_cloneable_type_from_two_different_control_flow_branches/src/lib.rs index 7612f4db5..0cdd0f923 100644 --- a/libs/ui_tests/borrow_checker/control_flow/you_can_consume_a_non_cloneable_type_from_two_different_control_flow_branches/src/lib.rs +++ b/libs/ui_tests/borrow_checker/control_flow/you_can_consume_a_non_cloneable_type_from_two_different_control_flow_branches/src/lib.rs @@ -1,11 +1,5 @@ -use std::path::PathBuf; - +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; -use pavex::blueprint::{ - constructor::{CloningStrategy, Lifecycle}, - router::GET, - Blueprint, -}; use pavex::response::Response; // The call graph looks like this: @@ -48,9 +42,9 @@ pub fn handler(_a: A, _b: B) -> Response { pub fn blueprint() -> Blueprint { let mut bp = Blueprint::new(); - bp.constructor(f!(crate::a), Lifecycle::RequestScoped) + bp.request_scoped(f!(crate::a)) .error_handler(f!(crate::error_handler)); - bp.constructor(f!(crate::b), Lifecycle::RequestScoped); + bp.request_scoped(f!(crate::b)); bp.route(GET, "/home", f!(crate::handler)); bp } diff --git a/libs/ui_tests/borrow_checker/diamond/diamond_can_be_solved_if_type_is_copy/src/lib.rs b/libs/ui_tests/borrow_checker/diamond/diamond_can_be_solved_if_type_is_copy/src/lib.rs index 583efe420..f97e41bcf 100644 --- a/libs/ui_tests/borrow_checker/diamond/diamond_can_be_solved_if_type_is_copy/src/lib.rs +++ b/libs/ui_tests/borrow_checker/diamond/diamond_can_be_solved_if_type_is_copy/src/lib.rs @@ -1,10 +1,4 @@ -use std::path::PathBuf; - -use pavex::blueprint::{ - constructor::{CloningStrategy, Lifecycle}, - router::GET, - Blueprint, -}; +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; use pavex::response::Response; @@ -56,12 +50,10 @@ pub fn handler(_c: C, _d: D) -> Response { pub fn blueprint() -> Blueprint { let mut bp = Blueprint::new(); - bp.constructor(f!(crate::a), Lifecycle::RequestScoped) - .clone_if_necessary(); - bp.constructor(f!(crate::b), Lifecycle::RequestScoped) - .clone_if_necessary(); - bp.constructor(f!(crate::c), Lifecycle::RequestScoped); - bp.constructor(f!(crate::d), Lifecycle::RequestScoped); + bp.request_scoped(f!(crate::a)).clone_if_necessary(); + bp.request_scoped(f!(crate::b)).clone_if_necessary(); + bp.request_scoped(f!(crate::c)); + bp.request_scoped(f!(crate::d)); bp.route(GET, "/home", f!(crate::handler)); bp } diff --git a/libs/ui_tests/borrow_checker/diamond/diamond_can_be_solved_if_we_can_clone/src/lib.rs b/libs/ui_tests/borrow_checker/diamond/diamond_can_be_solved_if_we_can_clone/src/lib.rs index fb3482b55..b1b35dc58 100644 --- a/libs/ui_tests/borrow_checker/diamond/diamond_can_be_solved_if_we_can_clone/src/lib.rs +++ b/libs/ui_tests/borrow_checker/diamond/diamond_can_be_solved_if_we_can_clone/src/lib.rs @@ -1,10 +1,4 @@ -use std::path::PathBuf; - -use pavex::blueprint::{ - constructor::{CloningStrategy, Lifecycle}, - router::GET, - Blueprint, -}; +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; use pavex::response::Response; @@ -56,12 +50,10 @@ pub fn handler(_c: C, _d: D) -> Response { pub fn blueprint() -> Blueprint { let mut bp = Blueprint::new(); - bp.constructor(f!(crate::a), Lifecycle::RequestScoped) - .clone_if_necessary(); - bp.constructor(f!(crate::b), Lifecycle::RequestScoped) - .clone_if_necessary(); - bp.constructor(f!(crate::c), Lifecycle::RequestScoped); - bp.constructor(f!(crate::d), Lifecycle::RequestScoped); + bp.request_scoped(f!(crate::a)).clone_if_necessary(); + bp.request_scoped(f!(crate::b)).clone_if_necessary(); + bp.request_scoped(f!(crate::c)); + bp.request_scoped(f!(crate::d)); bp.route(GET, "/home", f!(crate::handler)); bp } diff --git a/libs/ui_tests/borrow_checker/diamond/diamond_cannot_be_solved_if_we_cannot_clone/expectations/stderr.txt b/libs/ui_tests/borrow_checker/diamond/diamond_cannot_be_solved_if_we_cannot_clone/expectations/stderr.txt index d25f79bae..cd4fd97b0 100644 --- a/libs/ui_tests/borrow_checker/diamond/diamond_cannot_be_solved_if_we_cannot_clone/expectations/stderr.txt +++ b/libs/ui_tests/borrow_checker/diamond/diamond_cannot_be_solved_if_we_cannot_clone/expectations/stderr.txt @@ -10,12 +10,12 @@ โ”‚ You can do so by invoking `.cloning(CloningStrategy::CloneIfNecessary)` โ”‚ on the type returned by `.constructor`. โ”‚ โ˜ž - โ”‚ โ•ญโ”€[borrow_checker/diamond/diamond_cannot_be_solved_if_we_cannot_clone/src/lib.rs:51:1] - โ”‚ 51 โ”‚ let mut bp = Blueprint::new(); - โ”‚ 52 โ”‚ bp.constructor(f!(crate::a), Lifecycle::RequestScoped); - โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ - โ”‚ ยท โ•ฐโ”€โ”€ The constructor was registered here - โ”‚ 53 โ”‚ // Being a singleton, this will be an input type of the dependency closure for the request handler + โ”‚ โ•ญโ”€[borrow_checker/diamond/diamond_cannot_be_solved_if_we_cannot_clone/src/lib.rs:49:1] + โ”‚ 49 โ”‚ let mut bp = Blueprint::new(); + โ”‚ 50 โ”‚ bp.request_scoped(f!(crate::a)); + โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ + โ”‚ ยท โ•ฐโ”€โ”€ The constructor was registered here + โ”‚ 51 โ”‚ // Being a singleton, this will be an input type of the dependency closure for the request handler โ”‚ โ•ฐโ”€โ”€โ”€โ”€ โ”‚ help: Considering changing the signature of `app::a`. โ”‚ It takes `app::A` by value. Would a shared reference, @@ -35,12 +35,12 @@ โ”‚ You can do so by invoking `.cloning(CloningStrategy::CloneIfNecessary)` โ”‚ on the type returned by `.constructor`. โ”‚ โ˜ž - โ”‚ โ•ญโ”€[borrow_checker/diamond/diamond_cannot_be_solved_if_we_cannot_clone/src/lib.rs:53:1] - โ”‚ 53 โ”‚ // Being a singleton, this will be an input type of the dependency closure for the request handler - โ”‚ 54 โ”‚ bp.constructor(f!(crate::b), Lifecycle::Singleton); - โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ - โ”‚ ยท โ•ฐโ”€โ”€ The constructor was registered here - โ”‚ 55 โ”‚ bp.constructor(f!(crate::c), Lifecycle::RequestScoped); + โ”‚ โ•ญโ”€[borrow_checker/diamond/diamond_cannot_be_solved_if_we_cannot_clone/src/lib.rs:51:1] + โ”‚ 51 โ”‚ // Being a singleton, this will be an input type of the dependency closure for the request handler + โ”‚ 52 โ”‚ bp.singleton(f!(crate::b)); + โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ + โ”‚ ยท โ•ฐโ”€โ”€ The constructor was registered here + โ”‚ 53 โ”‚ bp.request_scoped(f!(crate::c)); โ”‚ โ•ฐโ”€โ”€โ”€โ”€ โ”‚ help: Considering changing the signature of `app::b`. โ”‚ It takes `app::B` by value. Would a shared reference, diff --git a/libs/ui_tests/borrow_checker/diamond/diamond_cannot_be_solved_if_we_cannot_clone/src/lib.rs b/libs/ui_tests/borrow_checker/diamond/diamond_cannot_be_solved_if_we_cannot_clone/src/lib.rs index 3f77a200a..a4250f141 100644 --- a/libs/ui_tests/borrow_checker/diamond/diamond_cannot_be_solved_if_we_cannot_clone/src/lib.rs +++ b/libs/ui_tests/borrow_checker/diamond/diamond_cannot_be_solved_if_we_cannot_clone/src/lib.rs @@ -1,6 +1,4 @@ -use std::path::PathBuf; - -use pavex::blueprint::{constructor::Lifecycle, router::GET, Blueprint}; +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; use pavex::response::Response; @@ -49,11 +47,11 @@ pub fn handler(_c: C, _d: D) -> Response { pub fn blueprint() -> Blueprint { let mut bp = Blueprint::new(); - bp.constructor(f!(crate::a), Lifecycle::RequestScoped); + bp.request_scoped(f!(crate::a)); // Being a singleton, this will be an input type of the dependency closure for the request handler - bp.constructor(f!(crate::b), Lifecycle::Singleton); - bp.constructor(f!(crate::c), Lifecycle::RequestScoped); - bp.constructor(f!(crate::d), Lifecycle::RequestScoped); + bp.singleton(f!(crate::b)); + bp.request_scoped(f!(crate::c)); + bp.request_scoped(f!(crate::d)); bp.route(GET, "/home", f!(crate::handler)); bp } diff --git a/libs/ui_tests/borrow_checker/multiple_consumers/a_clonable_framework_type_can_be_moved_twice/src/lib.rs b/libs/ui_tests/borrow_checker/multiple_consumers/a_clonable_framework_type_can_be_moved_twice/src/lib.rs index ed11b8979..4a4bb8dcd 100644 --- a/libs/ui_tests/borrow_checker/multiple_consumers/a_clonable_framework_type_can_be_moved_twice/src/lib.rs +++ b/libs/ui_tests/borrow_checker/multiple_consumers/a_clonable_framework_type_can_be_moved_twice/src/lib.rs @@ -1,10 +1,4 @@ -use std::path::PathBuf; - -use pavex::blueprint::{ - constructor::{CloningStrategy, Lifecycle}, - router::GET, - Blueprint, -}; +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; use pavex::request::path::RawPathParams; use pavex::response::Response; @@ -39,8 +33,8 @@ pub fn handler(_b: B, _c: C) -> Response { pub fn blueprint() -> Blueprint { let mut bp = Blueprint::new(); - bp.constructor(f!(crate::b), Lifecycle::RequestScoped); - bp.constructor(f!(crate::c), Lifecycle::RequestScoped); + bp.request_scoped(f!(crate::b)); + bp.request_scoped(f!(crate::c)); bp.route(GET, "/home", f!(crate::handler)); bp } diff --git a/libs/ui_tests/borrow_checker/multiple_consumers/a_clonable_input_type_can_be_moved_twice/src/lib.rs b/libs/ui_tests/borrow_checker/multiple_consumers/a_clonable_input_type_can_be_moved_twice/src/lib.rs index 5c7f7afe1..c14625c82 100644 --- a/libs/ui_tests/borrow_checker/multiple_consumers/a_clonable_input_type_can_be_moved_twice/src/lib.rs +++ b/libs/ui_tests/borrow_checker/multiple_consumers/a_clonable_input_type_can_be_moved_twice/src/lib.rs @@ -1,10 +1,4 @@ -use std::path::PathBuf; - -use pavex::blueprint::{ - constructor::{CloningStrategy, Lifecycle}, - router::GET, - Blueprint, -}; +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; use pavex::response::Response; @@ -45,10 +39,9 @@ pub fn handler(_b: B, _c: C) -> Response { pub fn blueprint() -> Blueprint { let mut bp = Blueprint::new(); // A is a singleton, so it will be an input parameter of the dependency closure for `handler` - bp.constructor(f!(crate::a), Lifecycle::Singleton) - .clone_if_necessary(); - bp.constructor(f!(crate::b), Lifecycle::RequestScoped); - bp.constructor(f!(crate::c), Lifecycle::RequestScoped); + bp.singleton(f!(crate::a)).clone_if_necessary(); + bp.request_scoped(f!(crate::b)); + bp.request_scoped(f!(crate::c)); bp.route(GET, "/home", f!(crate::handler)); bp } diff --git a/libs/ui_tests/borrow_checker/multiple_consumers/a_clonable_type_can_be_moved_twice/src/lib.rs b/libs/ui_tests/borrow_checker/multiple_consumers/a_clonable_type_can_be_moved_twice/src/lib.rs index e7eab6418..f7c497979 100644 --- a/libs/ui_tests/borrow_checker/multiple_consumers/a_clonable_type_can_be_moved_twice/src/lib.rs +++ b/libs/ui_tests/borrow_checker/multiple_consumers/a_clonable_type_can_be_moved_twice/src/lib.rs @@ -1,10 +1,4 @@ -use std::path::PathBuf; - -use pavex::blueprint::{ - constructor::{CloningStrategy, Lifecycle}, - router::GET, - Blueprint, -}; +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; use pavex::response::Response; @@ -44,10 +38,9 @@ pub fn handler(_b: B, _c: C) -> Response { pub fn blueprint() -> Blueprint { let mut bp = Blueprint::new(); - bp.constructor(f!(crate::a), Lifecycle::RequestScoped) - .clone_if_necessary(); - bp.constructor(f!(crate::b), Lifecycle::RequestScoped); - bp.constructor(f!(crate::c), Lifecycle::RequestScoped); + bp.request_scoped(f!(crate::a)).clone_if_necessary(); + bp.request_scoped(f!(crate::b)); + bp.request_scoped(f!(crate::c)); bp.route(GET, "/home", f!(crate::handler)); bp } diff --git a/libs/ui_tests/borrow_checker/multiple_consumers/a_copy_type_can_be_moved_twice/src/lib.rs b/libs/ui_tests/borrow_checker/multiple_consumers/a_copy_type_can_be_moved_twice/src/lib.rs index 057bcc3fa..4fdbeaf5a 100644 --- a/libs/ui_tests/borrow_checker/multiple_consumers/a_copy_type_can_be_moved_twice/src/lib.rs +++ b/libs/ui_tests/borrow_checker/multiple_consumers/a_copy_type_can_be_moved_twice/src/lib.rs @@ -1,10 +1,4 @@ -use std::path::PathBuf; - -use pavex::blueprint::{ - constructor::{CloningStrategy, Lifecycle}, - router::GET, - Blueprint, -}; +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; use pavex::response::Response; @@ -44,10 +38,9 @@ pub fn handler(_b: B, _c: C) -> Response { pub fn blueprint() -> Blueprint { let mut bp = Blueprint::new(); - bp.constructor(f!(crate::a), Lifecycle::RequestScoped) - .clone_if_necessary(); - bp.constructor(f!(crate::b), Lifecycle::RequestScoped); - bp.constructor(f!(crate::c), Lifecycle::RequestScoped); + bp.request_scoped(f!(crate::a)).clone_if_necessary(); + bp.request_scoped(f!(crate::b)); + bp.request_scoped(f!(crate::c)); bp.route(GET, "/home", f!(crate::handler)); bp } diff --git a/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_framework_type_cannot_be_moved_twice/expectations/stderr.txt b/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_framework_type_cannot_be_moved_twice/expectations/stderr.txt index a851f4aa7..b7d1ab7da 100644 --- a/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_framework_type_cannot_be_moved_twice/expectations/stderr.txt +++ b/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_framework_type_cannot_be_moved_twice/expectations/stderr.txt @@ -13,18 +13,18 @@ โ”‚ `pavex::request::RequestHead` by value. โ”‚ Would a shared reference, `&pavex::request::RequestHead`, be enough? โ”‚ โ˜ž - โ”‚ โ•ญโ”€[borrow_checker/multiple_consumers/a_non_clonable_framework_type_cannot_be_moved_twice/src/lib.rs:39:1] - โ”‚ 39 โ”‚ let mut bp = Blueprint::new(); - โ”‚ 40 โ”‚ bp.constructor(f!(crate::b), Lifecycle::RequestScoped); - โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ - โ”‚ ยท โ•ฐโ”€โ”€ One of the consuming constructors - โ”‚ 41 โ”‚ bp.constructor(f!(crate::c), Lifecycle::RequestScoped); + โ”‚ โ•ญโ”€[borrow_checker/multiple_consumers/a_non_clonable_framework_type_cannot_be_moved_twice/src/lib.rs:35:1] + โ”‚ 35 โ”‚ let mut bp = Blueprint::new(); + โ”‚ 36 โ”‚ bp.request_scoped(f!(crate::b)); + โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ + โ”‚ ยท โ•ฐโ”€โ”€ One of the consuming constructors + โ”‚ 37 โ”‚ bp.request_scoped(f!(crate::c)); โ”‚ โ•ฐโ”€โ”€โ”€โ”€ โ”‚ โ˜ž - โ”‚ โ•ญโ”€[borrow_checker/multiple_consumers/a_non_clonable_framework_type_cannot_be_moved_twice/src/lib.rs:40:1] - โ”‚ 40 โ”‚ bp.constructor(f!(crate::b), Lifecycle::RequestScoped); - โ”‚ 41 โ”‚ bp.constructor(f!(crate::c), Lifecycle::RequestScoped); - โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ - โ”‚ ยท โ•ฐโ”€โ”€ One of the consuming constructors - โ”‚ 42 โ”‚ bp.route(GET, "/home", f!(crate::handler)); + โ”‚ โ•ญโ”€[borrow_checker/multiple_consumers/a_non_clonable_framework_type_cannot_be_moved_twice/src/lib.rs:36:1] + โ”‚ 36 โ”‚ bp.request_scoped(f!(crate::b)); + โ”‚ 37 โ”‚ bp.request_scoped(f!(crate::c)); + โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ + โ”‚ ยท โ•ฐโ”€โ”€ One of the consuming constructors + โ”‚ 38 โ”‚ bp.route(GET, "/home", f!(crate::handler)); โ”‚ โ•ฐโ”€โ”€โ”€โ”€ \ No newline at end of file diff --git a/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_framework_type_cannot_be_moved_twice/src/lib.rs b/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_framework_type_cannot_be_moved_twice/src/lib.rs index 16f3c733a..f9c6246ba 100644 --- a/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_framework_type_cannot_be_moved_twice/src/lib.rs +++ b/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_framework_type_cannot_be_moved_twice/src/lib.rs @@ -1,8 +1,4 @@ -use pavex::blueprint::{ - constructor::{CloningStrategy, Lifecycle}, - router::GET, - Blueprint, -}; +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; use pavex::request::RequestHead; use pavex::response::Response; @@ -37,8 +33,8 @@ pub fn handler(_b: B, _c: C) -> Response { pub fn blueprint() -> Blueprint { let mut bp = Blueprint::new(); - bp.constructor(f!(crate::b), Lifecycle::RequestScoped); - bp.constructor(f!(crate::c), Lifecycle::RequestScoped); + bp.request_scoped(f!(crate::b)); + bp.request_scoped(f!(crate::c)); bp.route(GET, "/home", f!(crate::handler)); bp } diff --git a/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_input_type_cannot_be_moved_twice/expectations/stderr.txt b/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_input_type_cannot_be_moved_twice/expectations/stderr.txt index d4030acc5..64b909b8d 100644 --- a/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_input_type_cannot_be_moved_twice/expectations/stderr.txt +++ b/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_input_type_cannot_be_moved_twice/expectations/stderr.txt @@ -14,29 +14,29 @@ โ”‚ You can do so by invoking `.cloning(CloningStrategy::CloneIfNecessary)` โ”‚ on the type returned by `.constructor`. โ”‚ โ˜ž - โ”‚ โ•ญโ”€[borrow_checker/multiple_consumers/a_non_clonable_input_type_cannot_be_moved_twice/src/lib.rs:43:1] - โ”‚ 43 โ”‚ // `A` is a singleton, therefore it will be an input of the dependency closure for the handler - โ”‚ 44 โ”‚ bp.constructor(f!(crate::a), Lifecycle::Singleton); - โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ - โ”‚ ยท โ•ฐโ”€โ”€ The constructor was registered here - โ”‚ 45 โ”‚ bp.constructor(f!(crate::b), Lifecycle::RequestScoped); + โ”‚ โ•ญโ”€[borrow_checker/multiple_consumers/a_non_clonable_input_type_cannot_be_moved_twice/src/lib.rs:41:1] + โ”‚ 41 โ”‚ // `A` is a singleton, therefore it will be an input of the dependency closure for the handler + โ”‚ 42 โ”‚ bp.singleton(f!(crate::a)); + โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ + โ”‚ ยท โ•ฐโ”€โ”€ The constructor was registered here + โ”‚ 43 โ”‚ bp.request_scoped(f!(crate::b)); โ”‚ โ•ฐโ”€โ”€โ”€โ”€ โ”‚ help: Considering changing the signature of the components that consume โ”‚ `app::A` by value. โ”‚ Would a shared reference, `&app::A`, be enough? โ”‚ โ˜ž - โ”‚ โ•ญโ”€[borrow_checker/multiple_consumers/a_non_clonable_input_type_cannot_be_moved_twice/src/lib.rs:44:1] - โ”‚ 44 โ”‚ bp.constructor(f!(crate::a), Lifecycle::Singleton); - โ”‚ 45 โ”‚ bp.constructor(f!(crate::b), Lifecycle::RequestScoped); - โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ - โ”‚ ยท โ•ฐโ”€โ”€ One of the consuming constructors - โ”‚ 46 โ”‚ bp.constructor(f!(crate::c), Lifecycle::RequestScoped); + โ”‚ โ•ญโ”€[borrow_checker/multiple_consumers/a_non_clonable_input_type_cannot_be_moved_twice/src/lib.rs:42:1] + โ”‚ 42 โ”‚ bp.singleton(f!(crate::a)); + โ”‚ 43 โ”‚ bp.request_scoped(f!(crate::b)); + โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ + โ”‚ ยท โ•ฐโ”€โ”€ One of the consuming constructors + โ”‚ 44 โ”‚ bp.request_scoped(f!(crate::c)); โ”‚ โ•ฐโ”€โ”€โ”€โ”€ โ”‚ โ˜ž - โ”‚ โ•ญโ”€[borrow_checker/multiple_consumers/a_non_clonable_input_type_cannot_be_moved_twice/src/lib.rs:45:1] - โ”‚ 45 โ”‚ bp.constructor(f!(crate::b), Lifecycle::RequestScoped); - โ”‚ 46 โ”‚ bp.constructor(f!(crate::c), Lifecycle::RequestScoped); - โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ - โ”‚ ยท โ•ฐโ”€โ”€ One of the consuming constructors - โ”‚ 47 โ”‚ bp.route(GET, "/home", f!(crate::handler)); + โ”‚ โ•ญโ”€[borrow_checker/multiple_consumers/a_non_clonable_input_type_cannot_be_moved_twice/src/lib.rs:43:1] + โ”‚ 43 โ”‚ bp.request_scoped(f!(crate::b)); + โ”‚ 44 โ”‚ bp.request_scoped(f!(crate::c)); + โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ + โ”‚ ยท โ•ฐโ”€โ”€ One of the consuming constructors + โ”‚ 45 โ”‚ bp.route(GET, "/home", f!(crate::handler)); โ”‚ โ•ฐโ”€โ”€โ”€โ”€ \ No newline at end of file diff --git a/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_input_type_cannot_be_moved_twice/src/lib.rs b/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_input_type_cannot_be_moved_twice/src/lib.rs index 206e26215..a23fe67ad 100644 --- a/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_input_type_cannot_be_moved_twice/src/lib.rs +++ b/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_input_type_cannot_be_moved_twice/src/lib.rs @@ -1,6 +1,4 @@ -use std::path::PathBuf; - -use pavex::blueprint::{constructor::Lifecycle, router::GET, Blueprint}; +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; use pavex::response::Response; @@ -41,9 +39,9 @@ pub fn handler(_b: B, _c: C) -> Response { pub fn blueprint() -> Blueprint { let mut bp = Blueprint::new(); // `A` is a singleton, therefore it will be an input of the dependency closure for the handler - bp.constructor(f!(crate::a), Lifecycle::Singleton); - bp.constructor(f!(crate::b), Lifecycle::RequestScoped); - bp.constructor(f!(crate::c), Lifecycle::RequestScoped); + bp.singleton(f!(crate::a)); + bp.request_scoped(f!(crate::b)); + bp.request_scoped(f!(crate::c)); bp.route(GET, "/home", f!(crate::handler)); bp } diff --git a/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice/expectations/stderr.txt b/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice/expectations/stderr.txt index a9eae62a4..845c9d042 100644 --- a/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice/expectations/stderr.txt +++ b/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice/expectations/stderr.txt @@ -14,31 +14,31 @@ โ”‚ You can do so by invoking `.cloning(CloningStrategy::CloneIfNecessary)` โ”‚ on the type returned by `.constructor`. โ”‚ โ˜ž - โ”‚ โ•ญโ”€[borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice/src/lib.rs:41:1] - โ”‚ 41 โ”‚ let mut bp = Blueprint::new(); - โ”‚ 42 โ”‚ bp.constructor(f!(crate::a), Lifecycle::RequestScoped); - โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ - โ”‚ ยท โ•ฐโ”€โ”€ The constructor was registered here - โ”‚ 43 โ”‚ bp.constructor(f!(crate::b), Lifecycle::RequestScoped); + โ”‚ โ•ญโ”€[borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice/src/lib.rs:39:1] + โ”‚ 39 โ”‚ let mut bp = Blueprint::new(); + โ”‚ 40 โ”‚ bp.request_scoped(f!(crate::a)); + โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ + โ”‚ ยท โ•ฐโ”€โ”€ The constructor was registered here + โ”‚ 41 โ”‚ bp.request_scoped(f!(crate::b)); โ”‚ โ•ฐโ”€โ”€โ”€โ”€ โ”‚ help: Considering changing the signature of the components that consume โ”‚ `app::A` by value. โ”‚ Would a shared reference, `&app::A`, be enough? โ”‚ โ˜ž - โ”‚ โ•ญโ”€[borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice/src/lib.rs:42:1] - โ”‚ 42 โ”‚ bp.constructor(f!(crate::a), Lifecycle::RequestScoped); - โ”‚ 43 โ”‚ bp.constructor(f!(crate::b), Lifecycle::RequestScoped); - โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ - โ”‚ ยท โ•ฐโ”€โ”€ One of the consuming constructors - โ”‚ 44 โ”‚ bp.constructor(f!(crate::c), Lifecycle::RequestScoped); + โ”‚ โ•ญโ”€[borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice/src/lib.rs:40:1] + โ”‚ 40 โ”‚ bp.request_scoped(f!(crate::a)); + โ”‚ 41 โ”‚ bp.request_scoped(f!(crate::b)); + โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ + โ”‚ ยท โ•ฐโ”€โ”€ One of the consuming constructors + โ”‚ 42 โ”‚ bp.request_scoped(f!(crate::c)); โ”‚ โ•ฐโ”€โ”€โ”€โ”€ โ”‚ โ˜ž - โ”‚ โ•ญโ”€[borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice/src/lib.rs:43:1] - โ”‚ 43 โ”‚ bp.constructor(f!(crate::b), Lifecycle::RequestScoped); - โ”‚ 44 โ”‚ bp.constructor(f!(crate::c), Lifecycle::RequestScoped); - โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ - โ”‚ ยท โ•ฐโ”€โ”€ One of the consuming constructors - โ”‚ 45 โ”‚ bp.route(GET, "/home", f!(crate::handler)); + โ”‚ โ•ญโ”€[borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice/src/lib.rs:41:1] + โ”‚ 41 โ”‚ bp.request_scoped(f!(crate::b)); + โ”‚ 42 โ”‚ bp.request_scoped(f!(crate::c)); + โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ + โ”‚ ยท โ•ฐโ”€โ”€ One of the consuming constructors + โ”‚ 43 โ”‚ bp.route(GET, "/home", f!(crate::handler)); โ”‚ โ•ฐโ”€โ”€โ”€โ”€ โ”‚ help: If `app::A` itself cannot implement `Clone`, consider โ”‚ wrapping it in an `std::sync::Rc` or `std::sync::Arc`. \ No newline at end of file diff --git a/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice/src/lib.rs b/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice/src/lib.rs index 75bdb197c..9ee48c581 100644 --- a/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice/src/lib.rs +++ b/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice/src/lib.rs @@ -1,6 +1,4 @@ -use std::path::PathBuf; - -use pavex::blueprint::{constructor::Lifecycle, router::GET, Blueprint}; +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; use pavex::response::Response; @@ -39,9 +37,9 @@ pub fn handler(_b: B, _c: C) -> Response { pub fn blueprint() -> Blueprint { let mut bp = Blueprint::new(); - bp.constructor(f!(crate::a), Lifecycle::RequestScoped); - bp.constructor(f!(crate::b), Lifecycle::RequestScoped); - bp.constructor(f!(crate::c), Lifecycle::RequestScoped); + bp.request_scoped(f!(crate::a)); + bp.request_scoped(f!(crate::b)); + bp.request_scoped(f!(crate::c)); bp.route(GET, "/home", f!(crate::handler)); bp } diff --git a/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice_across_stages/expectations/stderr.txt b/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice_across_stages/expectations/stderr.txt index 9a34f8c86..284e606d7 100644 --- a/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice_across_stages/expectations/stderr.txt +++ b/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice_across_stages/expectations/stderr.txt @@ -14,23 +14,23 @@ โ”‚ You can do so by invoking `.cloning(CloningStrategy::CloneIfNecessary)` โ”‚ on the type returned by `.constructor`. โ”‚ โ˜ž - โ”‚ โ•ญโ”€[borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice_across_stages/src/lib.rs:29:1] - โ”‚ 29 โ”‚ let mut bp = Blueprint::new(); - โ”‚ 30 โ”‚ bp.constructor(f!(crate::a), Lifecycle::RequestScoped); - โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ - โ”‚ ยท โ•ฐโ”€โ”€ The constructor was registered here - โ”‚ 31 โ”‚ bp.wrap(f!(crate::mw)); + โ”‚ โ•ญโ”€[borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice_across_stages/src/lib.rs:23:1] + โ”‚ 23 โ”‚ let mut bp = Blueprint::new(); + โ”‚ 24 โ”‚ bp.request_scoped(f!(crate::a)); + โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ + โ”‚ ยท โ•ฐโ”€โ”€ The constructor was registered here + โ”‚ 25 โ”‚ bp.wrap(f!(crate::mw)); โ”‚ โ•ฐโ”€โ”€โ”€โ”€ โ”‚ help: Considering changing the signature of the components that consume โ”‚ `app::A` by value. โ”‚ Would a shared reference, `&app::A`, be enough? โ”‚ โ˜ž - โ”‚ โ•ญโ”€[borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice_across_stages/src/lib.rs:30:1] - โ”‚ 30 โ”‚ bp.constructor(f!(crate::a), Lifecycle::RequestScoped); - โ”‚ 31 โ”‚ bp.wrap(f!(crate::mw)); + โ”‚ โ•ญโ”€[borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice_across_stages/src/lib.rs:24:1] + โ”‚ 24 โ”‚ bp.request_scoped(f!(crate::a)); + โ”‚ 25 โ”‚ bp.wrap(f!(crate::mw)); โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€ โ”‚ ยท โ•ฐโ”€โ”€ One of the consuming wrapping middlewares - โ”‚ 32 โ”‚ bp.route(GET, "/home", f!(crate::handler)); + โ”‚ 26 โ”‚ bp.route(GET, "/home", f!(crate::handler)); โ”‚ โ•ฐโ”€โ”€โ”€โ”€ โ”‚ help: If `app::A` itself cannot implement `Clone`, consider โ”‚ wrapping it in an `std::sync::Rc` or `std::sync::Arc`. \ No newline at end of file diff --git a/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice_across_stages/src/lib.rs b/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice_across_stages/src/lib.rs index e65831652..2794018b1 100644 --- a/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice_across_stages/src/lib.rs +++ b/libs/ui_tests/borrow_checker/multiple_consumers/a_non_clonable_type_cannot_be_moved_twice_across_stages/src/lib.rs @@ -1,10 +1,4 @@ -use std::path::PathBuf; - -use pavex::blueprint::{ - constructor::{CloningStrategy, Lifecycle}, - router::GET, - Blueprint, -}; +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; use pavex::middleware::Next; use pavex::response::Response; @@ -27,7 +21,7 @@ where pub fn blueprint() -> Blueprint { let mut bp = Blueprint::new(); - bp.constructor(f!(crate::a), Lifecycle::RequestScoped); + bp.request_scoped(f!(crate::a)); bp.wrap(f!(crate::mw)); bp.route(GET, "/home", f!(crate::handler)); bp diff --git a/libs/ui_tests/borrow_checker/mutability/src/lib.rs b/libs/ui_tests/borrow_checker/mutability/src/lib.rs index c3036525c..c7f5ae90d 100644 --- a/libs/ui_tests/borrow_checker/mutability/src/lib.rs +++ b/libs/ui_tests/borrow_checker/mutability/src/lib.rs @@ -1,6 +1,4 @@ -use std::path::PathBuf; - -use pavex::blueprint::{constructor::Lifecycle, router::GET, Blueprint}; +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; use pavex::response::Response; @@ -41,8 +39,8 @@ pub fn handler(_a: &mut A, _b: B) -> Response { pub fn blueprint() -> Blueprint { let mut bp = Blueprint::new(); - bp.constructor(f!(crate::a), Lifecycle::RequestScoped); - bp.constructor(f!(crate::b), Lifecycle::RequestScoped); + bp.request_scoped(f!(crate::a)); + bp.request_scoped(f!(crate::b)); bp.route(GET, "/home", f!(crate::handler)); bp } diff --git a/libs/ui_tests/borrow_checker/transitive_borrows/expectations/stderr.txt b/libs/ui_tests/borrow_checker/transitive_borrows/expectations/stderr.txt index 8a70942eb..12661dbab 100644 --- a/libs/ui_tests/borrow_checker/transitive_borrows/expectations/stderr.txt +++ b/libs/ui_tests/borrow_checker/transitive_borrows/expectations/stderr.txt @@ -13,12 +13,12 @@ โ”‚ You can do so by invoking `.clone_if_necessary()` after having โ”‚ registered your constructor. โ”‚ โ˜ž - โ”‚ โ•ญโ”€[borrow_checker/transitive_borrows/src/lib.rs:47:1] - โ”‚ 47 โ”‚ let mut bp = Blueprint::new(); - โ”‚ 48 โ”‚ bp.constructor(f!(crate::a), Lifecycle::RequestScoped); - โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ - โ”‚ ยท โ•ฐโ”€โ”€ The constructor was registered here - โ”‚ 49 โ”‚ bp.constructor(f!(crate::b), Lifecycle::RequestScoped); + โ”‚ โ•ญโ”€[borrow_checker/transitive_borrows/src/lib.rs:45:1] + โ”‚ 45 โ”‚ let mut bp = Blueprint::new(); + โ”‚ 46 โ”‚ bp.request_scoped(f!(crate::a)); + โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ + โ”‚ ยท โ•ฐโ”€โ”€ The constructor was registered here + โ”‚ 47 โ”‚ bp.request_scoped(f!(crate::b)); โ”‚ โ•ฐโ”€โ”€โ”€โ”€ โ”‚ help: Consider changing the signature of `app::b`. โ”‚ It takes `app::A` by value. Would a shared reference, diff --git a/libs/ui_tests/borrow_checker/transitive_borrows/src/lib.rs b/libs/ui_tests/borrow_checker/transitive_borrows/src/lib.rs index 50b45dd19..7e4427575 100644 --- a/libs/ui_tests/borrow_checker/transitive_borrows/src/lib.rs +++ b/libs/ui_tests/borrow_checker/transitive_borrows/src/lib.rs @@ -1,6 +1,4 @@ -use std::path::PathBuf; - -use pavex::blueprint::{constructor::Lifecycle, router::GET, Blueprint}; +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; use pavex::response::Response; @@ -45,9 +43,9 @@ pub fn handler(_c: C, _b: B) -> Response { pub fn blueprint() -> Blueprint { let mut bp = Blueprint::new(); - bp.constructor(f!(crate::a), Lifecycle::RequestScoped); - bp.constructor(f!(crate::b), Lifecycle::RequestScoped); - bp.constructor(f!(crate::c), Lifecycle::RequestScoped); + bp.request_scoped(f!(crate::a)); + bp.request_scoped(f!(crate::b)); + bp.request_scoped(f!(crate::c)); bp.route(GET, "/home", f!(crate::handler)); bp } diff --git a/libs/ui_tests/borrow_checker/triangle/triangle_can_be_solved_if_framework_type_is_clonable/src/lib.rs b/libs/ui_tests/borrow_checker/triangle/triangle_can_be_solved_if_framework_type_is_clonable/src/lib.rs index 599cd24bd..ee8d0a254 100644 --- a/libs/ui_tests/borrow_checker/triangle/triangle_can_be_solved_if_framework_type_is_clonable/src/lib.rs +++ b/libs/ui_tests/borrow_checker/triangle/triangle_can_be_solved_if_framework_type_is_clonable/src/lib.rs @@ -1,10 +1,4 @@ -use std::path::PathBuf; - -use pavex::blueprint::{ - constructor::{CloningStrategy, Lifecycle}, - router::GET, - Blueprint, -}; +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; use pavex::request::path::RawPathParams; use pavex::response::Response; @@ -34,7 +28,7 @@ pub fn handler(_p: &RawPathParams, _b: B) -> Response { pub fn blueprint() -> Blueprint { let mut bp = Blueprint::new(); - bp.constructor(f!(crate::b), Lifecycle::RequestScoped); + bp.request_scoped(f!(crate::b)); bp.route(GET, "/home", f!(crate::handler)); bp } diff --git a/libs/ui_tests/borrow_checker/triangle/triangle_can_be_solved_if_input_type_is_clonable/src/lib.rs b/libs/ui_tests/borrow_checker/triangle/triangle_can_be_solved_if_input_type_is_clonable/src/lib.rs index 6d6cdd7be..346b57ec3 100644 --- a/libs/ui_tests/borrow_checker/triangle/triangle_can_be_solved_if_input_type_is_clonable/src/lib.rs +++ b/libs/ui_tests/borrow_checker/triangle/triangle_can_be_solved_if_input_type_is_clonable/src/lib.rs @@ -1,10 +1,4 @@ -use std::path::PathBuf; - -use pavex::blueprint::{ - constructor::{CloningStrategy, Lifecycle}, - router::GET, - Blueprint, -}; +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; use pavex::response::Response; @@ -40,9 +34,8 @@ pub fn handler(_a: &A, _b: B) -> Response { pub fn blueprint() -> Blueprint { let mut bp = Blueprint::new(); // A is a singleton, so it will be an input parameter of the dependency closure for `handler` - bp.constructor(f!(crate::a), Lifecycle::Singleton) - .clone_if_necessary(); - bp.constructor(f!(crate::b), Lifecycle::RequestScoped); + bp.singleton(f!(crate::a)).clone_if_necessary(); + bp.request_scoped(f!(crate::b)); bp.route(GET, "/home", f!(crate::handler)); bp } diff --git a/libs/ui_tests/borrow_checker/triangle/triangle_can_be_solved_if_type_is_clonable/src/lib.rs b/libs/ui_tests/borrow_checker/triangle/triangle_can_be_solved_if_type_is_clonable/src/lib.rs index b9c82d567..932e636d5 100644 --- a/libs/ui_tests/borrow_checker/triangle/triangle_can_be_solved_if_type_is_clonable/src/lib.rs +++ b/libs/ui_tests/borrow_checker/triangle/triangle_can_be_solved_if_type_is_clonable/src/lib.rs @@ -1,10 +1,4 @@ -use std::path::PathBuf; - -use pavex::blueprint::{ - constructor::{CloningStrategy, Lifecycle}, - router::GET, - Blueprint, -}; +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; use pavex::response::Response; @@ -39,9 +33,8 @@ pub fn handler(_a: &A, _b: B) -> Response { pub fn blueprint() -> Blueprint { let mut bp = Blueprint::new(); - bp.constructor(f!(crate::a), Lifecycle::RequestScoped) - .clone_if_necessary(); - bp.constructor(f!(crate::b), Lifecycle::RequestScoped); + bp.request_scoped(f!(crate::a)).clone_if_necessary(); + bp.request_scoped(f!(crate::b)); bp.route(GET, "/home", f!(crate::handler)); bp } diff --git a/libs/ui_tests/borrow_checker/triangle/triangle_can_be_solved_if_type_is_copy/src/lib.rs b/libs/ui_tests/borrow_checker/triangle/triangle_can_be_solved_if_type_is_copy/src/lib.rs index 797c37797..29de2b0f0 100644 --- a/libs/ui_tests/borrow_checker/triangle/triangle_can_be_solved_if_type_is_copy/src/lib.rs +++ b/libs/ui_tests/borrow_checker/triangle/triangle_can_be_solved_if_type_is_copy/src/lib.rs @@ -1,10 +1,4 @@ -use std::path::PathBuf; - -use pavex::blueprint::{ - constructor::{CloningStrategy, Lifecycle}, - router::GET, - Blueprint, -}; +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; use pavex::response::Response; @@ -39,9 +33,8 @@ pub fn handler(_a: &A, _b: B) -> Response { pub fn blueprint() -> Blueprint { let mut bp = Blueprint::new(); - bp.constructor(f!(crate::a), Lifecycle::RequestScoped) - .clone_if_necessary(); - bp.constructor(f!(crate::b), Lifecycle::RequestScoped); + bp.request_scoped(f!(crate::a)).clone_if_necessary(); + bp.request_scoped(f!(crate::b)); bp.route(GET, "/home", f!(crate::handler)); bp } diff --git a/libs/ui_tests/borrow_checker/triangle/triangle_cannot_be_solved_if_framework_type_is_not_clonable/src/lib.rs b/libs/ui_tests/borrow_checker/triangle/triangle_cannot_be_solved_if_framework_type_is_not_clonable/src/lib.rs index 92d059d9a..db9e8f095 100644 --- a/libs/ui_tests/borrow_checker/triangle/triangle_cannot_be_solved_if_framework_type_is_not_clonable/src/lib.rs +++ b/libs/ui_tests/borrow_checker/triangle/triangle_cannot_be_solved_if_framework_type_is_not_clonable/src/lib.rs @@ -1,4 +1,4 @@ -use pavex::blueprint::{constructor::Lifecycle, router::GET, Blueprint}; +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; use pavex::request::RequestHead; use pavex::response::Response; @@ -27,7 +27,7 @@ pub fn handler(_r: &RequestHead, _b: B) -> Response { pub fn blueprint() -> Blueprint { let mut bp = Blueprint::new(); - bp.constructor(f!(crate::b), Lifecycle::RequestScoped); + bp.request_scoped(f!(crate::b)); bp.route(GET, "/home", f!(crate::handler)); bp } diff --git a/libs/ui_tests/borrow_checker/triangle/triangle_cannot_be_solved_if_input_type_is_not_clonable/expectations/stderr.txt b/libs/ui_tests/borrow_checker/triangle/triangle_cannot_be_solved_if_input_type_is_not_clonable/expectations/stderr.txt index 322875321..f406a228e 100644 --- a/libs/ui_tests/borrow_checker/triangle/triangle_cannot_be_solved_if_input_type_is_not_clonable/expectations/stderr.txt +++ b/libs/ui_tests/borrow_checker/triangle/triangle_cannot_be_solved_if_input_type_is_not_clonable/expectations/stderr.txt @@ -12,12 +12,12 @@ โ”‚ You can do so by invoking `.clone_if_necessary()` after having โ”‚ registered your constructor. โ”‚ โ˜ž - โ”‚ โ•ญโ”€[borrow_checker/triangle/triangle_cannot_be_solved_if_input_type_is_not_clonable/src/lib.rs:37:1] - โ”‚ 37 โ”‚ // A is a singleton, so it will be an input parameter of the dependency closure for `handler` - โ”‚ 38 โ”‚ bp.constructor(f!(crate::a), Lifecycle::Singleton); - โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ - โ”‚ ยท โ•ฐโ”€โ”€ The constructor was registered here - โ”‚ 39 โ”‚ bp.constructor(f!(crate::b), Lifecycle::RequestScoped); + โ”‚ โ•ญโ”€[borrow_checker/triangle/triangle_cannot_be_solved_if_input_type_is_not_clonable/src/lib.rs:35:1] + โ”‚ 35 โ”‚ // A is a singleton, so it will be an input parameter of the dependency closure for `handler` + โ”‚ 36 โ”‚ bp.singleton(f!(crate::a)); + โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ + โ”‚ ยท โ•ฐโ”€โ”€ The constructor was registered here + โ”‚ 37 โ”‚ bp.request_scoped(f!(crate::b)); โ”‚ โ•ฐโ”€โ”€โ”€โ”€ โ”‚ help: Consider changing the signature of `app::b`. โ”‚ It takes `app::A` by value. Would a shared reference, diff --git a/libs/ui_tests/borrow_checker/triangle/triangle_cannot_be_solved_if_input_type_is_not_clonable/src/lib.rs b/libs/ui_tests/borrow_checker/triangle/triangle_cannot_be_solved_if_input_type_is_not_clonable/src/lib.rs index 53e4e14bf..7cb083600 100644 --- a/libs/ui_tests/borrow_checker/triangle/triangle_cannot_be_solved_if_input_type_is_not_clonable/src/lib.rs +++ b/libs/ui_tests/borrow_checker/triangle/triangle_cannot_be_solved_if_input_type_is_not_clonable/src/lib.rs @@ -1,6 +1,4 @@ -use std::path::PathBuf; - -use pavex::blueprint::{constructor::Lifecycle, router::GET, Blueprint}; +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; use pavex::response::Response; @@ -35,8 +33,8 @@ pub fn handler(_a: &A, _b: B) -> Response { pub fn blueprint() -> Blueprint { let mut bp = Blueprint::new(); // A is a singleton, so it will be an input parameter of the dependency closure for `handler` - bp.constructor(f!(crate::a), Lifecycle::Singleton); - bp.constructor(f!(crate::b), Lifecycle::RequestScoped); + bp.singleton(f!(crate::a)); + bp.request_scoped(f!(crate::b)); bp.route(GET, "/home", f!(crate::handler)); bp } diff --git a/libs/ui_tests/borrow_checker/triangle/triangle_cannot_be_solved_if_type_is_not_clonable/expectations/stderr.txt b/libs/ui_tests/borrow_checker/triangle/triangle_cannot_be_solved_if_type_is_not_clonable/expectations/stderr.txt index 3065ee2ca..6e71dbe89 100644 --- a/libs/ui_tests/borrow_checker/triangle/triangle_cannot_be_solved_if_type_is_not_clonable/expectations/stderr.txt +++ b/libs/ui_tests/borrow_checker/triangle/triangle_cannot_be_solved_if_type_is_not_clonable/expectations/stderr.txt @@ -12,12 +12,12 @@ โ”‚ You can do so by invoking `.clone_if_necessary()` after having โ”‚ registered your constructor. โ”‚ โ˜ž - โ”‚ โ•ญโ”€[borrow_checker/triangle/triangle_cannot_be_solved_if_type_is_not_clonable/src/lib.rs:36:1] - โ”‚ 36 โ”‚ let mut bp = Blueprint::new(); - โ”‚ 37 โ”‚ bp.constructor(f!(crate::a), Lifecycle::RequestScoped); - โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ - โ”‚ ยท โ•ฐโ”€โ”€ The constructor was registered here - โ”‚ 38 โ”‚ bp.constructor(f!(crate::b), Lifecycle::RequestScoped); + โ”‚ โ•ญโ”€[borrow_checker/triangle/triangle_cannot_be_solved_if_type_is_not_clonable/src/lib.rs:34:1] + โ”‚ 34 โ”‚ let mut bp = Blueprint::new(); + โ”‚ 35 โ”‚ bp.request_scoped(f!(crate::a)); + โ”‚ ยท  โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€ + โ”‚ ยท โ•ฐโ”€โ”€ The constructor was registered here + โ”‚ 36 โ”‚ bp.request_scoped(f!(crate::b)); โ”‚ โ•ฐโ”€โ”€โ”€โ”€ โ”‚ help: Consider changing the signature of `app::b`. โ”‚ It takes `app::A` by value. Would a shared reference, diff --git a/libs/ui_tests/borrow_checker/triangle/triangle_cannot_be_solved_if_type_is_not_clonable/src/lib.rs b/libs/ui_tests/borrow_checker/triangle/triangle_cannot_be_solved_if_type_is_not_clonable/src/lib.rs index 704b5e17c..e11ea7437 100644 --- a/libs/ui_tests/borrow_checker/triangle/triangle_cannot_be_solved_if_type_is_not_clonable/src/lib.rs +++ b/libs/ui_tests/borrow_checker/triangle/triangle_cannot_be_solved_if_type_is_not_clonable/src/lib.rs @@ -1,6 +1,4 @@ -use std::path::PathBuf; - -use pavex::blueprint::{constructor::Lifecycle, router::GET, Blueprint}; +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; use pavex::response::Response; @@ -34,8 +32,8 @@ pub fn handler(_a: &A, _b: B) -> Response { pub fn blueprint() -> Blueprint { let mut bp = Blueprint::new(); - bp.constructor(f!(crate::a), Lifecycle::RequestScoped); - bp.constructor(f!(crate::b), Lifecycle::RequestScoped); + bp.request_scoped(f!(crate::a)); + bp.request_scoped(f!(crate::b)); bp.route(GET, "/home", f!(crate::handler)); bp } diff --git a/libs/ui_tests/borrow_checker/triangle/triangle_with_middleware_can_be_solved_if_type_is_clonable/src/lib.rs b/libs/ui_tests/borrow_checker/triangle/triangle_with_middleware_can_be_solved_if_type_is_clonable/src/lib.rs index 439fb7b6e..379ac2cde 100644 --- a/libs/ui_tests/borrow_checker/triangle/triangle_with_middleware_can_be_solved_if_type_is_clonable/src/lib.rs +++ b/libs/ui_tests/borrow_checker/triangle/triangle_with_middleware_can_be_solved_if_type_is_clonable/src/lib.rs @@ -1,10 +1,4 @@ -use std::path::PathBuf; - -use pavex::blueprint::{ - constructor::{CloningStrategy, Lifecycle}, - router::GET, - Blueprint, -}; +use pavex::blueprint::{router::GET, Blueprint}; use pavex::f; use pavex::middleware::Next; use pavex::response::Response; @@ -41,8 +35,7 @@ pub fn handler(_a: &A) -> Response { pub fn blueprint() -> Blueprint { let mut bp = Blueprint::new(); - bp.constructor(f!(crate::a), Lifecycle::RequestScoped) - .clone_if_necessary(); + bp.request_scoped(f!(crate::a)).clone_if_necessary(); bp.wrap(f!(crate::mw)); bp.route(GET, "/home", f!(crate::handler)); bp