diff --git a/contrib/sync_db_pools/lib/tests/databases.rs b/contrib/sync_db_pools/lib/tests/databases.rs index 0bccbc56..3219a481 100644 --- a/contrib/sync_db_pools/lib/tests/databases.rs +++ b/contrib/sync_db_pools/lib/tests/databases.rs @@ -1,6 +1,8 @@ #[cfg(all(feature = "diesel_sqlite_pool", feature = "diesel_postgres_pool"))] mod databases_tests { - use rocket_sync_db_pools::{database, diesel}; + #![allow(dead_code)] + + use rocket_sync_db_pools::database; #[database("example")] struct ExampleDb(diesel::SqliteConnection); diff --git a/contrib/sync_db_pools/lib/tests/shutdown.rs b/contrib/sync_db_pools/lib/tests/shutdown.rs index d338862e..d21e6f87 100644 --- a/contrib/sync_db_pools/lib/tests/shutdown.rs +++ b/contrib/sync_db_pools/lib/tests/shutdown.rs @@ -5,6 +5,7 @@ mod sqlite_shutdown_test { use rocket_sync_db_pools::database; #[database("test")] + #[allow(dead_code)] struct Pool(diesel::SqliteConnection); async fn rocket() -> Rocket { diff --git a/core/codegen/src/bang/test_guide.rs b/core/codegen/src/bang/test_guide.rs index faa9b560..cfbfc124 100644 --- a/core/codegen/src/bang/test_guide.rs +++ b/core/codegen/src/bang/test_guide.rs @@ -1,7 +1,7 @@ use std::path::Path; use std::error::Error; -use syn::{self, Ident, LitStr}; +use syn::{Ident, LitStr}; use devise::ext::SpanDiagnosticExt; use proc_macro2::TokenStream; diff --git a/core/codegen/src/name.rs b/core/codegen/src/name.rs index c3a2521b..c5b8e2b1 100644 --- a/core/codegen/src/name.rs +++ b/core/codegen/src/name.rs @@ -1,6 +1,6 @@ use crate::http::uncased::UncasedStr; -use syn::{self, Ident, ext::IdentExt}; +use syn::{Ident, ext::IdentExt}; use proc_macro2::{Span, TokenStream}; /// A "name" read by codegen, which may or may not be an identifier. A `Name` is diff --git a/core/codegen/src/syn_ext.rs b/core/codegen/src/syn_ext.rs index 608a914c..73ab6166 100644 --- a/core/codegen/src/syn_ext.rs +++ b/core/codegen/src/syn_ext.rs @@ -4,7 +4,7 @@ use std::ops::Deref; use std::hash::{Hash, Hasher}; use std::borrow::Cow; -use syn::{self, Ident, ext::IdentExt as _, visit::Visit}; +use syn::{Ident, ext::IdentExt as _, visit::Visit}; use proc_macro2::{Span, TokenStream}; use devise::ext::{PathExt, TypeExt as _}; use rocket_http::ext::IntoOwned; @@ -21,17 +21,12 @@ pub trait ReturnTypeExt { fn ty(&self) -> Option<&syn::Type>; } -pub trait TokenStreamExt { - fn respanned(&self, span: Span) -> Self; -} - pub trait FnArgExt { fn typed(&self) -> Option<(&syn::Ident, &syn::Type)>; fn wild(&self) -> Option<&syn::PatWild>; } pub trait TypeExt { - fn unfold(&self) -> Vec>; fn unfold_with_ty_macros(&self, names: &[&str], mapper: MacTyMapFn) -> Vec>; fn is_concrete(&self, generic_ident: &[&Ident]) -> bool; } @@ -112,15 +107,6 @@ impl ReturnTypeExt for syn::ReturnType { } } -impl TokenStreamExt for TokenStream { - fn respanned(&self, span: Span) -> Self { - self.clone().into_iter().map(|mut token| { - token.set_span(span); - token - }).collect() - } -} - impl FnArgExt for syn::FnArg { fn typed(&self) -> Option<(&Ident, &syn::Type)> { match self { @@ -154,10 +140,6 @@ fn macro_inner_ty(t: &syn::TypeMacro, names: &[&str], m: MacTyMapFn) -> Option Vec> { - self.unfold_with_ty_macros(&[], |_| None) - } - fn unfold_with_ty_macros(&self, names: &[&str], mapper: MacTyMapFn) -> Vec> { struct Visitor<'a, 'm> { parents: Vec>, @@ -240,10 +222,10 @@ impl GenericsExt for syn::Generics { mod tests { #[test] fn test_type_unfold_is_generic() { - use super::{TypeExt, syn}; + use super::TypeExt; let ty: syn::Type = syn::parse_quote!(A, Box, Option>); - let children = ty.unfold(); + let children = ty.unfold_with_ty_macros(&[], |_| None); assert_eq!(children.len(), 8); let gen_ident = format_ident!("T"); diff --git a/core/http/src/method.rs b/core/http/src/method.rs index a959fbc2..11e031d4 100644 --- a/core/http/src/method.rs +++ b/core/http/src/method.rs @@ -135,7 +135,6 @@ impl fmt::Display for Method { #[cfg(feature = "serde")] mod serde { - use std::fmt; use super::*; use serde_::ser::{Serialize, Serializer}; diff --git a/core/http/src/parse/uri/tests.rs b/core/http/src/parse/uri/tests.rs index ac7b506c..1f37c604 100644 --- a/core/http/src/parse/uri/tests.rs +++ b/core/http/src/parse/uri/tests.rs @@ -1,4 +1,3 @@ -use crate::uri::{Origin, Authority, Absolute, Asterisk}; use crate::parse::uri::*; macro_rules! assert_parse_eq { diff --git a/core/http/src/raw_str.rs b/core/http/src/raw_str.rs index 02a54e3b..fbc2dd77 100644 --- a/core/http/src/raw_str.rs +++ b/core/http/src/raw_str.rs @@ -1,14 +1,13 @@ +use std::fmt; use std::borrow::{Borrow, Cow}; -use std::convert::AsRef; use std::cmp::Ordering; use std::str::Utf8Error; -use std::fmt; use ref_cast::RefCast; use stable_pattern::{Pattern, Searcher, ReverseSearcher, Split, SplitInternal}; -use crate::uri::fmt::{DEFAULT_ENCODE_SET, percent_encode, percent_encode_bytes}; use crate::uncased::UncasedStr; +use crate::uri::fmt::{DEFAULT_ENCODE_SET, percent_encode, percent_encode_bytes}; /// A reference to a string inside of a raw HTTP message. /// diff --git a/core/http/src/status.rs b/core/http/src/status.rs index 5518621d..5de8e50e 100644 --- a/core/http/src/status.rs +++ b/core/http/src/status.rs @@ -382,7 +382,6 @@ impl Ord for Status { #[cfg(feature = "serde")] mod serde { - use std::fmt; use super::*; use serde_::ser::{Serialize, Serializer}; diff --git a/core/lib/src/form/form.rs b/core/lib/src/form/form.rs index 848d490d..bcb2a241 100644 --- a/core/lib/src/form/form.rs +++ b/core/lib/src/form/form.rs @@ -4,8 +4,7 @@ use crate::Request; use crate::outcome::try_outcome; use crate::data::{Data, FromData, Outcome}; use crate::http::{RawStr, ext::IntoOwned}; -use crate::form::{SharedStack, parser::{Parser, RawStrParser}}; -use crate::form::prelude::*; +use crate::form::prelude::{*, parser::{Parser, RawStrParser}}; /// A data guard for [`FromForm`] types. /// diff --git a/core/lib/src/form/parser.rs b/core/lib/src/form/parser.rs index 4b5fe0a7..1a93d74e 100644 --- a/core/lib/src/form/parser.rs +++ b/core/lib/src/form/parser.rs @@ -3,8 +3,8 @@ use either::Either; use crate::request::{Request, local_cache_once}; use crate::data::{Data, Limits, Outcome}; -use crate::form::{SharedStack, prelude::*}; use crate::http::{RawStr, Status}; +use crate::form::prelude::*; type Result<'r, T> = std::result::Result>; diff --git a/core/lib/src/sentinel.rs b/core/lib/src/sentinel.rs index df503c31..02d17546 100644 --- a/core/lib/src/sentinel.rs +++ b/core/lib/src/sentinel.rs @@ -447,7 +447,6 @@ pub mod resolution { #[cfg(test)] mod test { use std::any::TypeId; - use crate::sentinel::resolve; struct NotASentinel; struct YesASentinel; diff --git a/core/lib/src/shield/policy.rs b/core/lib/src/shield/policy.rs index 3ac3bc79..29b493c2 100644 --- a/core/lib/src/shield/policy.rs +++ b/core/lib/src/shield/policy.rs @@ -7,7 +7,7 @@ use indexmap::IndexMap; use rocket_http::{ext::IntoCollection, private::SmallVec}; use time::Duration; -use crate::http::{Header, uri::Absolute, uncased::{UncasedStr, Uncased}}; +use crate::http::{Header, uri::Absolute, uncased::Uncased}; /// Trait implemented by security and privacy policy headers. /// @@ -64,22 +64,6 @@ pub trait Policy: Default + Send + Sync + 'static { fn header(&self) -> Header<'static>; } -/// Hack to make `Policy` Object-Safe. -pub(crate) trait SubPolicy: Send + Sync { - fn name(&self) -> &'static UncasedStr; - fn header(&self) -> Header<'static>; -} - -impl SubPolicy for P { - fn name(&self) -> &'static UncasedStr { - P::NAME.into() - } - - fn header(&self) -> Header<'static> { - Policy::header(self) - } -} - macro_rules! impl_policy { ($T:ty, $name:expr) => ( impl Policy for $T { diff --git a/core/lib/tests/derive-reexports.rs b/core/lib/tests/derive-reexports.rs index 2f719f8f..0c8cde9e 100644 --- a/core/lib/tests/derive-reexports.rs +++ b/core/lib/tests/derive-reexports.rs @@ -1,5 +1,3 @@ -use rocket; - use rocket::{get, routes}; use rocket::form::{FromForm, FromFormField}; use rocket::response::Responder; diff --git a/core/lib/tests/forward-includes-status-1560.rs b/core/lib/tests/forward-includes-status-1560.rs index b325672a..f5b8190d 100644 --- a/core/lib/tests/forward-includes-status-1560.rs +++ b/core/lib/tests/forward-includes-status-1560.rs @@ -56,9 +56,10 @@ fn catcher() -> &'static str { mod tests { use super::*; + use rocket::routes; use rocket::local::blocking::Client; - use rocket::http::{Header, Status}; + use rocket::http::Header; #[test] fn authorized_forwards() { diff --git a/core/lib/tests/head_handling.rs b/core/lib/tests/head_handling.rs index 367d212a..330ddc2c 100644 --- a/core/lib/tests/head_handling.rs +++ b/core/lib/tests/head_handling.rs @@ -23,7 +23,7 @@ mod head_handling_tests { use rocket::Route; use rocket::local::blocking::Client; - use rocket::http::{Status, ContentType}; + use rocket::http::ContentType; fn routes() -> Vec { routes![index, empty, other]