mirror of https://github.com/fafhrd91/actix-web
chore(codegen,http): address clippy warnings (#4043)
This commit is contained in:
parent
75822de4ea
commit
d0fa09eb83
|
|
@ -366,10 +366,9 @@ where
|
||||||
io.poll_flush(cx)
|
io.poll_flush(cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enter_linger(mut self: Pin<&mut Self>) {
|
fn enter_linger(flags: &mut Flags) {
|
||||||
let this = self.as_mut().project();
|
flags.remove(Flags::KEEP_ALIVE);
|
||||||
this.flags.remove(Flags::KEEP_ALIVE);
|
flags.insert(Flags::LINGER | Flags::FINISHED);
|
||||||
this.flags.insert(Flags::LINGER | Flags::FINISHED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ensure_linger_timer(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> bool {
|
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)?;
|
let size = self.as_mut().send_response_inner(res, &body)?;
|
||||||
match size {
|
match size {
|
||||||
BodySize::None | BodySize::Sized(0) => {
|
BodySize::None | BodySize::Sized(0) => {
|
||||||
let this = self.as_mut().project();
|
let mut this = self.as_mut().project();
|
||||||
|
|
||||||
if close_after_response {
|
if close_after_response {
|
||||||
if this.config.client_disconnect_deadline().is_some() {
|
if this.config.client_disconnect_deadline().is_some() {
|
||||||
drop(this);
|
Self::enter_linger(this.flags);
|
||||||
self.as_mut().enter_linger();
|
|
||||||
} else {
|
} else {
|
||||||
self.as_mut()
|
this.flags.insert(Flags::SHUTDOWN | Flags::FINISHED);
|
||||||
.project()
|
|
||||||
.flags
|
|
||||||
.insert(Flags::SHUTDOWN | Flags::FINISHED);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.flags.insert(Flags::FINISHED);
|
this.flags.insert(Flags::FINISHED);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.as_mut().project().state.set(State::None);
|
this.state.set(State::None);
|
||||||
}
|
}
|
||||||
_ => self
|
_ => self
|
||||||
.as_mut()
|
.as_mut()
|
||||||
|
|
@ -509,23 +504,19 @@ where
|
||||||
let size = self.as_mut().send_response_inner(res, &body)?;
|
let size = self.as_mut().send_response_inner(res, &body)?;
|
||||||
match size {
|
match size {
|
||||||
BodySize::None | BodySize::Sized(0) => {
|
BodySize::None | BodySize::Sized(0) => {
|
||||||
let this = self.as_mut().project();
|
let mut this = self.as_mut().project();
|
||||||
|
|
||||||
if close_after_response {
|
if close_after_response {
|
||||||
if this.config.client_disconnect_deadline().is_some() {
|
if this.config.client_disconnect_deadline().is_some() {
|
||||||
drop(this);
|
Self::enter_linger(this.flags);
|
||||||
self.as_mut().enter_linger();
|
|
||||||
} else {
|
} else {
|
||||||
self.as_mut()
|
this.flags.insert(Flags::SHUTDOWN | Flags::FINISHED);
|
||||||
.project()
|
|
||||||
.flags
|
|
||||||
.insert(Flags::SHUTDOWN | Flags::FINISHED);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.flags.insert(Flags::FINISHED);
|
this.flags.insert(Flags::FINISHED);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.as_mut().project().state.set(State::None);
|
this.state.set(State::None);
|
||||||
}
|
}
|
||||||
_ => self
|
_ => self
|
||||||
.as_mut()
|
.as_mut()
|
||||||
|
|
@ -646,13 +637,9 @@ where
|
||||||
|
|
||||||
if not_pipelined && close_after_response {
|
if not_pipelined && close_after_response {
|
||||||
if this.config.client_disconnect_deadline().is_some() {
|
if this.config.client_disconnect_deadline().is_some() {
|
||||||
drop(this);
|
Self::enter_linger(this.flags);
|
||||||
self.as_mut().enter_linger();
|
|
||||||
} else {
|
} else {
|
||||||
self.as_mut()
|
this.flags.insert(Flags::SHUTDOWN | Flags::FINISHED);
|
||||||
.project()
|
|
||||||
.flags
|
|
||||||
.insert(Flags::SHUTDOWN | Flags::FINISHED);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.flags.insert(Flags::FINISHED);
|
this.flags.insert(Flags::FINISHED);
|
||||||
|
|
@ -708,13 +695,9 @@ where
|
||||||
|
|
||||||
if not_pipelined && close_after_response {
|
if not_pipelined && close_after_response {
|
||||||
if this.config.client_disconnect_deadline().is_some() {
|
if this.config.client_disconnect_deadline().is_some() {
|
||||||
drop(this);
|
Self::enter_linger(this.flags);
|
||||||
self.as_mut().enter_linger();
|
|
||||||
} else {
|
} else {
|
||||||
self.as_mut()
|
this.flags.insert(Flags::SHUTDOWN | Flags::FINISHED);
|
||||||
.project()
|
|
||||||
.flags
|
|
||||||
.insert(Flags::SHUTDOWN | Flags::FINISHED);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.flags.insert(Flags::FINISHED);
|
this.flags.insert(Flags::FINISHED);
|
||||||
|
|
|
||||||
|
|
@ -513,20 +513,17 @@ pub(crate) fn with_methods(input: TokenStream) -> TokenStream {
|
||||||
Err(err) => return input_and_compile_error(input, err),
|
Err(err) => return input_and_compile_error(input, err),
|
||||||
};
|
};
|
||||||
|
|
||||||
let (methods, others) = ast
|
let mut methods = Vec::new();
|
||||||
.attrs
|
|
||||||
.into_iter()
|
|
||||||
.map(|attr| match MethodType::from_path(attr.path()) {
|
|
||||||
Ok(method) => Ok((method, attr)),
|
|
||||||
Err(_) => Err(attr),
|
|
||||||
})
|
|
||||||
.partition::<Vec<_>, _>(Result::is_ok);
|
|
||||||
|
|
||||||
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
|
let methods = match methods
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(Result::unwrap)
|
|
||||||
.map(|(method, attr)| {
|
.map(|(method, attr)| {
|
||||||
attr.parse_args()
|
attr.parse_args()
|
||||||
.and_then(|args| Args::new(args, Some(method)))
|
.and_then(|args| Args::new(args, Some(method)))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue