chore(codegen,http): address clippy warnings (#4043)

This commit is contained in:
Yuki Okushi 2026-04-26 14:32:51 +09:00 committed by GitHub
parent 75822de4ea
commit d0fa09eb83
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 42 deletions

View File

@ -366,10 +366,9 @@ where
io.poll_flush(cx)
}
fn enter_linger(mut self: Pin<&mut Self>) {
let this = self.as_mut().project();
this.flags.remove(Flags::KEEP_ALIVE);
this.flags.insert(Flags::LINGER | Flags::FINISHED);
fn enter_linger(flags: &mut Flags) {
flags.remove(Flags::KEEP_ALIVE);
flags.insert(Flags::LINGER | Flags::FINISHED);
}
fn ensure_linger_timer(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> bool {
@ -464,23 +463,19 @@ where
let size = self.as_mut().send_response_inner(res, &body)?;
match size {
BodySize::None | BodySize::Sized(0) => {
let this = self.as_mut().project();
let mut this = self.as_mut().project();
if close_after_response {
if this.config.client_disconnect_deadline().is_some() {
drop(this);
self.as_mut().enter_linger();
Self::enter_linger(this.flags);
} else {
self.as_mut()
.project()
.flags
.insert(Flags::SHUTDOWN | Flags::FINISHED);
this.flags.insert(Flags::SHUTDOWN | Flags::FINISHED);
}
} else {
this.flags.insert(Flags::FINISHED);
}
self.as_mut().project().state.set(State::None);
this.state.set(State::None);
}
_ => self
.as_mut()
@ -509,23 +504,19 @@ where
let size = self.as_mut().send_response_inner(res, &body)?;
match size {
BodySize::None | BodySize::Sized(0) => {
let this = self.as_mut().project();
let mut this = self.as_mut().project();
if close_after_response {
if this.config.client_disconnect_deadline().is_some() {
drop(this);
self.as_mut().enter_linger();
Self::enter_linger(this.flags);
} else {
self.as_mut()
.project()
.flags
.insert(Flags::SHUTDOWN | Flags::FINISHED);
this.flags.insert(Flags::SHUTDOWN | Flags::FINISHED);
}
} else {
this.flags.insert(Flags::FINISHED);
}
self.as_mut().project().state.set(State::None);
this.state.set(State::None);
}
_ => self
.as_mut()
@ -646,13 +637,9 @@ where
if not_pipelined && close_after_response {
if this.config.client_disconnect_deadline().is_some() {
drop(this);
self.as_mut().enter_linger();
Self::enter_linger(this.flags);
} else {
self.as_mut()
.project()
.flags
.insert(Flags::SHUTDOWN | Flags::FINISHED);
this.flags.insert(Flags::SHUTDOWN | Flags::FINISHED);
}
} else {
this.flags.insert(Flags::FINISHED);
@ -708,13 +695,9 @@ where
if not_pipelined && close_after_response {
if this.config.client_disconnect_deadline().is_some() {
drop(this);
self.as_mut().enter_linger();
Self::enter_linger(this.flags);
} else {
self.as_mut()
.project()
.flags
.insert(Flags::SHUTDOWN | Flags::FINISHED);
this.flags.insert(Flags::SHUTDOWN | Flags::FINISHED);
}
} else {
this.flags.insert(Flags::FINISHED);

View File

@ -513,20 +513,17 @@ pub(crate) fn with_methods(input: TokenStream) -> TokenStream {
Err(err) => return input_and_compile_error(input, err),
};
let (methods, others) = ast
.attrs
.into_iter()
.map(|attr| match MethodType::from_path(attr.path()) {
Ok(method) => Ok((method, attr)),
Err(_) => Err(attr),
})
.partition::<Vec<_>, _>(Result::is_ok);
let mut methods = Vec::new();
ast.attrs = others.into_iter().map(Result::unwrap_err).collect();
for attr in std::mem::take(&mut ast.attrs) {
match MethodType::from_path(attr.path()) {
Ok(method) => methods.push((method, attr)),
Err(_) => ast.attrs.push(attr),
}
}
let methods = match methods
.into_iter()
.map(Result::unwrap)
.map(|(method, attr)| {
attr.parse_args()
.and_then(|args| Args::new(args, Some(method)))