Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--lib/smol_str/Cargo.toml3
-rw-r--r--lib/smol_str/src/lib.rs62
-rw-r--r--lib/smol_str/src/serde.rs5
-rw-r--r--lib/smol_str/tests/test.rs11
-rw-r--r--lib/smol_str/tests/tidy.rs1
-rw-r--r--xtask/src/tidy.rs21
6 files changed, 33 insertions, 70 deletions
diff --git a/lib/smol_str/Cargo.toml b/lib/smol_str/Cargo.toml
index 814781f05a..ee3263594a 100644
--- a/lib/smol_str/Cargo.toml
+++ b/lib/smol_str/Cargo.toml
@@ -33,8 +33,5 @@ serde = ["dep:serde_core"]
name = "bench"
harness = false
-[profile.bench]
-lto = "fat"
-
[lints]
workspace = true
diff --git a/lib/smol_str/src/lib.rs b/lib/smol_str/src/lib.rs
index ded07c61c6..effaba211d 100644
--- a/lib/smol_str/src/lib.rs
+++ b/lib/smol_str/src/lib.rs
@@ -115,10 +115,7 @@ impl Clone for SmolStr {
impl Default for SmolStr {
#[inline(always)]
fn default() -> SmolStr {
- SmolStr(Repr::Inline {
- len: InlineSize::_V0,
- buf: [0; INLINE_CAP],
- })
+ SmolStr(Repr::Inline { len: InlineSize::_V0, buf: [0; INLINE_CAP] })
}
}
@@ -216,13 +213,13 @@ impl hash::Hash for SmolStr {
}
impl fmt::Debug for SmolStr {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(self.as_str(), f)
}
}
impl fmt::Display for SmolStr {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(self.as_str(), f)
}
}
@@ -245,11 +242,8 @@ fn from_buf_and_chars(
) -> SmolStr {
let min_size = iter.size_hint().0 + buf_len;
if min_size > INLINE_CAP {
- let heap: String = core::str::from_utf8(&buf[..buf_len])
- .unwrap()
- .chars()
- .chain(iter)
- .collect();
+ let heap: String =
+ core::str::from_utf8(&buf[..buf_len]).unwrap().chars().chain(iter).collect();
if heap.len() <= INLINE_CAP {
// size hint lied
return SmolStr::new_inline(&heap);
@@ -490,10 +484,7 @@ impl InlineSize {
#[derive(Clone, Debug)]
enum Repr {
- Inline {
- len: InlineSize,
- buf: [u8; INLINE_CAP],
- },
+ Inline { len: InlineSize, buf: [u8; INLINE_CAP] },
Static(&'static str),
Heap(Arc<str>),
}
@@ -521,10 +512,8 @@ impl Repr {
if len <= N_NEWLINES + N_SPACES {
let bytes = text.as_bytes();
let possible_newline_count = cmp::min(len, N_NEWLINES);
- let newlines = bytes[..possible_newline_count]
- .iter()
- .take_while(|&&b| b == b'\n')
- .count();
+ let newlines =
+ bytes[..possible_newline_count].iter().take_while(|&&b| b == b'\n').count();
let possible_space_count = len - newlines;
if possible_space_count <= N_SPACES && bytes[newlines..].iter().all(|&b| b == b' ') {
let spaces = possible_space_count;
@@ -576,16 +565,9 @@ impl Repr {
match (self, other) {
(Self::Heap(l0), Self::Heap(r0)) => Arc::ptr_eq(l0, r0),
(Self::Static(l0), Self::Static(r0)) => core::ptr::eq(l0, r0),
- (
- Self::Inline {
- len: l_len,
- buf: l_buf,
- },
- Self::Inline {
- len: r_len,
- buf: r_buf,
- },
- ) => l_len == r_len && l_buf == r_buf,
+ (Self::Inline { len: l_len, buf: l_buf }, Self::Inline { len: r_len, buf: r_buf }) => {
+ l_len == r_len && l_buf == r_buf
+ }
_ => false,
}
}
@@ -649,11 +631,7 @@ impl StrExt for str {
let len = self.len();
if len <= INLINE_CAP {
let (buf, rest) = inline_convert_while_ascii(self, u8::to_ascii_lowercase);
- from_buf_and_chars(
- buf,
- len - rest.len(),
- rest.chars().flat_map(|c| c.to_lowercase()),
- )
+ from_buf_and_chars(buf, len - rest.len(), rest.chars().flat_map(|c| c.to_lowercase()))
} else {
self.to_lowercase().into()
}
@@ -664,11 +642,7 @@ impl StrExt for str {
let len = self.len();
if len <= INLINE_CAP {
let (buf, rest) = inline_convert_while_ascii(self, u8::to_ascii_uppercase);
- from_buf_and_chars(
- buf,
- len - rest.len(),
- rest.chars().flat_map(|c| c.to_uppercase()),
- )
+ from_buf_and_chars(buf, len - rest.len(), rest.chars().flat_map(|c| c.to_uppercase()))
} else {
self.to_uppercase().into()
}
@@ -878,10 +852,7 @@ enum SmolStrBuilderRepr {
impl Default for SmolStrBuilderRepr {
#[inline]
fn default() -> Self {
- SmolStrBuilderRepr::Inline {
- buf: [0; INLINE_CAP],
- len: 0,
- }
+ SmolStrBuilderRepr::Inline { buf: [0; INLINE_CAP], len: 0 }
}
}
@@ -889,10 +860,7 @@ impl SmolStrBuilder {
/// Creates a new empty [`SmolStrBuilder`].
#[must_use]
pub const fn new() -> Self {
- Self(SmolStrBuilderRepr::Inline {
- buf: [0; INLINE_CAP],
- len: 0,
- })
+ Self(SmolStrBuilderRepr::Inline { buf: [0; INLINE_CAP], len: 0 })
}
/// Builds a [`SmolStr`] from `self`.
diff --git a/lib/smol_str/src/serde.rs b/lib/smol_str/src/serde.rs
index 4f08b444c5..66cbcd3bad 100644
--- a/lib/smol_str/src/serde.rs
+++ b/lib/smol_str/src/serde.rs
@@ -67,10 +67,7 @@ where
{
match String::from_utf8(v) {
Ok(s) => Ok(SmolStr::from(s)),
- Err(e) => Err(Error::invalid_value(
- Unexpected::Bytes(&e.into_bytes()),
- &self,
- )),
+ Err(e) => Err(Error::invalid_value(Unexpected::Bytes(&e.into_bytes()), &self)),
}
}
}
diff --git a/lib/smol_str/tests/test.rs b/lib/smol_str/tests/test.rs
index 8f7d9ec39a..640e7df681 100644
--- a/lib/smol_str/tests/test.rs
+++ b/lib/smol_str/tests/test.rs
@@ -1,3 +1,4 @@
+#![allow(clippy::disallowed_types)]
use std::sync::Arc;
#[cfg(not(miri))]
@@ -8,10 +9,7 @@ use smol_str::{SmolStr, SmolStrBuilder};
#[test]
#[cfg(target_pointer_width = "64")]
fn smol_str_is_smol() {
- assert_eq!(
- ::std::mem::size_of::<SmolStr>(),
- ::std::mem::size_of::<String>(),
- );
+ assert_eq!(::std::mem::size_of::<SmolStr>(), ::std::mem::size_of::<String>(),);
}
#[test]
@@ -341,10 +339,7 @@ mod test_str_ext {
#[test]
fn large() {
let lowercase = "aaaaaaAAAAAaaaaaaaaaaaaaaaaaaaaaAAAAaaaaaaaaaaaaaa".to_lowercase_smolstr();
- assert_eq!(
- lowercase,
- "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
- );
+ assert_eq!(lowercase, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
assert!(lowercase.is_heap_allocated());
}
diff --git a/lib/smol_str/tests/tidy.rs b/lib/smol_str/tests/tidy.rs
index e2d809e40f..743fa5add9 100644
--- a/lib/smol_str/tests/tidy.rs
+++ b/lib/smol_str/tests/tidy.rs
@@ -1,3 +1,4 @@
+#![allow(clippy::disallowed_methods, clippy::print_stdout)]
#![cfg(not(miri))]
use std::{
env,
diff --git a/xtask/src/tidy.rs b/xtask/src/tidy.rs
index 40997eb93d..ebfc7d0a94 100644
--- a/xtask/src/tidy.rs
+++ b/xtask/src/tidy.rs
@@ -127,21 +127,24 @@ fn check_cargo_toml(path: &Path, text: String) {
}
fn check_licenses(sh: &Shell) {
- const EXPECTED: [&str; 20] = [
+ const EXPECTED: &[&str] = &[
"(MIT OR Apache-2.0) AND Unicode-3.0",
"0BSD OR MIT OR Apache-2.0",
- "Apache-2.0",
+ "Apache-2.0 / MIT",
"Apache-2.0 OR BSL-1.0",
"Apache-2.0 OR MIT",
- "Apache-2.0 WITH LLVM-exception",
"Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT",
+ "Apache-2.0 WITH LLVM-exception",
+ "Apache-2.0",
"Apache-2.0/MIT",
+ "BSD-2-Clause OR Apache-2.0 OR MIT",
"CC0-1.0",
"ISC",
- "MIT",
"MIT / Apache-2.0",
+ "MIT OR Apache-2.0 OR LGPL-2.1-or-later",
"MIT OR Apache-2.0",
"MIT OR Zlib OR Apache-2.0",
+ "MIT",
"MIT/Apache-2.0",
"MPL-2.0",
"Unicode-3.0",
@@ -159,18 +162,20 @@ fn check_licenses(sh: &Shell) {
.collect::<Vec<_>>();
licenses.sort_unstable();
licenses.dedup();
- if licenses != EXPECTED {
+ let mut expected = EXPECTED.to_vec();
+ expected.sort_unstable();
+ if licenses != expected {
let mut diff = String::new();
diff.push_str("New Licenses:\n");
for &l in licenses.iter() {
- if !EXPECTED.contains(&l) {
+ if !expected.contains(&l) {
diff += &format!(" {l}\n")
}
}
diff.push_str("\nMissing Licenses:\n");
- for l in EXPECTED {
+ for l in expected {
if !licenses.contains(&l) {
diff += &format!(" {l}\n")
}
@@ -178,7 +183,7 @@ fn check_licenses(sh: &Shell) {
panic!("different set of licenses!\n{diff}");
}
- assert_eq!(licenses, EXPECTED);
+ assert_eq!(licenses, expected);
}
fn check_test_attrs(path: &Path, text: &str) {