Skip to content

Commit

Permalink
Glommio clippy (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Apr 8, 2024
1 parent a858394 commit ec8eb23
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 50 deletions.
1 change: 1 addition & 0 deletions .github/workflows/cov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ jobs:
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
fail_ci_if_error: true
4 changes: 2 additions & 2 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ jobs:
continue-on-error: true
run: |
cd ntex
cargo test --no-default-features --no-fail-fast --features="async-std,cookie,url,compress,openssl,rustls,ws"
cargo test --no-default-features --no-fail-fast --features="async-std,cookie,url,compress,openssl,rustls,ws,brotli"
- name: Install cargo-cache
continue-on-error: true
run: |
cargo install cargo-cache --version 0.6.2 --no-default-features --features ci-autoclean
cargo install cargo-cache --no-default-features --features ci-autoclean
- name: Clear the cargo caches
continue-on-error: true
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ jobs:
- name: Run tests
run: cargo test --all --all-features --no-fail-fast -- --nocapture

- name: Clear the cargo caches
- name: Install cargo-cache
continue-on-error: true
run: |
cargo install cargo-cache --no-default-features --features ci-autoclean
- name: Clear the cargo caches
continue-on-error: true
run: |
cargo-cache
19 changes: 1 addition & 18 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,4 @@ jobs:
- name: Run tests
run: |
cargo test --lib --all-features --no-fail-fast -- --nocapture \
--skip test_panic_in_worker \
--skip test_connection_force_close \
--skip test_connection_server_close \
--skip test_freeze \
--skip test_simple \
--skip test_test_methods \
--skip test_connection_wait_queue_force_close \
--skip test_params \
--skip test_body \
--skip test_form \
--skip test_json \
--skip test_connection_reuse \
--skip test_connection_wait_queue \
--skip test_no_decompress \
--skip test_connection_reuse_h2 \
--skip test_h2_tcp \
--skip test_timer
cargo test --lib --all-features --no-fail-fast -- --nocapture --skip test_panic_in_worker --skip test_connection_force_close --skip test_connection_server_close --skip test_freeze --skip test_simple --skip test_test_methods --skip test_connection_wait_queue_force_close --skip test_params --skip test_body --skip test_form --skip test_json --skip test_connection_reuse --skip test_connection_wait_queue --skip test_no_decompress --skip test_connection_reuse_h2 --skip test_h2_tcp --skip test_timer
2 changes: 1 addition & 1 deletion ntex-bytes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ simdutf8 = { version = "0.1.4", optional = true }
serde_test = "1"
serde_json = "1"
ntex = { version = "1", features = ["tokio"] }
ntex-bytes = { version = "*", features = ["mpool"] }
ntex-bytes = { path = ".", features = ["mpool"] }
2 changes: 1 addition & 1 deletion ntex-bytes/src/buf/buf_mut.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{cmp, mem, ptr, usize};
use std::{cmp, mem, ptr};

use super::{UninitSlice, Writer};

Expand Down
2 changes: 1 addition & 1 deletion ntex-bytes/src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::borrow::{Borrow, BorrowMut};
use std::ops::{Deref, DerefMut, RangeBounds};
use std::sync::atomic::Ordering::{Acquire, Relaxed, Release};
use std::sync::atomic::{self, AtomicUsize};
use std::{cmp, fmt, hash, mem, ptr, ptr::NonNull, slice, usize};
use std::{cmp, fmt, hash, mem, ptr, ptr::NonNull, slice};

use crate::pool::{PoolId, PoolRef};
use crate::{buf::IntoIter, buf::UninitSlice, debug, Buf, BufMut};
Expand Down
1 change: 0 additions & 1 deletion ntex-bytes/tests/test_buf_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use ntex_bytes::{BufMut, BytesMut};
use std::fmt::Write;
use std::usize;

#[test]
fn test_vec_as_mut_buf() {
Expand Down
2 changes: 2 additions & 0 deletions ntex-glommio/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ impl Future for WriteTask {
match this.state.with_buf(|buf| flush_io(&mut *io, buf, cx)) {
Poll::Ready(Ok(())) => {
let io = this.io.clone();
#[allow(clippy::await_holding_refcell_ref)]
let fut = Box::pin(async move {
io.0.borrow()
.shutdown(std::net::Shutdown::Write)
Expand Down Expand Up @@ -510,6 +511,7 @@ impl Future for UnixWriteTask {
match this.state.with_buf(|buf| flush_io(&mut *io, buf, cx)) {
Poll::Ready(Ok(())) => {
let io = this.io.clone();
#[allow(clippy::await_holding_refcell_ref)]
let fut = Box::pin(async move {
io.0.borrow()
.shutdown(std::net::Shutdown::Write)
Expand Down
2 changes: 1 addition & 1 deletion ntex-glommio/src/signals.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{cell::RefCell, future::Future, pin::Pin, rc::Rc, task::Context, task::Poll};

thread_local! {
static SRUN: RefCell<bool> = RefCell::new(false);
static SRUN: RefCell<bool> = const { RefCell::new(false) };
static SHANDLERS: Rc<RefCell<Vec<oneshot::Sender<Signal>>>> = Default::default();
}

Expand Down
2 changes: 1 addition & 1 deletion ntex-http/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ macro_rules! from_integers {
let val = HeaderValue::from(n);
assert_eq!(val, &n.to_string());

let n = ::std::$t::MAX;
let n = $t::MAX;
let val = HeaderValue::from(n);
assert_eq!(val, &n.to_string());
}
Expand Down
6 changes: 1 addition & 5 deletions ntex-router/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,7 @@ impl<T: ResourcePath> Path<T> {
/// If keyed parameter is not available empty string is used as default
/// value.
pub fn query(&self, key: &str) -> &str {
if let Some(s) = self.get(key) {
s
} else {
""
}
self.get(key).unwrap_or_default()
}

/// Return iterator to items in parameter container
Expand Down
6 changes: 3 additions & 3 deletions ntex-tokio/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{io::Result, net, net::SocketAddr, path::Path};
use std::{io::Result, net, net::SocketAddr};

use ntex_bytes::PoolRef;
use ntex_io::Io;
Expand Down Expand Up @@ -32,7 +32,7 @@ pub async fn tcp_connect_in(addr: SocketAddr, pool: PoolRef) -> Result<Io> {
/// Opens a unix stream connection.
pub async fn unix_connect<'a, P>(addr: P) -> Result<Io>
where
P: AsRef<Path> + 'a,
P: AsRef<std::path::Path> + 'a,
{
let sock = tokio::net::UnixStream::connect(addr).await?;
Ok(Io::new(UnixStream(sock)))
Expand All @@ -42,7 +42,7 @@ where
/// Opens a unix stream connection and specified memory pool.
pub async fn unix_connect_in<'a, P>(addr: P, pool: PoolRef) -> Result<Io>
where
P: AsRef<Path> + 'a,
P: AsRef<std::path::Path> + 'a,
{
let sock = tokio::net::UnixStream::connect(addr).await?;
Ok(Io::with_memory_pool(UnixStream(sock), pool))
Expand Down
2 changes: 1 addition & 1 deletion ntex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ license = "MIT OR Apache-2.0"
edition = "2021"

[package.metadata.docs.rs]
features = ["tokio", "openssl", "rustls", "compress", "cookie", "ws"]
features = ["tokio", "openssl", "rustls", "compress", "cookie", "ws", "brotli"]

[lib]
name = "ntex"
Expand Down
8 changes: 4 additions & 4 deletions ntex/src/web/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,12 +592,10 @@ impl<Err: ErrorRenderer> Service<WebRequest<Err>> for Filter<Err> {
#[cfg(test)]
mod tests {
use super::*;
use crate::http::header::{self, HeaderValue};
use crate::http::{Method, StatusCode};
use crate::service::fn_service;
use crate::util::{Bytes, Ready};
use crate::http::{header, header::HeaderValue, Method, StatusCode};
use crate::web::test::{call_service, init_service, read_body, TestRequest};
use crate::web::{self, middleware::DefaultHeaders, HttpRequest, HttpResponse};
use crate::{service::fn_service, util::Ready};

#[crate::rt_test]
async fn test_default_resource() {
Expand Down Expand Up @@ -775,6 +773,8 @@ mod tests {
#[cfg(feature = "url")]
#[crate::rt_test]
async fn test_external_resource() {
use crate::util::Bytes;

let srv = init_service(
App::new()
.external_resource("youtube", "https://youtube.com/watch/{video_id}")
Expand Down
6 changes: 1 addition & 5 deletions ntex/src/web/httprequest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,7 @@ impl HttpRequest {
/// E.g., id=10
#[inline]
pub fn query_string(&self) -> &str {
if let Some(query) = self.uri().query().as_ref() {
query
} else {
""
}
self.uri().query().unwrap_or_default()
}

/// Io reference for current connection
Expand Down
6 changes: 1 addition & 5 deletions ntex/src/web/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,7 @@ impl<Err> WebRequest<Err> {
/// E.g., id=10
#[inline]
pub fn query_string(&self) -> &str {
if let Some(query) = self.uri().query().as_ref() {
query
} else {
""
}
self.uri().query().unwrap_or_default()
}

/// Peer socket address
Expand Down

0 comments on commit ec8eb23

Please sign in to comment.