Merge pull request #289 from ikatson/clippy-1.83

Clippy updates + update Rust deps
This commit is contained in:
Igor Katson 2024-12-03 22:22:09 +01:00 committed by GitHub
commit fb4e4c5741
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 602 additions and 451 deletions

View file

@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust_version: ["1.76", "1.78", "1.82"]
rust_version: ["1.78", "1.83"]
steps:
- name: rustup toolchain install ${{ matrix.rust_version }}
run: |

950
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -14,7 +14,7 @@ where
{
struct Wrapper<'a>(&'a [u8]);
impl<'a> Serialize for Wrapper<'a> {
impl Serialize for Wrapper<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,

View file

@ -202,7 +202,7 @@ impl serde::de::Error for Error {
}
}
impl<'de, 'a> serde::de::Deserializer<'de> for &'a mut BencodeDeserializer<'de> {
impl<'de> serde::de::Deserializer<'de> for &mut BencodeDeserializer<'de> {
type Error = Error;
fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
@ -517,7 +517,7 @@ struct SeqAccess<'a, 'de> {
de: &'a mut BencodeDeserializer<'de>,
}
impl<'a, 'de> serde::de::MapAccess<'de> for MapAccess<'a, 'de> {
impl<'de> serde::de::MapAccess<'de> for MapAccess<'_, 'de> {
type Error = Error;
fn next_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>, Self::Error>
@ -559,7 +559,7 @@ impl<'a, 'de> serde::de::MapAccess<'de> for MapAccess<'a, 'de> {
}
}
impl<'a, 'de> serde::de::SeqAccess<'de> for SeqAccess<'a, 'de> {
impl<'de> serde::de::SeqAccess<'de> for SeqAccess<'_, 'de> {
type Error = Error;
fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>

View file

@ -97,7 +97,7 @@ impl<W: std::io::Write> BencodeSerializer<W> {
struct SerializeSeq<'ser, W: std::io::Write> {
ser: &'ser mut BencodeSerializer<W>,
}
impl<'ser, W: std::io::Write> serde::ser::SerializeSeq for SerializeSeq<'ser, W> {
impl<W: std::io::Write> serde::ser::SerializeSeq for SerializeSeq<'_, W> {
type Ok = ();
type Error = SerError;
@ -117,7 +117,7 @@ impl<'ser, W: std::io::Write> serde::ser::SerializeSeq for SerializeSeq<'ser, W>
struct SerializeTuple<'ser, W: std::io::Write> {
ser: &'ser mut BencodeSerializer<W>,
}
impl<'ser, W: std::io::Write> serde::ser::SerializeTuple for SerializeTuple<'ser, W> {
impl<W: std::io::Write> serde::ser::SerializeTuple for SerializeTuple<'_, W> {
type Ok = ();
type Error = SerError;
@ -139,7 +139,7 @@ struct SerializeMap<'ser, W: std::io::Write> {
tmp: BTreeMap<ByteBufOwned, ByteBufOwned>,
last_key: Option<ByteBufOwned>,
}
impl<'ser, W: std::io::Write> serde::ser::SerializeMap for SerializeMap<'ser, W> {
impl<W: std::io::Write> serde::ser::SerializeMap for SerializeMap<'_, W> {
type Ok = ();
type Error = SerError;
@ -182,7 +182,7 @@ struct SerializeStruct<'ser, W: std::io::Write> {
ser: &'ser mut BencodeSerializer<W>,
tmp: BTreeMap<&'static str, ByteBufOwned>,
}
impl<'ser, W: std::io::Write> serde::ser::SerializeStruct for SerializeStruct<'ser, W> {
impl<W: std::io::Write> serde::ser::SerializeStruct for SerializeStruct<'_, W> {
type Ok = ();
type Error = SerError;

View file

@ -29,14 +29,14 @@ impl ByteBufT for ByteBufOwned {
}
}
impl<'a> ByteBufT for ByteBuf<'a> {
impl ByteBufT for ByteBuf<'_> {
fn as_slice(&self) -> &[u8] {
self.as_ref()
}
}
struct HexBytes<'a>(&'a [u8]);
impl<'a> std::fmt::Display for HexBytes<'a> {
impl std::fmt::Display for HexBytes<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
for byte in self.0 {
write!(f, "{byte:02x?}")?;
@ -71,13 +71,13 @@ fn debug_bytes(b: &[u8], f: &mut std::fmt::Formatter<'_>, debug_strings: bool) -
write!(f, "<{} bytes>", b.len())
}
impl<'a> std::fmt::Debug for ByteBuf<'a> {
impl std::fmt::Debug for ByteBuf<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
debug_bytes(self.0, f, true)
}
}
impl<'a> std::fmt::Display for ByteBuf<'a> {
impl std::fmt::Display for ByteBuf<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
debug_bytes(self.0, f, false)
}
@ -95,7 +95,7 @@ impl std::fmt::Display for ByteBufOwned {
}
}
impl<'a> CloneToOwned for ByteBuf<'a> {
impl CloneToOwned for ByteBuf<'_> {
type Target = ByteBufOwned;
fn clone_to_owned(&self, within_buffer: Option<&Bytes>) -> Self::Target {
@ -126,7 +126,7 @@ impl CloneToOwned for ByteBufOwned {
}
}
impl<'a> std::convert::AsRef<[u8]> for ByteBuf<'a> {
impl std::convert::AsRef<[u8]> for ByteBuf<'_> {
fn as_ref(&self) -> &[u8] {
self.0
}
@ -144,13 +144,13 @@ impl std::borrow::Borrow<[u8]> for ByteBufOwned {
}
}
impl<'a> std::borrow::Borrow<[u8]> for ByteBuf<'a> {
impl std::borrow::Borrow<[u8]> for ByteBuf<'_> {
fn borrow(&self) -> &[u8] {
self.0
}
}
impl<'a> std::ops::Deref for ByteBuf<'a> {
impl std::ops::Deref for ByteBuf<'_> {
type Target = [u8];
fn deref(&self) -> &Self::Target {
@ -190,7 +190,7 @@ impl From<Bytes> for ByteBufOwned {
}
}
impl<'a> serde::ser::Serialize for ByteBuf<'a> {
impl serde::ser::Serialize for ByteBuf<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
@ -215,7 +215,7 @@ impl<'de> serde::de::Deserialize<'de> for ByteBufOwned {
{
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
impl serde::de::Visitor<'_> for Visitor {
type Value = ByteBufOwned;
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {

View file

@ -27,7 +27,7 @@ impl<'de> Deserialize<'de> for MessageType {
D: serde::Deserializer<'de>,
{
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
impl serde::de::Visitor<'_> for Visitor {
type Value = MessageType;
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
@ -271,7 +271,7 @@ impl<'de> Deserialize<'de> for CompactPeerInfo {
D: Deserializer<'de>,
{
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
impl serde::de::Visitor<'_> for Visitor {
type Value = CompactPeerInfo;
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {

View file

@ -51,7 +51,7 @@ impl Serialize for PeerStore {
peers: &'a dashmap::DashMap<Id20, Vec<StoredPeer>>,
}
impl<'a> Serialize for SerializePeers<'a> {
impl Serialize for SerializePeers<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,

View file

@ -83,7 +83,7 @@ pub struct BucketTreeIteratorItem<'a> {
pub leaf: &'a LeafBucket,
}
impl<'a> BucketTreeIteratorItem<'a> {
impl BucketTreeIteratorItem<'_> {
pub fn random_within(&self) -> Id20 {
generate_random_id(self.start, self.bits)
}

View file

@ -92,7 +92,8 @@ tracing-subscriber = { version = "0.3", default-features = false, features = [
], optional = true }
uuid = { version = "1.2", features = ["v4"] }
futures = "0.3"
url = "2"
url = { version = "=2.5.2", default-features = false } # can't upgrade yet until min version is Rust 1.81, see https://github.com/servo/rust-url/issues/992
hex = "0.4"
backoff = "0.4.0"
dashmap = "6"

View file

@ -85,7 +85,7 @@ impl<'a> FileOps<'a> {
processed_bytes: u64,
is_broken: bool,
}
impl<'a> CurrentFile<'a> {
impl CurrentFile<'_> {
fn remaining(&self) -> u64 {
self.fi.len - self.processed_bytes
}

View file

@ -23,7 +23,7 @@ impl Subscriber {
}
}
impl<'a> MakeWriter<'a> for Subscriber {
impl MakeWriter<'_> for Subscriber {
type Writer = LineWriter<Writer>;
fn make_writer(&self) -> Self::Writer {

View file

@ -19,7 +19,7 @@ tracing = "0.1.40"
tokio = { version = "1", features = ["rt-multi-thread", "macros", "time"] }
hex = "0.4"
anyhow = "1"
url = "2"
url = { version = "2", default-features = false }
uuid = { version = "1", features = ["v4"] }
parking_lot = "0.12"
serde = { version = "1", features = ["derive"] }

View file

@ -125,7 +125,7 @@ pub enum FileIteratorName<'a, BufType> {
Tree(&'a [BufType]),
}
impl<'a, BufType> std::fmt::Debug for FileIteratorName<'a, BufType>
impl<BufType> std::fmt::Debug for FileIteratorName<'_, BufType>
where
BufType: AsRef<[u8]>,
{
@ -203,7 +203,7 @@ pub struct FileDetails<'a, BufType> {
pub symlink_path: Option<&'a [BufType]>,
}
impl<'a, BufType> FileDetails<'a, BufType>
impl<BufType> FileDetails<'_, BufType>
where
BufType: AsRef<[u8]>,
{
@ -235,7 +235,7 @@ pub struct FileDetailsExt<'a, BufType> {
pub pieces: std::ops::Range<u32>,
}
impl<'a, BufType> FileDetailsExt<'a, BufType> {
impl<BufType> FileDetailsExt<'_, BufType> {
pub fn pieces_usize(&self) -> std::ops::Range<usize> {
self.pieces.start as usize..self.pieces.end as usize
}

View file

@ -47,11 +47,11 @@ impl ExtendedHandshake<ByteBuf<'static>> {
}
}
impl<'a, ByteBuf> ExtendedHandshake<ByteBuf>
impl<ByteBuf> ExtendedHandshake<ByteBuf>
where
ByteBuf: ByteBufT,
{
fn get_msgid(&self, msg_type: &'a [u8]) -> Option<u8> {
fn get_msgid(&self, msg_type: &[u8]) -> Option<u8> {
self.m.get(msg_type).copied()
}

View file

@ -105,7 +105,7 @@ where
struct Visitor<T> {
p: PhantomData<T>,
}
impl<'de, T> serde::de::Visitor<'de> for Visitor<T>
impl<T> serde::de::Visitor<'_> for Visitor<T>
where
T: IpLike,
{

View file

@ -246,7 +246,7 @@ impl<'a> Bitfield<'a> {
}
}
impl<'a> std::fmt::Debug for Bitfield<'a> {
impl std::fmt::Debug for Bitfield<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Bitfield")
.field("_ones", &self.data.count_ones())

View file

@ -24,4 +24,4 @@ rand = "0.8"
tracing = "0.1.40"
reqwest = { version = "0.12", default-features = false, features = ["json"] }
bencode = { path = "../bencode", default-features = false, package = "librqbit-bencode", version = "3" }
url = "2"
url = { version = "2", default-features = false }

View file

@ -52,7 +52,7 @@ pub struct DictPeer<'a> {
port: u16,
}
impl<'a> DictPeer<'a> {
impl DictPeer<'_> {
fn as_sockaddr(&self) -> SocketAddr {
SocketAddr::new(self.ip, self.port)
}
@ -118,7 +118,7 @@ where
D: Deserializer<'de>,
{
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
impl serde::de::Visitor<'_> for Visitor {
type Value = IpAddr;
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {

View file

@ -31,18 +31,18 @@ gethostname = "0.5.0"
librqbit-sha1-wrapper = { path = "../sha1w", version = "4", default-features = false }
librqbit-core = { version = "4", path = "../librqbit_core", default-features = false }
mime_guess = "2.0.5"
url = "2.5.2"
url = { version = "2", default-features = false }
parking_lot = "0.12.3"
tokio-util = "0.7.11"
reqwest = { version = "0.12.7", default-features = false }
socket2 = "0.5.7"
quick-xml = { version = "0.36.1", features = ["serialize"] }
quick-xml = { version = "0.37.1", features = ["serialize"] }
network-interface = "2.0.0"
futures = "0.3.30"
[dev-dependencies]
tracing-subscriber = "0.3.18"
tower-http = { version = "0.5", features = ["trace"] }
tower-http = { version = "0.6.2", features = ["trace"] }
[[example]]
name = "upnp-stub-server"

View file

@ -150,7 +150,7 @@ pub mod browse {
// This COULD have been done with CDATA, but some Samsung TVs don't like that, they want
// escaped XML instead.
let items_encoded = quick_xml::escape::escape(items_encoded.as_ref());
let items_encoded = quick_xml::escape::escape(items_encoded);
format!(
include_str!(

View file

@ -39,7 +39,7 @@ pub struct SsdpMSearchRequest<'a> {
pub st: &'a BStr,
}
impl<'a> SsdpMSearchRequest<'a> {
impl SsdpMSearchRequest<'_> {
fn matches_media_server(&self) -> bool {
if self.man != "\"ssdp:discover\"" {
return false;
@ -80,17 +80,15 @@ pub fn try_parse_ssdp<'a, 'h>(
}
match (host, man, st) {
(Some(host), Some(man), Some(st)) => {
return Ok(SsdpMessage::MSearch(SsdpMSearchRequest {
host: BStr::new(host),
man: BStr::new(man),
st: BStr::new(st),
}))
}
(Some(host), Some(man), Some(st)) => Ok(SsdpMessage::MSearch(SsdpMSearchRequest {
host: BStr::new(host),
man: BStr::new(man),
st: BStr::new(st),
})),
_ => bail!("not all of host, man and st are set"),
}
}
_ => return Ok(SsdpMessage::OtherRequest(req)),
_ => Ok(SsdpMessage::OtherRequest(req)),
}
}

View file

@ -18,11 +18,11 @@ reqwest = { version = "0.12", default-features = false }
serde = { version = "1", features = ["derive"] }
tokio = { version = "1", features = ["macros"] }
futures = "0.3"
url = "2"
url = { version = "2", default-features = false }
network-interface = { version = "2" }
httparse = "1.9.4"
bstr = "1.10.0"
quick-xml = { version = "0.36.1", features = ["serialize"] }
quick-xml = { version = "0.37.1", features = ["serialize"] }
[dev-dependencies]
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }