commit c84b365e478a9065c71190c2c567f7cfa9f20d1b
parent 9d56f2cd671ffe0be824fab9d5646fa3b84fed75
Author: Zack Newman <zack@philomathiclife.com>
Date: Mon, 23 Jun 2025 10:57:05 -0600
more lints
Diffstat:
5 files changed, 74 insertions(+), 41 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
@@ -10,7 +10,71 @@ name = "ascii_domain"
readme = "README.md"
repository = "https://git.philomathiclife.com/repos/ascii_domain/"
rust-version = "1.86.0"
-version = "0.6.4"
+version = "0.6.5"
+
+[lints.rust]
+ambiguous_negative_literals = { level = "deny", priority = -1 }
+closure_returning_async_block = { level = "deny", priority = -1 }
+deref_into_dyn_supertrait = { level = "deny", priority = -1 }
+ffi_unwind_calls = { level = "deny", priority = -1 }
+future_incompatible = { level = "deny", priority = -1 }
+impl_trait_redundant_captures = { level = "deny", priority = -1 }
+keyword-idents = { level = "deny", priority = -1 }
+let_underscore = { level = "deny", priority = -1 }
+linker_messages = { level = "deny", priority = -1 }
+macro_use_extern_crate = { level = "deny", priority = -1 }
+meta_variable_misuse = { level = "deny", priority = -1 }
+missing_copy_implementations = { level = "deny", priority = -1 }
+missing_debug_implementations = { level = "deny", priority = -1 }
+missing_docs = { level = "deny", priority = -1 }
+non_ascii_idents = { level = "deny", priority = -1 }
+nonstandard_style = { level = "deny", priority = -1 }
+redundant_imports = { level = "deny", priority = -1 }
+redundant_lifetimes = { level = "deny", priority = -1 }
+refining_impl_trait = { level = "deny", priority = -1 }
+rust_2018_compatibility = { level = "deny", priority = -1 }
+rust_2018_idioms = { level = "deny", priority = -1 }
+rust_2021_compatibility = { level = "deny", priority = -1 }
+rust_2024_compatibility = { level = "deny", priority = -1 }
+single_use_lifetimes = { level = "deny", priority = -1 }
+trivial_casts = { level = "deny", priority = -1 }
+trivial_numeric_casts = { level = "deny", priority = -1 }
+unit_bindings = { level = "deny", priority = -1 }
+unknown_lints = { level = "deny", priority = -1 }
+unnameable_types = { level = "deny", priority = -1 }
+unreachable_pub = { level = "deny", priority = -1 }
+unsafe_code = { level = "deny", priority = -1 }
+unstable_features = { level = "deny", priority = -1 }
+unused = { level = "deny", priority = -1 }
+unused_crate_dependencies = { level = "deny", priority = -1 }
+unused_import_braces = { level = "deny", priority = -1 }
+unused_lifetimes = { level = "deny", priority = -1 }
+unused_qualifications = { level = "deny", priority = -1 }
+unused_results = { level = "deny", priority = -1 }
+variant_size_differences = { level = "deny", priority = -1 }
+warnings = { level = "deny", priority = -1 }
+
+[lints.clippy]
+all = { level = "deny", priority = -1 }
+cargo = { level = "deny", priority = -1 }
+complexity = { level = "deny", priority = -1 }
+correctness = { level = "deny", priority = -1 }
+nursery = { level = "deny", priority = -1 }
+pedantic = { level = "deny", priority = -1 }
+perf = { level = "deny", priority = -1 }
+restriction = { level = "deny", priority = -1 }
+style = { level = "deny", priority = -1 }
+suspicious = { level = "deny", priority = -1 }
+# Noisy, opinionated, and likely don't prevent bugs or improve APIs.
+arbitrary_source_item_ordering = "allow"
+blanket_clippy_restriction_lints = "allow"
+exhaustive_enums = "allow"
+implicit_return = "allow"
+min_ident_chars = "allow"
+missing_trait_methods = "allow"
+question_mark_used = "allow"
+return_and_then = "allow"
+single_char_lifetime_names = "allow"
[package.metadata.docs.rs]
all-features = true
diff --git a/src/char_set.rs b/src/char_set.rs
@@ -4,6 +4,7 @@ use core::{
str,
};
/// Error returned from [`AllowedAscii::try_from_unique_ascii`].
+#[expect(variant_size_differences, reason = "usize is fine in size")]
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum AsciiErr {
/// Since `AllowedAscii` only allows unique ASCII characters and doesn't allow `b'.'`, the maximum count is
@@ -48,6 +49,7 @@ impl Error for AsciiErr {}
///
/// It is _highly_ unlikely that non-printable ASCII nor `b'\\'` should be used since such ASCII would almost
/// certainly require being escaped.
+#[derive(Debug)]
pub struct AllowedAscii<T> {
/// The allowed ASCII `u8`s.
allowed: T,
diff --git a/src/dom.rs b/src/dom.rs
@@ -4,7 +4,7 @@ use alloc::{string::String, vec::Vec};
use core::{
borrow::Borrow,
cmp::Ordering,
- convert::{self, AsRef},
+ convert,
error::Error,
fmt::{self, Display, Formatter},
hash::{Hash, Hasher},
@@ -560,7 +560,7 @@ impl From<Domain<Self>> for String {
fn from(value: Domain<Self>) -> Self {
if value.contains_trailing_dot() {
let mut val = value.value;
- val.pop();
+ _ = val.pop();
val
} else {
value.value
@@ -603,7 +603,7 @@ impl From<Domain<Self>> for Vec<u8> {
fn from(value: Domain<Self>) -> Self {
if value.contains_trailing_dot() {
let mut val = value.value;
- val.pop();
+ _ = val.pop();
val
} else {
value.value
@@ -627,6 +627,7 @@ impl<'a: 'b, 'b> From<Domain<&'a [u8]>> for &'b [u8] {
}
}
/// Error returned from [`Domain::try_from_bytes`].
+#[expect(variant_size_differences, reason = "usize is fine in size")]
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum DomainErr {
/// The domain was empty.
@@ -1511,6 +1512,7 @@ mod tests {
use crate::char_set::{ASCII_FIREFOX, ASCII_HYPHEN_DIGITS_LETTERS, AllowedAscii};
use alloc::borrow::ToOwned;
use core::cmp::Ordering;
+ use serde_json as _;
#[test]
fn test_dom_parse() {
let allowed_ascii = ASCII_FIREFOX;
diff --git a/src/lib.rs b/src/lib.rs
@@ -19,41 +19,6 @@
//! set.
#![cfg_attr(docsrs, feature(doc_cfg))]
#![no_std]
-#![deny(
- future_incompatible,
- let_underscore,
- missing_docs,
- nonstandard_style,
- rust_2018_compatibility,
- rust_2018_idioms,
- rust_2021_compatibility,
- rust_2024_compatibility,
- unsafe_code,
- unused,
- warnings,
- clippy::all,
- clippy::cargo,
- clippy::complexity,
- clippy::correctness,
- clippy::nursery,
- clippy::pedantic,
- clippy::perf,
- clippy::restriction,
- clippy::style,
- clippy::suspicious
-)]
-#![expect(
- clippy::blanket_clippy_restriction_lints,
- clippy::arbitrary_source_item_ordering,
- clippy::exhaustive_enums,
- clippy::implicit_return,
- clippy::min_ident_chars,
- clippy::missing_trait_methods,
- clippy::question_mark_used,
- clippy::return_and_then,
- clippy::single_char_lifetime_names,
- reason = "noisy, opinionated, and likely doesn't prevent bugs or improve APIs"
-)]
/// Contains [`char_set::AllowedAscii`] which is how one dictates the character set [`dom::Domain::try_from_bytes`]
/// uses.
pub mod char_set;
diff --git a/src/serde.rs b/src/serde.rs
@@ -59,7 +59,7 @@ impl<T: AsRef<[u8]>> Serialize for Rfc1123Domain<T> {
clippy::partial_pub_fields,
reason = "we don't expost PhantomData for obvious reasons, so this is fine"
)]
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Debug)]
pub struct DomainVisitor<'a, T, T2> {
/// Phantom.
_x: PhantomData<fn() -> T2>,
@@ -103,6 +103,7 @@ impl<'a, T, T2> DomainVisitor<'a, T, T2> {
/// use ascii_domain::{char_set::ASCII_HYPHEN_DIGITS_LETTERS, serde::DomainVisitor};
/// assert!(DomainVisitor::<'_, _, String>::new(&ASCII_HYPHEN_DIGITS_LETTERS).allowed_ascii.len() == 63);
/// ```
+ #[expect(single_use_lifetimes, reason = "false positive")]
#[inline]
pub const fn new<'b: 'a>(allowed_ascii: &'b AllowedAscii<T>) -> Self {
Self {
@@ -240,7 +241,6 @@ mod tests {
dom::{Domain, Rfc1123Domain},
};
use alloc::string::String;
- use serde_json;
#[test]
fn test_serde() {
assert!(