1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-25 18:09:22 +02:00

clippy warnings

This commit is contained in:
Nikolay Kim
2018-10-01 21:16:56 -07:00
parent e4686f6c8d
commit 127af92541
18 changed files with 46 additions and 49 deletions

View File

@ -1,4 +1,7 @@
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]
#![cfg_attr(
feature = "cargo-clippy",
allow(clippy::redundant_field_names)
)]
use std::{cmp, io};

View File

@ -78,7 +78,7 @@ pub fn write_content_length(mut n: usize, bytes: &mut BytesMut) {
let d1 = n << 1;
unsafe {
ptr::copy_nonoverlapping(
DEC_DIGITS_LUT.as_ptr().offset(d1 as isize),
DEC_DIGITS_LUT.as_ptr().add(d1),
buf.as_mut_ptr().offset(18),
2,
);
@ -94,7 +94,7 @@ pub fn write_content_length(mut n: usize, bytes: &mut BytesMut) {
n /= 100;
unsafe {
ptr::copy_nonoverlapping(
DEC_DIGITS_LUT.as_ptr().offset(d1 as isize),
DEC_DIGITS_LUT.as_ptr().add(d1),
buf.as_mut_ptr().offset(19),
2,
)

View File

@ -329,7 +329,10 @@ where
/// Start listening for incoming connections with supplied acceptor.
#[doc(hidden)]
#[cfg_attr(feature = "cargo-clippy", allow(needless_pass_by_value))]
#[cfg_attr(
feature = "cargo-clippy",
allow(clippy::needless_pass_by_value)
)]
pub fn bind_with<S, A>(mut self, addr: S, acceptor: A) -> io::Result<Self>
where
S: net::ToSocketAddrs,

View File

@ -151,10 +151,9 @@ impl Output {
let version = resp.version().unwrap_or_else(|| req.version);
let mut len = 0;
#[cfg_attr(feature = "cargo-clippy", allow(match_ref_pats))]
let has_body = match resp.body() {
&Body::Empty => false,
&Body::Binary(ref bin) => {
Body::Empty => false,
Body::Binary(ref bin) => {
len = bin.len();
!(response_encoding == ContentEncoding::Auto && len < 96)
}
@ -190,16 +189,15 @@ impl Output {
#[cfg(not(any(feature = "brotli", feature = "flate2")))]
let mut encoding = ContentEncoding::Identity;
#[cfg_attr(feature = "cargo-clippy", allow(match_ref_pats))]
let transfer = match resp.body() {
&Body::Empty => {
Body::Empty => {
if !info.head {
info.length = ResponseLength::Zero;
}
*self = Output::Empty(buf);
return;
}
&Body::Binary(_) => {
Body::Binary(_) => {
#[cfg(any(feature = "brotli", feature = "flate2"))]
{
if !(encoding == ContentEncoding::Identity
@ -244,7 +242,7 @@ impl Output {
}
return;
}
&Body::Streaming(_) | &Body::Actor(_) => {
Body::Streaming(_) | Body::Actor(_) => {
if resp.upgrade() {
if version == Version::HTTP_2 {
error!("Connection upgrade is forbidden for HTTP/2");
@ -441,7 +439,7 @@ impl ContentEncoder {
}
}
#[cfg_attr(feature = "cargo-clippy", allow(inline_always))]
#[cfg_attr(feature = "cargo-clippy", allow(clippy::inline_always))]
#[inline(always)]
pub fn write_eof(&mut self) -> Result<bool, io::Error> {
let encoder =
@ -483,7 +481,7 @@ impl ContentEncoder {
}
}
#[cfg_attr(feature = "cargo-clippy", allow(inline_always))]
#[cfg_attr(feature = "cargo-clippy", allow(clippy::inline_always))]
#[inline(always)]
pub fn write(&mut self, data: &[u8]) -> Result<(), io::Error> {
match *self {

View File

@ -216,7 +216,7 @@ impl<H> WorkerSettings<H> {
fn update_date(&self) {
// Unsafe: WorkerSetting is !Sync and !Send
unsafe { (&mut *self.0.date.get()).0 = false };
unsafe { (*self.0.date.get()).0 = false };
}
}