diff --git a/phf/src/map.rs b/phf/src/map.rs index 1cd02dbc..3df11b3c 100644 --- a/phf/src/map.rs +++ b/phf/src/map.rs @@ -27,7 +27,7 @@ where K: fmt::Debug, V: fmt::Debug, { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_map().entries(self.entries()).finish() } } @@ -108,7 +108,7 @@ impl Map { /// Returns an iterator over the key/value pairs in the map. /// /// Entries are returned in an arbitrary but fixed order. - pub fn entries(&self) -> Entries { + pub fn entries(&self) -> Entries<'_, K, V> { Entries { iter: self.entries.iter(), } @@ -117,7 +117,7 @@ impl Map { /// Returns an iterator over the keys in the map. /// /// Keys are returned in an arbitrary but fixed order. - pub fn keys(&self) -> Keys { + pub fn keys(&self) -> Keys<'_, K, V> { Keys { iter: self.entries(), } @@ -126,7 +126,7 @@ impl Map { /// Returns an iterator over the values in the map. /// /// Values are returned in an arbitrary but fixed order. - pub fn values(&self) -> Values { + pub fn values(&self) -> Values<'_, K, V> { Values { iter: self.entries(), } @@ -143,7 +143,7 @@ impl<'a, K, V> IntoIterator for &'a Map { } /// An iterator over the key/value pairs in a `Map`. -pub struct Entries<'a, K: 'a, V: 'a> { +pub struct Entries<'a, K, V> { iter: slice::Iter<'a, (K, V)>, } @@ -168,7 +168,7 @@ impl<'a, K, V> DoubleEndedIterator for Entries<'a, K, V> { impl<'a, K, V> ExactSizeIterator for Entries<'a, K, V> {} /// An iterator over the keys in a `Map`. -pub struct Keys<'a, K: 'a, V: 'a> { +pub struct Keys<'a, K, V> { iter: Entries<'a, K, V>, } @@ -193,7 +193,7 @@ impl<'a, K, V> DoubleEndedIterator for Keys<'a, K, V> { impl<'a, K, V> ExactSizeIterator for Keys<'a, K, V> {} /// An iterator over the values in a `Map`. -pub struct Values<'a, K: 'a, V: 'a> { +pub struct Values<'a, K, V> { iter: Entries<'a, K, V>, } diff --git a/phf/src/ordered_map.rs b/phf/src/ordered_map.rs index 5a5f583e..de888aef 100644 --- a/phf/src/ordered_map.rs +++ b/phf/src/ordered_map.rs @@ -33,7 +33,7 @@ where K: fmt::Debug, V: fmt::Debug, { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_map().entries(self.entries()).finish() } } @@ -140,7 +140,7 @@ impl OrderedMap { /// Returns an iterator over the key/value pairs in the map. /// /// Entries are returned in the same order in which they were defined. - pub fn entries(&self) -> Entries { + pub fn entries(&self) -> Entries<'_, K, V> { Entries { iter: self.entries.iter(), } @@ -149,7 +149,7 @@ impl OrderedMap { /// Returns an iterator over the keys in the map. /// /// Keys are returned in the same order in which they were defined. - pub fn keys(&self) -> Keys { + pub fn keys(&self) -> Keys<'_, K, V> { Keys { iter: self.entries(), } @@ -158,7 +158,7 @@ impl OrderedMap { /// Returns an iterator over the values in the map. /// /// Values are returned in the same order in which they were defined. - pub fn values(&self) -> Values { + pub fn values(&self) -> Values<'_, K, V> { Values { iter: self.entries(), } @@ -175,7 +175,7 @@ impl<'a, K, V> IntoIterator for &'a OrderedMap { } /// An iterator over the entries in a `OrderedMap`. -pub struct Entries<'a, K: 'a, V: 'a> { +pub struct Entries<'a, K, V> { iter: slice::Iter<'a, (K, V)>, } @@ -200,7 +200,7 @@ impl<'a, K, V> DoubleEndedIterator for Entries<'a, K, V> { impl<'a, K, V> ExactSizeIterator for Entries<'a, K, V> {} /// An iterator over the keys in a `OrderedMap`. -pub struct Keys<'a, K: 'a, V: 'a> { +pub struct Keys<'a, K, V> { iter: Entries<'a, K, V>, } @@ -225,7 +225,7 @@ impl<'a, K, V> DoubleEndedIterator for Keys<'a, K, V> { impl<'a, K, V> ExactSizeIterator for Keys<'a, K, V> {} /// An iterator over the values in a `OrderedMap`. -pub struct Values<'a, K: 'a, V: 'a> { +pub struct Values<'a, K, V> { iter: Entries<'a, K, V>, } diff --git a/phf/src/ordered_set.rs b/phf/src/ordered_set.rs index 11b9203d..d1e93293 100644 --- a/phf/src/ordered_set.rs +++ b/phf/src/ordered_set.rs @@ -23,7 +23,7 @@ impl fmt::Debug for OrderedSet where T: fmt::Debug, { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_set().entries(self).finish() } } @@ -79,7 +79,7 @@ impl OrderedSet { /// Returns an iterator over the values in the set. /// /// Values are returned in the same order in which they were defined. - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, T> { Iter { iter: self.map.keys(), } @@ -119,7 +119,7 @@ impl<'a, T> IntoIterator for &'a OrderedSet { } /// An iterator over the values in a `OrderedSet`. -pub struct Iter<'a, T: 'a> { +pub struct Iter<'a, T> { iter: ordered_map::Keys<'a, T, ()>, } diff --git a/phf/src/set.rs b/phf/src/set.rs index 8d84c3b6..1a3f1acc 100644 --- a/phf/src/set.rs +++ b/phf/src/set.rs @@ -22,7 +22,7 @@ impl fmt::Debug for Set where T: fmt::Debug, { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_set().entries(self).finish() } } @@ -62,7 +62,7 @@ impl Set { /// Returns an iterator over the values in the set. /// /// Values are returned in an arbitrary but fixed order. - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, T> { Iter { iter: self.map.keys(), } diff --git a/phf_codegen/src/lib.rs b/phf_codegen/src/lib.rs index 3caa4362..5d51a816 100644 --- a/phf_codegen/src/lib.rs +++ b/phf_codegen/src/lib.rs @@ -135,7 +135,7 @@ use phf_generator::HashState; struct Delegate(T); impl fmt::Display for Delegate { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt_const(f) } } @@ -188,7 +188,7 @@ impl Map { /// # Panics /// /// Panics if there are any duplicate keys. - pub fn build(&self) -> DisplayMap { + pub fn build(&self) -> DisplayMap<'_, K> { let mut set = HashSet::new(); for key in &self.keys { if !set.insert(key) { @@ -216,7 +216,7 @@ pub struct DisplayMap<'a, K> { } impl<'a, K: FmtConst + 'a> fmt::Display for DisplayMap<'a, K> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // funky formatting here for nice output write!( f, @@ -293,7 +293,7 @@ impl Set { /// # Panics /// /// Panics if there are any duplicate keys. - pub fn build(&self) -> DisplaySet { + pub fn build(&self) -> DisplaySet<'_, T> { DisplaySet { inner: self.map.build(), } @@ -301,12 +301,12 @@ impl Set { } /// An adapter for printing a [`Set`](Set). -pub struct DisplaySet<'a, T: 'a> { +pub struct DisplaySet<'a, T> { inner: DisplayMap<'a, T>, } impl<'a, T: FmtConst + 'a> fmt::Display for DisplaySet<'a, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}::Set {{ map: {} }}", self.inner.path, self.inner) } } @@ -350,7 +350,7 @@ impl OrderedMap { /// # Panics /// /// Panics if there are any duplicate keys. - pub fn build(&self) -> DisplayOrderedMap { + pub fn build(&self) -> DisplayOrderedMap<'_, K> { let mut set = HashSet::new(); for key in &self.keys { if !set.insert(key) { @@ -370,7 +370,7 @@ impl OrderedMap { } /// An adapter for printing a [`OrderedMap`](OrderedMap). -pub struct DisplayOrderedMap<'a, K: 'a> { +pub struct DisplayOrderedMap<'a, K> { path: &'a str, state: HashState, keys: &'a [K], @@ -378,7 +378,7 @@ pub struct DisplayOrderedMap<'a, K: 'a> { } impl<'a, K: FmtConst + 'a> fmt::Display for DisplayOrderedMap<'a, K> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, "{}::OrderedMap {{ @@ -466,7 +466,7 @@ impl OrderedSet { /// # Panics /// /// Panics if there are any duplicate keys. - pub fn build(&self) -> DisplayOrderedSet { + pub fn build(&self) -> DisplayOrderedSet<'_, T> { DisplayOrderedSet { inner: self.map.build(), } @@ -474,12 +474,12 @@ impl OrderedSet { } /// An adapter for printing a [`OrderedSet`](OrderedSet). -pub struct DisplayOrderedSet<'a, T: 'a> { +pub struct DisplayOrderedSet<'a, T> { inner: DisplayOrderedMap<'a, T>, } impl<'a, T: FmtConst + 'a> fmt::Display for DisplayOrderedSet<'a, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, "{}::OrderedSet {{ map: {} }}", diff --git a/phf_macros/src/lib.rs b/phf_macros/src/lib.rs index 23a18698..bd277360 100644 --- a/phf_macros/src/lib.rs +++ b/phf_macros/src/lib.rs @@ -1,3 +1,4 @@ +// FIXME: Remove `extern crate` below when we bump MSRV to 1.42 or higher. extern crate proc_macro; use phf_generator::HashState; @@ -174,7 +175,7 @@ impl PhfHash for Key { } impl Parse for Key { - fn parse(input: ParseStream) -> parse::Result { + fn parse(input: ParseStream<'_>) -> parse::Result { let expr = input.parse()?; let parsed = ParsedKey::from_expr(&expr) .ok_or_else(|| Error::new_spanned(&expr, "unsupported key expression"))?; @@ -198,7 +199,7 @@ impl PhfHash for Entry { } impl Parse for Entry { - fn parse(input: ParseStream) -> parse::Result { + fn parse(input: ParseStream<'_>) -> parse::Result { let key = input.parse()?; input.parse::]>()?; let value = input.parse()?; @@ -209,7 +210,7 @@ impl Parse for Entry { struct Map(Vec); impl Parse for Map { - fn parse(input: ParseStream) -> parse::Result { + fn parse(input: ParseStream<'_>) -> parse::Result { let parsed = Punctuated::::parse_terminated(input)?; let map = parsed.into_iter().collect::>(); check_duplicates(&map)?; @@ -220,7 +221,7 @@ impl Parse for Map { struct Set(Vec); impl Parse for Set { - fn parse(input: ParseStream) -> parse::Result { + fn parse(input: ParseStream<'_>) -> parse::Result { let parsed = Punctuated::::parse_terminated(input)?; let set = parsed .into_iter() diff --git a/phf_shared/src/lib.rs b/phf_shared/src/lib.rs index c0ed0d57..79b119a3 100644 --- a/phf_shared/src/lib.rs +++ b/phf_shared/src/lib.rs @@ -78,7 +78,7 @@ pub trait PhfHash { /// Trait for printing types with `const` constructors, used by `phf_codegen` and `phf_macros`. pub trait FmtConst { /// Print a `const` expression representing this value. - fn fmt_const(&self, f: &mut fmt::Formatter) -> fmt::Result; + fn fmt_const(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result; } /// Identical to `std::borrow::Borrow` except omitting blanket impls to facilitate other @@ -131,7 +131,7 @@ pub trait PhfBorrow { macro_rules! delegate_debug ( ($ty:ty) => { impl FmtConst for $ty { - fn fmt_const(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt_const(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{:?}", self) } } @@ -220,7 +220,7 @@ impl<'a, T: 'a + PhfHash + ?Sized> PhfHash for &'a T { } impl<'a, T: 'a + FmtConst + ?Sized> FmtConst for &'a T { - fn fmt_const(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt_const(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (*self).fmt_const(f) } } @@ -253,7 +253,7 @@ impl PhfHash for [u8] { impl FmtConst for [u8] { #[inline] - fn fmt_const(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt_const(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // slices need a leading reference write!(f, "&{:?}", self) } @@ -275,7 +275,7 @@ impl FmtConst for unicase::UniCase where S: AsRef, { - fn fmt_const(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt_const(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if self.is_ascii() { f.write_str("UniCase::ascii(")?; } else { @@ -304,7 +304,7 @@ impl PhfHash for uncased::UncasedStr { #[cfg(feature = "uncased")] impl FmtConst for uncased::UncasedStr { - fn fmt_const(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt_const(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // transmute is not stable in const fns (rust-lang/rust#53605), so // `UncasedStr::new` can't be a const fn itself, but we can inline the // call to transmute here in the meantime. @@ -360,7 +360,7 @@ impl PhfHash for char { } // minimize duplicated code since formatting drags in quite a bit -fn fmt_array(array: &[u8], f: &mut fmt::Formatter) -> fmt::Result { +fn fmt_array(array: &[u8], f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{:?}", array) } @@ -374,7 +374,7 @@ macro_rules! array_impl ( } impl FmtConst for [$t; $n] { - fn fmt_const(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt_const(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt_array(self, f) } }