Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid generating needless lifetimes #635

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
34 changes: 24 additions & 10 deletions progenitor-impl/src/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,16 +662,30 @@ impl Generator {
body,
} = self.method_sig_body(method, quote! { self })?;

let method_impl = quote! {
#[doc = #doc_comment]
pub async fn #operation_id #bounds (
&'a self,
#(#params),*
) -> Result<
ResponseValue<#success_type>,
Error<#error_type>,
> {
#body
let method_impl = if params.is_empty() {
quote! {
#[doc = #doc_comment]
pub async fn #operation_id (
&self,
) -> Result<
ResponseValue<#success_type>,
Error<#error_type>,
> {
#body
}
}
} else {
quote! {
#[doc = #doc_comment]
pub async fn #operation_id #bounds (
&'a self,
#(#params),*
) -> Result<
ResponseValue<#success_type>,
Error<#error_type>,
> {
#body
}
}
};

Expand Down
18 changes: 7 additions & 11 deletions progenitor-impl/tests/output/buildomat-positional.out
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ impl Client {

impl Client {
///Sends a `POST` request to `/v1/control/hold`
pub async fn control_hold<'a>(&'a self) -> Result<ResponseValue<()>, Error<()>> {
pub async fn control_hold(&self) -> Result<ResponseValue<()>, Error<()>> {
let url = format!("{}/v1/control/hold", self.baseurl,);
let request = self
.client
Expand All @@ -331,7 +331,7 @@ impl Client {
}

///Sends a `POST` request to `/v1/control/resume`
pub async fn control_resume<'a>(&'a self) -> Result<ResponseValue<()>, Error<()>> {
pub async fn control_resume(&self) -> Result<ResponseValue<()>, Error<()>> {
let url = format!("{}/v1/control/resume", self.baseurl,);
let request = self.client.post(url).build()?;
let result = self.client.execute(request).await;
Expand Down Expand Up @@ -369,7 +369,7 @@ impl Client {
}

///Sends a `GET` request to `/v1/tasks`
pub async fn tasks_get<'a>(&'a self) -> Result<ResponseValue<Vec<types::Task>>, Error<()>> {
pub async fn tasks_get(&self) -> Result<ResponseValue<Vec<types::Task>>, Error<()>> {
let url = format!("{}/v1/tasks", self.baseurl,);
let request = self
.client
Expand Down Expand Up @@ -514,7 +514,7 @@ impl Client {
}

///Sends a `GET` request to `/v1/whoami`
pub async fn whoami<'a>(&'a self) -> Result<ResponseValue<types::WhoamiResult>, Error<()>> {
pub async fn whoami(&self) -> Result<ResponseValue<types::WhoamiResult>, Error<()>> {
let url = format!("{}/v1/whoami", self.baseurl,);
let request = self
.client
Expand Down Expand Up @@ -579,9 +579,7 @@ impl Client {
}

///Sends a `GET` request to `/v1/worker/ping`
pub async fn worker_ping<'a>(
&'a self,
) -> Result<ResponseValue<types::WorkerPingResult>, Error<()>> {
pub async fn worker_ping(&self) -> Result<ResponseValue<types::WorkerPingResult>, Error<()>> {
let url = format!("{}/v1/worker/ping", self.baseurl,);
let request = self
.client
Expand Down Expand Up @@ -692,9 +690,7 @@ impl Client {
}

///Sends a `GET` request to `/v1/workers`
pub async fn workers_list<'a>(
&'a self,
) -> Result<ResponseValue<types::WorkersResult>, Error<()>> {
pub async fn workers_list(&self) -> Result<ResponseValue<types::WorkersResult>, Error<()>> {
let url = format!("{}/v1/workers", self.baseurl,);
let request = self
.client
Expand All @@ -713,7 +709,7 @@ impl Client {
}

///Sends a `POST` request to `/v1/workers/recycle`
pub async fn workers_recycle<'a>(&'a self) -> Result<ResponseValue<()>, Error<()>> {
pub async fn workers_recycle(&self) -> Result<ResponseValue<()>, Error<()>> {
let url = format!("{}/v1/workers/recycle", self.baseurl,);
let request = self.client.post(url).build()?;
let result = self.client.execute(request).await;
Expand Down
30 changes: 12 additions & 18 deletions progenitor-impl/tests/output/nexus-positional.out
Original file line number Diff line number Diff line change
Expand Up @@ -6630,7 +6630,7 @@ impl Client {
}

///Sends a `POST` request to `/logout`
pub async fn logout<'a>(&'a self) -> Result<ResponseValue<()>, Error<types::Error>> {
pub async fn logout(&self) -> Result<ResponseValue<()>, Error<types::Error>> {
let url = format!("{}/logout", self.baseurl,);
let request = self
.client
Expand Down Expand Up @@ -10806,8 +10806,8 @@ impl Client {
///Fetch the current silo's IAM policy
///
///Sends a `GET` request to `/policy`
pub async fn policy_view<'a>(
&'a self,
pub async fn policy_view(
&self,
) -> Result<ResponseValue<types::SiloRolePolicy>, Error<types::Error>> {
let url = format!("{}/policy", self.baseurl,);
let request = self
Expand Down Expand Up @@ -10992,9 +10992,7 @@ impl Client {
///Fetch the user associated with the current session
///
///Sends a `GET` request to `/session/me`
pub async fn session_me<'a>(
&'a self,
) -> Result<ResponseValue<types::User>, Error<types::Error>> {
pub async fn session_me(&self) -> Result<ResponseValue<types::User>, Error<types::Error>> {
let url = format!("{}/session/me", self.baseurl,);
let request = self
.client
Expand Down Expand Up @@ -12733,8 +12731,8 @@ impl Client {
///Fetch the IP pool used for Oxide services
///
///Sends a `GET` request to `/system/ip-pools-service`
pub async fn ip_pool_service_view<'a>(
&'a self,
pub async fn ip_pool_service_view(
&self,
) -> Result<ResponseValue<types::IpPool>, Error<types::Error>> {
let url = format!("{}/system/ip-pools-service", self.baseurl,);
let request = self
Expand Down Expand Up @@ -12985,8 +12983,8 @@ impl Client {
///Fetch the top-level IAM policy
///
///Sends a `GET` request to `/system/policy`
pub async fn system_policy_view<'a>(
&'a self,
pub async fn system_policy_view(
&self,
) -> Result<ResponseValue<types::FleetRolePolicy>, Error<types::Error>> {
let url = format!("{}/system/policy", self.baseurl,);
let request = self
Expand Down Expand Up @@ -16161,9 +16159,7 @@ impl Client {
///Refresh update data
///
///Sends a `POST` request to `/v1/system/update/refresh`
pub async fn system_update_refresh<'a>(
&'a self,
) -> Result<ResponseValue<()>, Error<types::Error>> {
pub async fn system_update_refresh(&self) -> Result<ResponseValue<()>, Error<types::Error>> {
let url = format!("{}/v1/system/update/refresh", self.baseurl,);
let request = self
.client
Expand Down Expand Up @@ -16223,9 +16219,7 @@ impl Client {
///If there is no update in progress, do nothing.
///
///Sends a `POST` request to `/v1/system/update/stop`
pub async fn system_update_stop<'a>(
&'a self,
) -> Result<ResponseValue<()>, Error<types::Error>> {
pub async fn system_update_stop(&self) -> Result<ResponseValue<()>, Error<types::Error>> {
let url = format!("{}/v1/system/update/stop", self.baseurl,);
let request = self
.client
Expand Down Expand Up @@ -16419,8 +16413,8 @@ impl Client {
///View system version and update status
///
///Sends a `GET` request to `/v1/system/update/version`
pub async fn system_version<'a>(
&'a self,
pub async fn system_version(
&self,
) -> Result<ResponseValue<types::SystemVersion>, Error<types::Error>> {
let url = format!("{}/v1/system/update/version", self.baseurl,);
let request = self
Expand Down
8 changes: 4 additions & 4 deletions progenitor-impl/tests/output/propolis-server-positional.out
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,8 @@ impl Client {

impl Client {
///Sends a `GET` request to `/instance`
pub async fn instance_get<'a>(
&'a self,
pub async fn instance_get(
&self,
) -> Result<ResponseValue<types::InstanceGetResponse>, Error<types::Error>> {
let url = format!("{}/instance", self.baseurl,);
let request = self
Expand Down Expand Up @@ -789,8 +789,8 @@ impl Client {
}

///Sends a `GET` request to `/instance/serial`
pub async fn instance_serial<'a>(
&'a self,
pub async fn instance_serial(
&self,
) -> Result<ResponseValue<reqwest::Upgraded>, Error<reqwest::Upgraded>> {
let url = format!("{}/instance/serial", self.baseurl,);
let request = self
Expand Down
4 changes: 1 addition & 3 deletions progenitor-impl/tests/output/test_freeform_response.out
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ impl Client {

impl Client {
///Sends a `GET` request to `/`
pub async fn freeform_response<'a>(
&'a self,
) -> Result<ResponseValue<ByteStream>, Error<ByteStream>> {
pub async fn freeform_response(&self) -> Result<ResponseValue<ByteStream>, Error<ByteStream>> {
let url = format!("{}/", self.baseurl,);
let request = self.client.get(url).build()?;
let result = self.client.execute(request).await;
Expand Down
Loading