Address new nightly compiler warnings.

This commit is contained in:
Sergio Benitez 2024-03-19 14:08:14 -07:00
parent 1619bbbddc
commit d9249db6d6
16 changed files with 17 additions and 55 deletions

View File

@ -1,6 +1,8 @@
#[cfg(all(feature = "diesel_sqlite_pool", feature = "diesel_postgres_pool"))] #[cfg(all(feature = "diesel_sqlite_pool", feature = "diesel_postgres_pool"))]
mod databases_tests { mod databases_tests {
use rocket_sync_db_pools::{database, diesel}; #![allow(dead_code)]
use rocket_sync_db_pools::database;
#[database("example")] #[database("example")]
struct ExampleDb(diesel::SqliteConnection); struct ExampleDb(diesel::SqliteConnection);

View File

@ -5,6 +5,7 @@ mod sqlite_shutdown_test {
use rocket_sync_db_pools::database; use rocket_sync_db_pools::database;
#[database("test")] #[database("test")]
#[allow(dead_code)]
struct Pool(diesel::SqliteConnection); struct Pool(diesel::SqliteConnection);
async fn rocket() -> Rocket<Build> { async fn rocket() -> Rocket<Build> {

View File

@ -1,7 +1,7 @@
use std::path::Path; use std::path::Path;
use std::error::Error; use std::error::Error;
use syn::{self, Ident, LitStr}; use syn::{Ident, LitStr};
use devise::ext::SpanDiagnosticExt; use devise::ext::SpanDiagnosticExt;
use proc_macro2::TokenStream; use proc_macro2::TokenStream;

View File

@ -1,6 +1,6 @@
use crate::http::uncased::UncasedStr; use crate::http::uncased::UncasedStr;
use syn::{self, Ident, ext::IdentExt}; use syn::{Ident, ext::IdentExt};
use proc_macro2::{Span, TokenStream}; use proc_macro2::{Span, TokenStream};
/// A "name" read by codegen, which may or may not be an identifier. A `Name` is /// A "name" read by codegen, which may or may not be an identifier. A `Name` is

View File

@ -4,7 +4,7 @@ use std::ops::Deref;
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
use std::borrow::Cow; 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 proc_macro2::{Span, TokenStream};
use devise::ext::{PathExt, TypeExt as _}; use devise::ext::{PathExt, TypeExt as _};
use rocket_http::ext::IntoOwned; use rocket_http::ext::IntoOwned;
@ -21,17 +21,12 @@ pub trait ReturnTypeExt {
fn ty(&self) -> Option<&syn::Type>; fn ty(&self) -> Option<&syn::Type>;
} }
pub trait TokenStreamExt {
fn respanned(&self, span: Span) -> Self;
}
pub trait FnArgExt { pub trait FnArgExt {
fn typed(&self) -> Option<(&syn::Ident, &syn::Type)>; fn typed(&self) -> Option<(&syn::Ident, &syn::Type)>;
fn wild(&self) -> Option<&syn::PatWild>; fn wild(&self) -> Option<&syn::PatWild>;
} }
pub trait TypeExt { pub trait TypeExt {
fn unfold(&self) -> Vec<Child<'_>>;
fn unfold_with_ty_macros(&self, names: &[&str], mapper: MacTyMapFn) -> Vec<Child<'_>>; fn unfold_with_ty_macros(&self, names: &[&str], mapper: MacTyMapFn) -> Vec<Child<'_>>;
fn is_concrete(&self, generic_ident: &[&Ident]) -> bool; 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 { impl FnArgExt for syn::FnArg {
fn typed(&self) -> Option<(&Ident, &syn::Type)> { fn typed(&self) -> Option<(&Ident, &syn::Type)> {
match self { match self {
@ -154,10 +140,6 @@ fn macro_inner_ty(t: &syn::TypeMacro, names: &[&str], m: MacTyMapFn) -> Option<s
} }
impl TypeExt for syn::Type { impl TypeExt for syn::Type {
fn unfold(&self) -> Vec<Child<'_>> {
self.unfold_with_ty_macros(&[], |_| None)
}
fn unfold_with_ty_macros(&self, names: &[&str], mapper: MacTyMapFn) -> Vec<Child<'_>> { fn unfold_with_ty_macros(&self, names: &[&str], mapper: MacTyMapFn) -> Vec<Child<'_>> {
struct Visitor<'a, 'm> { struct Visitor<'a, 'm> {
parents: Vec<Cow<'a, syn::Type>>, parents: Vec<Cow<'a, syn::Type>>,
@ -240,10 +222,10 @@ impl GenericsExt for syn::Generics {
mod tests { mod tests {
#[test] #[test]
fn test_type_unfold_is_generic() { fn test_type_unfold_is_generic() {
use super::{TypeExt, syn}; use super::TypeExt;
let ty: syn::Type = syn::parse_quote!(A<B, C<impl Foo>, Box<dyn Foo>, Option<T>>); let ty: syn::Type = syn::parse_quote!(A<B, C<impl Foo>, Box<dyn Foo>, Option<T>>);
let children = ty.unfold(); let children = ty.unfold_with_ty_macros(&[], |_| None);
assert_eq!(children.len(), 8); assert_eq!(children.len(), 8);
let gen_ident = format_ident!("T"); let gen_ident = format_ident!("T");

View File

@ -135,7 +135,6 @@ impl fmt::Display for Method {
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
mod serde { mod serde {
use std::fmt;
use super::*; use super::*;
use serde_::ser::{Serialize, Serializer}; use serde_::ser::{Serialize, Serializer};

View File

@ -1,4 +1,3 @@
use crate::uri::{Origin, Authority, Absolute, Asterisk};
use crate::parse::uri::*; use crate::parse::uri::*;
macro_rules! assert_parse_eq { macro_rules! assert_parse_eq {

View File

@ -1,14 +1,13 @@
use std::fmt;
use std::borrow::{Borrow, Cow}; use std::borrow::{Borrow, Cow};
use std::convert::AsRef;
use std::cmp::Ordering; use std::cmp::Ordering;
use std::str::Utf8Error; use std::str::Utf8Error;
use std::fmt;
use ref_cast::RefCast; use ref_cast::RefCast;
use stable_pattern::{Pattern, Searcher, ReverseSearcher, Split, SplitInternal}; 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::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. /// A reference to a string inside of a raw HTTP message.
/// ///

View File

@ -382,7 +382,6 @@ impl Ord for Status {
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
mod serde { mod serde {
use std::fmt;
use super::*; use super::*;
use serde_::ser::{Serialize, Serializer}; use serde_::ser::{Serialize, Serializer};

View File

@ -4,8 +4,7 @@ use crate::Request;
use crate::outcome::try_outcome; use crate::outcome::try_outcome;
use crate::data::{Data, FromData, Outcome}; use crate::data::{Data, FromData, Outcome};
use crate::http::{RawStr, ext::IntoOwned}; use crate::http::{RawStr, ext::IntoOwned};
use crate::form::{SharedStack, parser::{Parser, RawStrParser}}; use crate::form::prelude::{*, parser::{Parser, RawStrParser}};
use crate::form::prelude::*;
/// A data guard for [`FromForm`] types. /// A data guard for [`FromForm`] types.
/// ///

View File

@ -3,8 +3,8 @@ use either::Either;
use crate::request::{Request, local_cache_once}; use crate::request::{Request, local_cache_once};
use crate::data::{Data, Limits, Outcome}; use crate::data::{Data, Limits, Outcome};
use crate::form::{SharedStack, prelude::*};
use crate::http::{RawStr, Status}; use crate::http::{RawStr, Status};
use crate::form::prelude::*;
type Result<'r, T> = std::result::Result<T, Error<'r>>; type Result<'r, T> = std::result::Result<T, Error<'r>>;

View File

@ -447,7 +447,6 @@ pub mod resolution {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use std::any::TypeId; use std::any::TypeId;
use crate::sentinel::resolve;
struct NotASentinel; struct NotASentinel;
struct YesASentinel; struct YesASentinel;

View File

@ -7,7 +7,7 @@ use indexmap::IndexMap;
use rocket_http::{ext::IntoCollection, private::SmallVec}; use rocket_http::{ext::IntoCollection, private::SmallVec};
use time::Duration; 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. /// Trait implemented by security and privacy policy headers.
/// ///
@ -64,22 +64,6 @@ pub trait Policy: Default + Send + Sync + 'static {
fn header(&self) -> Header<'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<P: Policy> SubPolicy for P {
fn name(&self) -> &'static UncasedStr {
P::NAME.into()
}
fn header(&self) -> Header<'static> {
Policy::header(self)
}
}
macro_rules! impl_policy { macro_rules! impl_policy {
($T:ty, $name:expr) => ( ($T:ty, $name:expr) => (
impl Policy for $T { impl Policy for $T {

View File

@ -1,5 +1,3 @@
use rocket;
use rocket::{get, routes}; use rocket::{get, routes};
use rocket::form::{FromForm, FromFormField}; use rocket::form::{FromForm, FromFormField};
use rocket::response::Responder; use rocket::response::Responder;

View File

@ -56,9 +56,10 @@ fn catcher() -> &'static str {
mod tests { mod tests {
use super::*; use super::*;
use rocket::routes; use rocket::routes;
use rocket::local::blocking::Client; use rocket::local::blocking::Client;
use rocket::http::{Header, Status}; use rocket::http::Header;
#[test] #[test]
fn authorized_forwards() { fn authorized_forwards() {

View File

@ -23,7 +23,7 @@ mod head_handling_tests {
use rocket::Route; use rocket::Route;
use rocket::local::blocking::Client; use rocket::local::blocking::Client;
use rocket::http::{Status, ContentType}; use rocket::http::ContentType;
fn routes() -> Vec<Route> { fn routes() -> Vec<Route> {
routes![index, empty, other] routes![index, empty, other]