diff --git a/regex-automata/src/dfa/dense.rs b/regex-automata/src/dfa/dense.rs index 6fc61dc4f..8e0f33c03 100644 --- a/regex-automata/src/dfa/dense.rs +++ b/regex-automata/src/dfa/dense.rs @@ -9,7 +9,7 @@ This module also contains a [`dense::Builder`](Builder) and a #[cfg(feature = "dfa-build")] use core::cmp; -use core::{convert::TryFrom, fmt, iter, mem::size_of, slice}; +use core::{fmt, iter, mem::size_of, slice}; #[cfg(feature = "dfa-build")] use alloc::{ diff --git a/regex-automata/src/dfa/sparse.rs b/regex-automata/src/dfa/sparse.rs index d461e0a0f..46278c181 100644 --- a/regex-automata/src/dfa/sparse.rs +++ b/regex-automata/src/dfa/sparse.rs @@ -38,11 +38,7 @@ assert_eq!(Some(HalfMatch::must(0, 7)), state.get_match()); #[cfg(feature = "dfa-build")] use core::iter; -use core::{ - convert::{TryFrom, TryInto}, - fmt, - mem::size_of, -}; +use core::{fmt, mem::size_of}; #[cfg(feature = "dfa-build")] use alloc::{vec, vec::Vec}; diff --git a/regex-automata/src/nfa/thompson/compiler.rs b/regex-automata/src/nfa/thompson/compiler.rs index 2d2172957..e6b1c9122 100644 --- a/regex-automata/src/nfa/thompson/compiler.rs +++ b/regex-automata/src/nfa/thompson/compiler.rs @@ -1876,11 +1876,11 @@ impl Utf8Node { #[cfg(test)] mod tests { - use alloc::{vec, vec::Vec}; + use alloc::vec; use crate::{ - nfa::thompson::{SparseTransitions, State, Transition, NFA}, - util::primitives::{PatternID, SmallIndex, StateID}, + nfa::thompson::{SparseTransitions, State}, + util::primitives::SmallIndex, }; use super::*; diff --git a/regex-automata/src/nfa/thompson/range_trie.rs b/regex-automata/src/nfa/thompson/range_trie.rs index cd77cc150..49debda40 100644 --- a/regex-automata/src/nfa/thompson/range_trie.rs +++ b/regex-automata/src/nfa/thompson/range_trie.rs @@ -141,7 +141,7 @@ construction later by virtue of producing a much much smaller NFA. [2] - https://www.mitpressjournals.org/doi/pdfplus/10.1162/089120100561601 */ -use core::{cell::RefCell, convert::TryFrom, fmt, mem, ops::RangeInclusive}; +use core::{cell::RefCell, fmt, mem, ops::RangeInclusive}; use alloc::{format, string::String, vec, vec::Vec}; @@ -915,10 +915,6 @@ fn intersects(r1: Utf8Range, r2: Utf8Range) -> bool { #[cfg(test)] mod tests { - use core::ops::RangeInclusive; - - use regex_syntax::utf8::Utf8Range; - use super::*; fn r(range: RangeInclusive) -> Utf8Range { diff --git a/regex-automata/src/util/determinize/state.rs b/regex-automata/src/util/determinize/state.rs index effa6f44d..8a8561a31 100644 --- a/regex-automata/src/util/determinize/state.rs +++ b/regex-automata/src/util/determinize/state.rs @@ -86,7 +86,7 @@ serialized anywhere. So any kind of change can be made with reckless abandon, as long as everything in this module agrees. */ -use core::{convert::TryFrom, mem}; +use core::mem; use alloc::{sync::Arc, vec::Vec}; diff --git a/regex-automata/src/util/int.rs b/regex-automata/src/util/int.rs index e6b13bff9..b726e93f8 100644 --- a/regex-automata/src/util/int.rs +++ b/regex-automata/src/util/int.rs @@ -41,6 +41,10 @@ like `u64::from` where possible, or even `usize::try_from()` for when we do explicitly want to panic or when we want to return an error for overflow. */ +// We define a little more than what we need, but I'd rather just have +// everything via a consistent and uniform API then have holes. +#![allow(dead_code)] + pub(crate) trait U8 { fn as_usize(self) -> usize; } @@ -240,13 +244,3 @@ impl Pointer for *const T { self as usize } } - -pub(crate) trait PointerMut { - fn as_usize(self) -> usize; -} - -impl PointerMut for *mut T { - fn as_usize(self) -> usize { - self as usize - } -} diff --git a/regex-automata/src/util/wire.rs b/regex-automata/src/util/wire.rs index ecf4fd8c0..b1351c7e9 100644 --- a/regex-automata/src/util/wire.rs +++ b/regex-automata/src/util/wire.rs @@ -41,11 +41,7 @@ generally requires serializing both its big-endian and little-endian variants, and then loading the correct one based on the target's endianness. */ -use core::{ - cmp, - convert::{TryFrom, TryInto}, - mem::size_of, -}; +use core::{cmp, mem::size_of}; #[cfg(feature = "alloc")] use alloc::{vec, vec::Vec}; @@ -867,11 +863,6 @@ pub(crate) trait Endian { /// this panics. fn write_u32(n: u32, dst: &mut [u8]); - /// Writes a u64 to the given destination buffer in a particular - /// endianness. If the destination buffer has a length smaller than 8, then - /// this panics. - fn write_u64(n: u64, dst: &mut [u8]); - /// Writes a u128 to the given destination buffer in a particular /// endianness. If the destination buffer has a length smaller than 16, /// then this panics. @@ -897,10 +888,6 @@ impl Endian for LE { dst[..4].copy_from_slice(&n.to_le_bytes()); } - fn write_u64(n: u64, dst: &mut [u8]) { - dst[..8].copy_from_slice(&n.to_le_bytes()); - } - fn write_u128(n: u128, dst: &mut [u8]) { dst[..16].copy_from_slice(&n.to_le_bytes()); } @@ -915,10 +902,6 @@ impl Endian for BE { dst[..4].copy_from_slice(&n.to_be_bytes()); } - fn write_u64(n: u64, dst: &mut [u8]) { - dst[..8].copy_from_slice(&n.to_be_bytes()); - } - fn write_u128(n: u128, dst: &mut [u8]) { dst[..16].copy_from_slice(&n.to_be_bytes()); } diff --git a/regex-capi/src/error.rs b/regex-capi/src/error.rs index a269a3913..7b91fb9d3 100644 --- a/regex-capi/src/error.rs +++ b/regex-capi/src/error.rs @@ -4,7 +4,6 @@ use std::fmt; use std::str; use libc::c_char; -use regex; #[derive(Debug)] pub struct Error { @@ -22,7 +21,7 @@ pub enum ErrorKind { impl Error { pub fn new(kind: ErrorKind) -> Error { - Error { message: None, kind: kind } + Error { message: None, kind } } pub fn is_err(&self) -> bool { diff --git a/regex-cli/cmd/debug/dfa.rs b/regex-cli/cmd/debug/dfa.rs index 9381cdadc..f16610fbe 100644 --- a/regex-cli/cmd/debug/dfa.rs +++ b/regex-cli/cmd/debug/dfa.rs @@ -5,7 +5,7 @@ use crate::{ util::{self, Table}, }; -use {lexopt, regex_automata::dfa::Automaton}; +use regex_automata::dfa::Automaton; pub fn run_dense(p: &mut lexopt::Parser) -> anyhow::Result<()> { const USAGE: &'static str = "\ diff --git a/regex-cli/logger.rs b/regex-cli/logger.rs index 0fe063f1c..4e783872e 100644 --- a/regex-cli/logger.rs +++ b/regex-cli/logger.rs @@ -3,7 +3,7 @@ // print to stderr. We therefore avoid bringing in extra dependencies just // for this functionality. -use log::{self, Log}; +use log::Log; /// The simplest possible logger that logs to stderr. /// diff --git a/regex-syntax/src/ast/parse.rs b/regex-syntax/src/ast/parse.rs index 593b14fbc..1a3df56b5 100644 --- a/regex-syntax/src/ast/parse.rs +++ b/regex-syntax/src/ast/parse.rs @@ -2405,8 +2405,6 @@ mod tests { use alloc::format; - use crate::ast::{self, Ast, Position, Span}; - use super::*; // Our own assert_eq, which has slightly better formatting (but honestly diff --git a/regex-syntax/src/hir/interval.rs b/regex-syntax/src/hir/interval.rs index e063390a8..d507ee724 100644 --- a/regex-syntax/src/hir/interval.rs +++ b/regex-syntax/src/hir/interval.rs @@ -479,23 +479,6 @@ pub trait Interval: ret } - /// Compute the symmetric difference the given range from this range. This - /// returns the union of the two ranges minus its intersection. - fn symmetric_difference( - &self, - other: &Self, - ) -> (Option, Option) { - let union = match self.union(other) { - None => return (Some(self.clone()), Some(other.clone())), - Some(union) => union, - }; - let intersection = match self.intersect(other) { - None => return (Some(self.clone()), Some(other.clone())), - Some(intersection) => intersection, - }; - union.difference(&intersection) - } - /// Returns true if and only if the two ranges are contiguous. Two ranges /// are contiguous if and only if the ranges are either overlapping or /// adjacent. diff --git a/regex-syntax/src/hir/translate.rs b/regex-syntax/src/hir/translate.rs index 313a1e9e8..3749ce307 100644 --- a/regex-syntax/src/hir/translate.rs +++ b/regex-syntax/src/hir/translate.rs @@ -1358,9 +1358,8 @@ fn ascii_class_as_chars( #[cfg(test)] mod tests { use crate::{ - ast::{self, parse::ParserBuilder, Ast, Position, Span}, - hir::{self, Hir, HirKind, Look, Properties}, - unicode::{self, ClassQuery}, + ast::{parse::ParserBuilder, Position}, + hir::{Look, Properties}, }; use super::*; diff --git a/regex-test/lib.rs b/regex-test/lib.rs index 2b630666e..7b5ab830c 100644 --- a/regex-test/lib.rs +++ b/regex-test/lib.rs @@ -99,9 +99,7 @@ See [`MatchKind`] for more details. This is an optional field and defaults to /// For this reason, `anyhow` is a public dependency and is re-exported here. pub extern crate anyhow; -use std::{ - borrow::Borrow, collections::HashSet, convert::TryFrom, fs, path::Path, -}; +use std::{borrow::Borrow, collections::HashSet, fs, path::Path}; use { anyhow::{bail, Context, Result},