mirror of https://github.com/rwf2/Rocket.git
Use workspace lints. Resolve new nightly warnings.
This commit is contained in:
parent
bb48a4d724
commit
3079dbfa85
15
Cargo.toml
15
Cargo.toml
|
@ -12,3 +12,18 @@ members = [
|
||||||
"contrib/ws/",
|
"contrib/ws/",
|
||||||
"docs/tests",
|
"docs/tests",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[workspace.lints.rust]
|
||||||
|
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(nightly)'] }
|
||||||
|
rust_2018_idioms = "warn"
|
||||||
|
async_fn_in_trait = "allow"
|
||||||
|
refining_impl_trait = "allow"
|
||||||
|
# unreachable_pub = "warn"
|
||||||
|
# single_use_lifetimes = "warn"
|
||||||
|
# missing_docs = "warn"
|
||||||
|
|
||||||
|
[workspace.lints.clippy]
|
||||||
|
type_complexity = "allow"
|
||||||
|
module_inception = "allow"
|
||||||
|
multiple_bound_locations = "allow"
|
||||||
|
manual_range_contains = "allow"
|
||||||
|
|
|
@ -13,6 +13,9 @@ rust-version = "1.75"
|
||||||
[lib]
|
[lib]
|
||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
devise = "0.4"
|
devise = "0.4"
|
||||||
quote = "1"
|
quote = "1"
|
||||||
|
|
|
@ -13,6 +13,9 @@ rust-version = "1.75"
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# deadpool features
|
# deadpool features
|
||||||
deadpool_postgres = ["deadpool-postgres", "deadpool"]
|
deadpool_postgres = ["deadpool-postgres", "deadpool"]
|
||||||
|
|
|
@ -12,9 +12,8 @@ license = "MIT OR Apache-2.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.75"
|
rust-version = "1.75"
|
||||||
|
|
||||||
[lints.clippy]
|
[lints]
|
||||||
type_complexity = "allow"
|
workspace = true
|
||||||
multiple_bound_locations = "allow"
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
tera = ["dep:tera"]
|
tera = ["dep:tera"]
|
||||||
|
|
|
@ -13,6 +13,9 @@ rust-version = "1.75"
|
||||||
[lib]
|
[lib]
|
||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
devise = "0.4"
|
devise = "0.4"
|
||||||
|
|
|
@ -10,6 +10,9 @@ license = "MIT OR Apache-2.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.75"
|
rust-version = "1.75"
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
diesel_sqlite_pool = ["diesel/sqlite", "diesel/r2d2"]
|
diesel_sqlite_pool = ["diesel/sqlite", "diesel/r2d2"]
|
||||||
diesel_postgres_pool = ["diesel/postgres", "diesel/r2d2"]
|
diesel_postgres_pool = ["diesel/postgres", "diesel/r2d2"]
|
||||||
|
|
|
@ -11,8 +11,8 @@ mod databases_tests {
|
||||||
struct PrimaryDb(diesel::PgConnection);
|
struct PrimaryDb(diesel::PgConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "databases", feature = "sqlite_pool"))]
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[cfg(all(feature = "sqlite_pool"))]
|
||||||
mod rusqlite_integration_test {
|
mod rusqlite_integration_test {
|
||||||
use rocket_sync_db_pools::{rusqlite, database};
|
use rocket_sync_db_pools::{rusqlite, database};
|
||||||
|
|
||||||
|
@ -58,13 +58,13 @@ mod rusqlite_integration_test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[cfg(feature = "databases")]
|
|
||||||
mod sentinel_and_runtime_test {
|
mod sentinel_and_runtime_test {
|
||||||
use rocket::{Rocket, Build};
|
use rocket::{Rocket, Build};
|
||||||
use r2d2::{ManageConnection, Pool};
|
use r2d2::{ManageConnection, Pool};
|
||||||
use rocket_sync_db_pools::{database, Poolable, PoolResult};
|
use rocket_sync_db_pools::{database, Poolable, PoolResult};
|
||||||
use tokio::runtime::Runtime;
|
use tokio::runtime::Runtime;
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
struct ContainsRuntime(Runtime);
|
struct ContainsRuntime(Runtime);
|
||||||
struct TestConnection;
|
struct TestConnection;
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,9 @@ license = "MIT OR Apache-2.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.75"
|
rust-version = "1.75"
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["tungstenite"]
|
default = ["tungstenite"]
|
||||||
tungstenite = ["tokio-tungstenite"]
|
tungstenite = ["tokio-tungstenite"]
|
||||||
|
|
|
@ -12,13 +12,12 @@ license = "MIT OR Apache-2.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.75"
|
rust-version = "1.75"
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
||||||
[lints.clippy]
|
|
||||||
manual_range_contains = "allow"
|
|
||||||
large_enum_variant = "allow"
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
indexmap = "2"
|
indexmap = "2"
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
|
|
|
@ -187,7 +187,7 @@ impl TypeExt for syn::Type {
|
||||||
fn is_concrete(&self, generics: &[&Ident]) -> bool {
|
fn is_concrete(&self, generics: &[&Ident]) -> bool {
|
||||||
struct ConcreteVisitor<'i>(bool, &'i [&'i Ident]);
|
struct ConcreteVisitor<'i>(bool, &'i [&'i Ident]);
|
||||||
|
|
||||||
impl<'a, 'i> Visit<'a> for ConcreteVisitor<'i> {
|
impl<'a> Visit<'a> for ConcreteVisitor<'_> {
|
||||||
fn visit_type(&mut self, ty: &'a syn::Type) {
|
fn visit_type(&mut self, ty: &'a syn::Type) {
|
||||||
use syn::Type::*;
|
use syn::Type::*;
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,9 @@ use rocket::local::blocking::Client;
|
||||||
use rocket::http::Status;
|
use rocket::http::Status;
|
||||||
|
|
||||||
#[catch(404)] fn not_found_0() -> &'static str { "404-0" }
|
#[catch(404)] fn not_found_0() -> &'static str { "404-0" }
|
||||||
#[catch(404)] fn not_found_1(_: &Request) -> &'static str { "404-1" }
|
#[catch(404)] fn not_found_1(_: &Request<'_>) -> &'static str { "404-1" }
|
||||||
#[catch(404)] fn not_found_2(_: Status, _: &Request) -> &'static str { "404-2" }
|
#[catch(404)] fn not_found_2(_: Status, _: &Request<'_>) -> &'static str { "404-2" }
|
||||||
#[catch(default)] fn all(_: Status, r: &Request) -> String { r.uri().to_string() }
|
#[catch(default)] fn all(_: Status, r: &Request<'_>) -> String { r.uri().to_string() }
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_simple_catchers() {
|
fn test_simple_catchers() {
|
||||||
|
@ -37,10 +37,10 @@ fn test_simple_catchers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/<code>")] fn forward(code: u16) -> Status { Status::new(code) }
|
#[get("/<code>")] fn forward(code: u16) -> Status { Status::new(code) }
|
||||||
#[catch(400)] fn forward_400(status: Status, _: &Request) -> String { status.code.to_string() }
|
#[catch(400)] fn forward_400(status: Status, _: &Request<'_>) -> String { status.code.to_string() }
|
||||||
#[catch(404)] fn forward_404(status: Status, _: &Request) -> String { status.code.to_string() }
|
#[catch(404)] fn forward_404(status: Status, _: &Request<'_>) -> String { status.code.to_string() }
|
||||||
#[catch(444)] fn forward_444(status: Status, _: &Request) -> String { status.code.to_string() }
|
#[catch(444)] fn forward_444(status: Status, _: &Request<'_>) -> String { status.code.to_string() }
|
||||||
#[catch(500)] fn forward_500(status: Status, _: &Request) -> String { status.code.to_string() }
|
#[catch(500)] fn forward_500(status: Status, _: &Request<'_>) -> String { status.code.to_string() }
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_status_param() {
|
fn test_status_param() {
|
||||||
|
|
|
@ -243,23 +243,23 @@ fn field_renaming() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let form_string = &["single=123", "some_case=hi_im_here"].join("&");
|
let form_string = &["single=123", "some_case=hi_im_here"].join("&");
|
||||||
let form: Option<MultiName> = strict(&form_string).ok();
|
let form: Option<MultiName<'_>> = strict(&form_string).ok();
|
||||||
assert_eq!(form, Some(MultiName { single: 123, some_case: "hi_im_here", }));
|
assert_eq!(form, Some(MultiName { single: 123, some_case: "hi_im_here", }));
|
||||||
|
|
||||||
let form_string = &["single=123", "SomeCase=HiImHere"].join("&");
|
let form_string = &["single=123", "SomeCase=HiImHere"].join("&");
|
||||||
let form: Option<MultiName> = strict(&form_string).ok();
|
let form: Option<MultiName<'_>> = strict(&form_string).ok();
|
||||||
assert_eq!(form, Some(MultiName { single: 123, some_case: "HiImHere", }));
|
assert_eq!(form, Some(MultiName { single: 123, some_case: "HiImHere", }));
|
||||||
|
|
||||||
let form_string = &["single=123", "some_case=hi_im_here", "SomeCase=HiImHere"].join("&");
|
let form_string = &["single=123", "some_case=hi_im_here", "SomeCase=HiImHere"].join("&");
|
||||||
let form: Option<MultiName> = strict(&form_string).ok();
|
let form: Option<MultiName<'_>> = strict(&form_string).ok();
|
||||||
assert!(form.is_none());
|
assert!(form.is_none());
|
||||||
|
|
||||||
let form_string = &["single=123", "some_case=hi_im_here", "SomeCase=HiImHere"].join("&");
|
let form_string = &["single=123", "some_case=hi_im_here", "SomeCase=HiImHere"].join("&");
|
||||||
let form: Option<MultiName> = lenient(&form_string).ok();
|
let form: Option<MultiName<'_>> = lenient(&form_string).ok();
|
||||||
assert_eq!(form, Some(MultiName { single: 123, some_case: "hi_im_here", }));
|
assert_eq!(form, Some(MultiName { single: 123, some_case: "hi_im_here", }));
|
||||||
|
|
||||||
let form_string = &["single=123", "SomeCase=HiImHere", "some_case=hi_im_here"].join("&");
|
let form_string = &["single=123", "SomeCase=HiImHere", "some_case=hi_im_here"].join("&");
|
||||||
let form: Option<MultiName> = lenient(&form_string).ok();
|
let form: Option<MultiName<'_>> = lenient(&form_string).ok();
|
||||||
assert_eq!(form, Some(MultiName { single: 123, some_case: "HiImHere", }));
|
assert_eq!(form, Some(MultiName { single: 123, some_case: "HiImHere", }));
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, FromForm)]
|
#[derive(Debug, PartialEq, FromForm)]
|
||||||
|
@ -273,19 +273,19 @@ fn field_renaming() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let form_string = &["HeLLO=123", "sOMECASe=hi_im_here"].join("&");
|
let form_string = &["HeLLO=123", "sOMECASe=hi_im_here"].join("&");
|
||||||
let form: Option<CaseInsensitive> = strict(&form_string).ok();
|
let form: Option<CaseInsensitive<'_>> = strict(&form_string).ok();
|
||||||
assert_eq!(form, Some(CaseInsensitive { hello: 123, some_case: "hi_im_here", }));
|
assert_eq!(form, Some(CaseInsensitive { hello: 123, some_case: "hi_im_here", }));
|
||||||
|
|
||||||
let form_string = &["hello=456", "SomeCase=HiImHere"].join("&");
|
let form_string = &["hello=456", "SomeCase=HiImHere"].join("&");
|
||||||
let form: Option<CaseInsensitive> = strict(&form_string).ok();
|
let form: Option<CaseInsensitive<'_>> = strict(&form_string).ok();
|
||||||
assert_eq!(form, Some(CaseInsensitive { hello: 456, some_case: "HiImHere", }));
|
assert_eq!(form, Some(CaseInsensitive { hello: 456, some_case: "HiImHere", }));
|
||||||
|
|
||||||
let form_string = &["helLO=789", "some_case=hi_there"].join("&");
|
let form_string = &["helLO=789", "some_case=hi_there"].join("&");
|
||||||
let form: Option<CaseInsensitive> = strict(&form_string).ok();
|
let form: Option<CaseInsensitive<'_>> = strict(&form_string).ok();
|
||||||
assert_eq!(form, Some(CaseInsensitive { hello: 789, some_case: "hi_there", }));
|
assert_eq!(form, Some(CaseInsensitive { hello: 789, some_case: "hi_there", }));
|
||||||
|
|
||||||
let form_string = &["hello=123", "SOme_case=hi_im_here"].join("&");
|
let form_string = &["hello=123", "SOme_case=hi_im_here"].join("&");
|
||||||
let form: Option<CaseInsensitive> = strict(&form_string).ok();
|
let form: Option<CaseInsensitive<'_>> = strict(&form_string).ok();
|
||||||
assert!(form.is_none());
|
assert!(form.is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,7 +479,7 @@ fn test_multi() {
|
||||||
more_dogs: HashMap<&'r str, Dog>,
|
more_dogs: HashMap<&'r str, Dog>,
|
||||||
}
|
}
|
||||||
|
|
||||||
let multi: Multi = strict("checks=true&checks=false&checks=false\
|
let multi: Multi<'_> = strict("checks=true&checks=false&checks=false\
|
||||||
&names=Sam&names[]=Smith&names[]=Bob\
|
&names=Sam&names[]=Smith&names[]=Bob\
|
||||||
&news[]=Here&news[]=also here\
|
&news[]=Here&news[]=also here\
|
||||||
&dogs[fido].barks=true&dogs[George].barks=false\
|
&dogs[fido].barks=true&dogs[George].barks=false\
|
||||||
|
@ -545,17 +545,17 @@ struct Person<'r> {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_nested_multi() {
|
fn test_nested_multi() {
|
||||||
let person: Person = lenient("sitting.barks=true&sitting.trained=true").unwrap();
|
let person: Person<'_> = lenient("sitting.barks=true&sitting.trained=true").unwrap();
|
||||||
assert_eq!(person, Person {
|
assert_eq!(person, Person {
|
||||||
sitting: Dog { barks: true, trained: true },
|
sitting: Dog { barks: true, trained: true },
|
||||||
cats: vec![],
|
cats: vec![],
|
||||||
dogs: vec![],
|
dogs: vec![],
|
||||||
});
|
});
|
||||||
|
|
||||||
let person = strict::<Person>("sitting.barks=true&sitting.trained=true");
|
let person = strict::<Person<'_>>("sitting.barks=true&sitting.trained=true");
|
||||||
assert!(person.is_err());
|
assert!(person.is_err());
|
||||||
|
|
||||||
let person: Person = lenient("sitting.barks=true&sitting.trained=true\
|
let person: Person<'_> = lenient("sitting.barks=true&sitting.trained=true\
|
||||||
&dogs[0].name=fido&dogs[0].pet.trained=yes&dogs[0].age=7&dogs[0].pet.barks=no\
|
&dogs[0].name=fido&dogs[0].pet.trained=yes&dogs[0].age=7&dogs[0].pet.barks=no\
|
||||||
").unwrap();
|
").unwrap();
|
||||||
assert_eq!(person, Person {
|
assert_eq!(person, Person {
|
||||||
|
@ -568,11 +568,11 @@ fn test_nested_multi() {
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
let person = strict::<Person>("sitting.barks=true&sitting.trained=true\
|
let person = strict::<Person<'_>>("sitting.barks=true&sitting.trained=true\
|
||||||
&dogs[0].name=fido&dogs[0].pet.trained=yes&dogs[0].age=7&dogs[0].pet.barks=no");
|
&dogs[0].name=fido&dogs[0].pet.trained=yes&dogs[0].age=7&dogs[0].pet.barks=no");
|
||||||
assert!(person.is_err());
|
assert!(person.is_err());
|
||||||
|
|
||||||
let person: Person = lenient("sitting.trained=no&sitting.barks=true\
|
let person: Person<'_> = lenient("sitting.trained=no&sitting.barks=true\
|
||||||
&dogs[0].name=fido&dogs[0].pet.trained=yes&dogs[0].age=7&dogs[0].pet.barks=no\
|
&dogs[0].name=fido&dogs[0].pet.trained=yes&dogs[0].age=7&dogs[0].pet.barks=no\
|
||||||
&dogs[1].pet.barks=true&dogs[1].name=Bob&dogs[1].pet.trained=no&dogs[1].age=1\
|
&dogs[1].pet.barks=true&dogs[1].name=Bob&dogs[1].pet.trained=no&dogs[1].age=1\
|
||||||
").unwrap();
|
").unwrap();
|
||||||
|
@ -593,7 +593,7 @@ fn test_nested_multi() {
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
let person: Person = strict("sitting.barks=true&sitting.trained=no\
|
let person: Person<'_> = strict("sitting.barks=true&sitting.trained=no\
|
||||||
&dogs[0].name=fido&dogs[0].pet.trained=yes&dogs[0].age=7&dogs[0].pet.barks=no\
|
&dogs[0].name=fido&dogs[0].pet.trained=yes&dogs[0].age=7&dogs[0].pet.barks=no\
|
||||||
&dogs[1].pet.barks=true&dogs[1].name=Bob&dogs[1].pet.trained=no&dogs[1].age=1\
|
&dogs[1].pet.barks=true&dogs[1].name=Bob&dogs[1].pet.trained=no&dogs[1].age=1\
|
||||||
&cats[george].pet.nip=paws&cats[george].name=George&cats[george].age=2\
|
&cats[george].pet.nip=paws&cats[george].name=George&cats[george].age=2\
|
||||||
|
@ -636,7 +636,7 @@ fn test_multipart() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rocket::post("/", data = "<form>")]
|
#[rocket::post("/", data = "<form>")]
|
||||||
fn form(form: Form<MyForm>) {
|
fn form(form: Form<MyForm<'_>>) {
|
||||||
assert_eq!(form.names, &["abcd", "123"]);
|
assert_eq!(form.names, &["abcd", "123"]);
|
||||||
assert_eq!(form.file.name(), Some("foo"));
|
assert_eq!(form.file.name(), Some("foo"));
|
||||||
}
|
}
|
||||||
|
@ -797,11 +797,11 @@ fn test_defaults() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// `field2` has no default.
|
// `field2` has no default.
|
||||||
assert!(lenient::<FormWithDefaults>("").is_err());
|
assert!(lenient::<FormWithDefaults<'_>>("").is_err());
|
||||||
|
|
||||||
// every other field should.
|
// every other field should.
|
||||||
let form_string = &["field2=102"].join("&");
|
let form_string = &["field2=102"].join("&");
|
||||||
let form1: Option<FormWithDefaults> = lenient(&form_string).ok();
|
let form1: Option<FormWithDefaults<'_>> = lenient(&form_string).ok();
|
||||||
assert_eq!(form1, Some(FormWithDefaults {
|
assert_eq!(form1, Some(FormWithDefaults {
|
||||||
field1: 100,
|
field1: 100,
|
||||||
field2: 102,
|
field2: 102,
|
||||||
|
@ -834,12 +834,12 @@ fn test_defaults() {
|
||||||
),
|
),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let form2: Option<FormWithDefaults> = strict(&form_string).ok();
|
let form2: Option<FormWithDefaults<'_>> = strict(&form_string).ok();
|
||||||
assert!(form2.is_none());
|
assert!(form2.is_none());
|
||||||
|
|
||||||
// Ensure actual form field values take precedence.
|
// Ensure actual form field values take precedence.
|
||||||
let form_string = &["field1=101", "field2=102", "field3=true", "field5=true"].join("&");
|
let form_string = &["field1=101", "field2=102", "field3=true", "field5=true"].join("&");
|
||||||
let form3: Option<FormWithDefaults> = lenient(&form_string).ok();
|
let form3: Option<FormWithDefaults<'_>> = lenient(&form_string).ok();
|
||||||
assert_eq!(form3, Some(FormWithDefaults {
|
assert_eq!(form3, Some(FormWithDefaults {
|
||||||
field1: 101,
|
field1: 101,
|
||||||
field2: 102,
|
field2: 102,
|
||||||
|
@ -852,7 +852,7 @@ fn test_defaults() {
|
||||||
// And that strict parsing still works.
|
// And that strict parsing still works.
|
||||||
let form = form3.unwrap();
|
let form = form3.unwrap();
|
||||||
let form_string = format!("{}", &form as &dyn UriDisplay<Query>);
|
let form_string = format!("{}", &form as &dyn UriDisplay<Query>);
|
||||||
let form4: form::Result<'_, FormWithDefaults> = strict(&form_string);
|
let form4: form::Result<'_, FormWithDefaults<'_>> = strict(&form_string);
|
||||||
assert_eq!(form4, Ok(form), "parse from {}", form_string);
|
assert_eq!(form4, Ok(form), "parse from {}", form_string);
|
||||||
|
|
||||||
#[derive(FromForm, UriDisplayQuery, PartialEq, Debug)]
|
#[derive(FromForm, UriDisplayQuery, PartialEq, Debug)]
|
||||||
|
@ -940,22 +940,22 @@ struct TokenOwned(String);
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn wrapper_works() {
|
fn wrapper_works() {
|
||||||
let form: Option<Token> = lenient("").ok();
|
let form: Option<Token<'_>> = lenient("").ok();
|
||||||
assert_eq!(form, Some(Token("some default hello")));
|
assert_eq!(form, Some(Token("some default hello")));
|
||||||
|
|
||||||
let form: Option<TokenOwned> = lenient("").ok();
|
let form: Option<TokenOwned> = lenient("").ok();
|
||||||
assert_eq!(form, Some(TokenOwned("123456".into())));
|
assert_eq!(form, Some(TokenOwned("123456".into())));
|
||||||
|
|
||||||
let errors = strict::<Token>("").unwrap_err();
|
let errors = strict::<Token<'_>>("").unwrap_err();
|
||||||
assert!(errors.iter().any(|e| matches!(e.kind, ErrorKind::Missing)));
|
assert!(errors.iter().any(|e| matches!(e.kind, ErrorKind::Missing)));
|
||||||
|
|
||||||
let form: Option<Token> = lenient("=hi there").ok();
|
let form: Option<Token<'_>> = lenient("=hi there").ok();
|
||||||
assert_eq!(form, Some(Token("hi there")));
|
assert_eq!(form, Some(Token("hi there")));
|
||||||
|
|
||||||
let form: Option<TokenOwned> = strict_encoded("=2318").ok();
|
let form: Option<TokenOwned> = strict_encoded("=2318").ok();
|
||||||
assert_eq!(form, Some(TokenOwned("2318".into())));
|
assert_eq!(form, Some(TokenOwned("2318".into())));
|
||||||
|
|
||||||
let errors = lenient::<Token>("=hi").unwrap_err();
|
let errors = lenient::<Token<'_>>("=hi").unwrap_err();
|
||||||
assert!(errors.iter().any(|e| matches!(e.kind, ErrorKind::InvalidLength { .. })));
|
assert!(errors.iter().any(|e| matches!(e.kind, ErrorKind::InvalidLength { .. })));
|
||||||
|
|
||||||
let errors = lenient::<TokenOwned>("=hellothere").unwrap_err();
|
let errors = lenient::<TokenOwned>("=hellothere").unwrap_err();
|
||||||
|
|
|
@ -127,19 +127,20 @@ async fn generic_responder() {
|
||||||
let local_req = client.get("/");
|
let local_req = client.get("/");
|
||||||
let req = local_req.inner();
|
let req = local_req.inner();
|
||||||
|
|
||||||
let v: MyResult<_, (), ContentType, Cookie<'static>> = MyResult::Ok(Json("hi"));
|
let v: MyResult<'_, _, (), ContentType, Cookie<'static>> = MyResult::Ok(Json("hi"));
|
||||||
let mut r = v.respond_to(req).unwrap();
|
let mut r = v.respond_to(req).unwrap();
|
||||||
assert_eq!(r.status(), Status::Ok);
|
assert_eq!(r.status(), Status::Ok);
|
||||||
assert_eq!(r.content_type().unwrap(), ContentType::JSON);
|
assert_eq!(r.content_type().unwrap(), ContentType::JSON);
|
||||||
assert_eq!(r.body_mut().to_string().await.unwrap(), "\"hi\"");
|
assert_eq!(r.body_mut().to_string().await.unwrap(), "\"hi\"");
|
||||||
|
|
||||||
let v: MyResult<(), &[u8], _, _> = MyResult::Err(&[7, 13, 23], ContentType::JPEG, Accept::Text);
|
let bytes = &[7, 13, 23];
|
||||||
|
let v: MyResult<'_, (), &[u8], _, _> = MyResult::Err(bytes, ContentType::JPEG, Accept::Text);
|
||||||
let mut r = v.respond_to(req).unwrap();
|
let mut r = v.respond_to(req).unwrap();
|
||||||
assert_eq!(r.status(), Status::NotFound);
|
assert_eq!(r.status(), Status::NotFound);
|
||||||
assert_eq!(r.content_type().unwrap(), ContentType::JPEG);
|
assert_eq!(r.content_type().unwrap(), ContentType::JPEG);
|
||||||
assert_eq!(r.body_mut().to_bytes().await.unwrap(), vec![7, 13, 23]);
|
assert_eq!(r.body_mut().to_bytes().await.unwrap(), bytes);
|
||||||
|
|
||||||
let v: MyResult<(), &[u8], ContentType, Accept> = MyResult::Other("beep beep");
|
let v: MyResult<'_, (), &[u8], ContentType, Accept> = MyResult::Other("beep beep");
|
||||||
let mut r = v.respond_to(req).unwrap();
|
let mut r = v.respond_to(req).unwrap();
|
||||||
assert_eq!(r.status(), Status::InternalServerError);
|
assert_eq!(r.status(), Status::InternalServerError);
|
||||||
assert_eq!(r.content_type().unwrap(), ContentType::Text);
|
assert_eq!(r.content_type().unwrap(), ContentType::Text);
|
||||||
|
|
|
@ -15,7 +15,7 @@ fn swap(r#raw: String, bare: String) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[catch(400)]
|
#[catch(400)]
|
||||||
fn catch(r#raw: &rocket::Request) -> String {
|
fn catch(r#raw: &rocket::Request<'_>) -> String {
|
||||||
format!("{}", raw.method())
|
format!("{}", raw.method())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,16 +15,14 @@ categories = ["web-programming"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.75"
|
rust-version = "1.75"
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
serde = ["dep:serde", "uncased/with-serde-alloc"]
|
serde = ["dep:serde", "uncased/with-serde-alloc"]
|
||||||
uuid = ["dep:uuid"]
|
uuid = ["dep:uuid"]
|
||||||
|
|
||||||
[lints.clippy]
|
|
||||||
module_inception = "allow"
|
|
||||||
multiple_bound_locations = "allow"
|
|
||||||
manual_range_contains = "allow"
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tinyvec = { version = "1.6", features = ["std", "rustc_1_57"] }
|
tinyvec = { version = "1.6", features = ["std", "rustc_1_57"] }
|
||||||
percent-encoding = "2"
|
percent-encoding = "2"
|
||||||
|
|
|
@ -19,17 +19,8 @@ rust-version = "1.75"
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
|
|
||||||
[lints.rust]
|
[lints]
|
||||||
rust_2018_idioms = "warn"
|
workspace = true
|
||||||
# missing_docs = "warn"
|
|
||||||
async_fn_in_trait = "allow"
|
|
||||||
refining_impl_trait = "allow"
|
|
||||||
|
|
||||||
[lints.clippy]
|
|
||||||
type_complexity = "allow"
|
|
||||||
module_inception = "allow"
|
|
||||||
multiple_bound_locations = "allow"
|
|
||||||
manual_range_contains = "allow"
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["http2", "tokio-macros"]
|
default = ["http2", "tokio-macros"]
|
||||||
|
|
|
@ -8,6 +8,9 @@ edition = "2021"
|
||||||
[package.metadata]
|
[package.metadata]
|
||||||
cargo-fuzz = true
|
cargo-fuzz = true
|
||||||
|
|
||||||
|
[lints.rust]
|
||||||
|
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(honggfuzz)', 'cfg(afl)'] }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libfuzzer-sys = "0.4"
|
libfuzzer-sys = "0.4"
|
||||||
arbitrary = { version = "1.3", features = ["derive"] }
|
arbitrary = { version = "1.3", features = ["derive"] }
|
||||||
|
|
|
@ -204,7 +204,7 @@ fn fuzz((route_a, route_b, req): TestData<'_>) {
|
||||||
#[cfg(all(not(honggfuzz), not(afl)))]
|
#[cfg(all(not(honggfuzz), not(afl)))]
|
||||||
libfuzzer_sys::fuzz_target!(|data: TestData| fuzz(data));
|
libfuzzer_sys::fuzz_target!(|data: TestData| fuzz(data));
|
||||||
|
|
||||||
#[cfg(honggbuzz)]
|
#[cfg(honggfuzz)]
|
||||||
fn main() {
|
fn main() {
|
||||||
loop {
|
loop {
|
||||||
honggfuzz::fuzz!(|data: TestData| fuzz(data));
|
honggfuzz::fuzz!(|data: TestData| fuzz(data));
|
||||||
|
|
|
@ -321,7 +321,7 @@ async fn known_macro_sentinel_works() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/<_a>/<b>")]
|
#[get("/<_a>/<b>")]
|
||||||
fn reader<'a, 'b>(_a: &'a str, b: &'b str) -> ReaderStream![TextSentinel<'b>] {
|
fn reader<'b>(_a: &str, b: &'b str) -> ReaderStream![TextSentinel<'b>] {
|
||||||
ReaderStream!(yield TextSentinel(b);)
|
ReaderStream!(yield TextSentinel(b);)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,9 @@ workspace = "../../"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rocket = { path = "../../core/lib", features = ["secrets"] }
|
rocket = { path = "../../core/lib", features = ["secrets"] }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue