mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-12-27 16:07:46 +00:00
Fix lints
This commit is contained in:
parent
076e315d60
commit
3e6863eeb1
@ -1,8 +1,10 @@
|
||||
use crate::{Repr, SmolStr, INLINE_CAP};
|
||||
use alloc::string::{String, ToString};
|
||||
use borsh::io::{Error, ErrorKind, Read, Write};
|
||||
use borsh::{BorshDeserialize, BorshSerialize};
|
||||
use core::intrinsics::transmute;
|
||||
use borsh::{
|
||||
io::{Error, ErrorKind, Read, Write},
|
||||
BorshDeserialize, BorshSerialize,
|
||||
};
|
||||
use core::mem::transmute;
|
||||
|
||||
impl BorshSerialize for SmolStr {
|
||||
fn serialize<W: Write>(&self, writer: &mut W) -> borsh::io::Result<()> {
|
||||
@ -27,12 +29,8 @@ impl BorshDeserialize for SmolStr {
|
||||
}))
|
||||
} else {
|
||||
// u8::vec_from_reader always returns Some on success in current implementation
|
||||
let vec = u8::vec_from_reader(len, reader)?.ok_or_else(|| {
|
||||
Error::new(
|
||||
ErrorKind::Other,
|
||||
"u8::vec_from_reader unexpectedly returned None".to_string(),
|
||||
)
|
||||
})?;
|
||||
let vec = u8::vec_from_reader(len, reader)?
|
||||
.ok_or_else(|| Error::other("u8::vec_from_reader unexpectedly returned None"))?;
|
||||
Ok(SmolStr::from(String::from_utf8(vec).map_err(|err| {
|
||||
let msg = err.to_string();
|
||||
Error::new(ErrorKind::InvalidData, msg)
|
||||
|
||||
@ -161,7 +161,7 @@ impl<'a> PartialEq<&'a str> for SmolStr {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> PartialEq<SmolStr> for &'a str {
|
||||
impl PartialEq<SmolStr> for &str {
|
||||
#[inline(always)]
|
||||
fn eq(&self, other: &SmolStr) -> bool {
|
||||
*self == other
|
||||
@ -189,7 +189,7 @@ impl<'a> PartialEq<&'a String> for SmolStr {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> PartialEq<SmolStr> for &'a String {
|
||||
impl PartialEq<SmolStr> for &String {
|
||||
#[inline(always)]
|
||||
fn eq(&self, other: &SmolStr) -> bool {
|
||||
*self == other
|
||||
@ -380,7 +380,7 @@ impl From<Box<str>> for SmolStr {
|
||||
impl From<Arc<str>> for SmolStr {
|
||||
#[inline]
|
||||
fn from(s: Arc<str>) -> SmolStr {
|
||||
let repr = Repr::new_on_stack(s.as_ref()).unwrap_or_else(|| Repr::Heap(s));
|
||||
let repr = Repr::new_on_stack(s.as_ref()).unwrap_or(Repr::Heap(s));
|
||||
Self(repr)
|
||||
}
|
||||
}
|
||||
|
||||
@ -390,8 +390,8 @@ mod test_str_ext {
|
||||
assert!(!result.is_heap_allocated());
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "borsh")]
|
||||
|
||||
#[cfg(feature = "borsh")]
|
||||
mod borsh_tests {
|
||||
use borsh::BorshDeserialize;
|
||||
use smol_str::{SmolStr, ToSmolStr};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user