Update to Rust 1.65

* Use new let-else syntax
* Fix new clippy lints

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
This commit is contained in:
Alexis Sellier 2022-11-04 13:01:20 +01:00
parent f3c4a53e1e
commit 45c7f3049b
No known key found for this signature in database
12 changed files with 17 additions and 23 deletions

View File

@ -15,6 +15,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.65
- name: Build
run: cargo build --verbose --all-features
env:
@ -42,7 +43,7 @@ jobs:
with:
profile: minimal
components: clippy, rustfmt
toolchain: 1.64
toolchain: 1.65
- name: Cache cargo registry
uses: actions/cache@v1
with:

View File

@ -285,7 +285,7 @@ impl PublicKey {
buf[..2].copy_from_slice(&Self::MULTICODEC_TYPE);
buf[2..].copy_from_slice(self.0.deref());
multibase::encode(multibase::Base::Base58Btc, &buf)
multibase::encode(multibase::Base::Base58Btc, buf)
}
}

View File

@ -48,7 +48,7 @@ impl Keystore {
/// The `passphrase` is used to encrypt the private key.
pub fn init(&self, comment: &str, passphrase: &str) -> Result<PublicKey, Error> {
let pair = KeyPair::generate();
let ssh_pair = ssh_key::private::Ed25519Keypair::from_bytes(&*pair)?;
let ssh_pair = ssh_key::private::Ed25519Keypair::from_bytes(&pair)?;
let ssh_pair = ssh_key::private::KeypairData::Ed25519(ssh_pair);
let secret = ssh_key::PrivateKey::new(ssh_pair, comment)?;
let secret = secret.encrypt(ssh_key::rand_core::OsRng, passphrase)?;

View File

@ -417,9 +417,7 @@ where
}
let seeds = self.seeds(&id);
let seeds = if let Some(seeds) = NonEmpty::from_vec(seeds) {
seeds
} else {
let Some(seeds) = NonEmpty::from_vec(seeds) else {
log::error!("No seeds found for {}", id);
resp.send(FetchLookup::NotFound).ok();
@ -755,9 +753,7 @@ where
message: Message,
) -> Result<(), session::Error> {
let peer_ip = remote.ip();
let peer = if let Some(peer) = self.sessions.get_mut(&peer_ip) {
peer
} else {
let Some(peer) = self.sessions.get_mut(&peer_ip) else {
return Err(session::Error::NotFound(remote.ip()));
};
peer.last_active = self.clock.local_time();

View File

@ -560,13 +560,11 @@ impl<S: WriteStorage + 'static, G: Signer> Simulation<S, G> {
//
// It's also possible that the connection was only attempted and never succeeded,
// in which case we would return here.
let port = if let Some(port) = self.connections.get(&(node, remote.ip())) {
*port
} else {
let Some(port) = self.connections.get(&(node, remote.ip())) else {
debug!(target: "sim", "Ignoring disconnect of {remote} from {node}");
return;
};
let local_addr: net::SocketAddr = (node, port).into();
let local_addr: net::SocketAddr = (node, *port).into();
let latency = self.latency(node, remote.ip());
// The remote node receives the disconnection with some delay.

View File

@ -129,6 +129,8 @@ impl Encode for PublicKey {
impl<const T: usize> Encode for &[u8; T] {
fn encode<W: io::Write + ?Sized>(&self, writer: &mut W) -> Result<usize, io::Error> {
// TODO: This can be removed when the clippy bugs are fixed
#[allow(clippy::explicit_auto_deref)]
writer.write_all(*self)?;
Ok(mem::size_of::<Self>())

View File

@ -63,9 +63,7 @@ pub trait ClientStream: Sized + Send + Sync {
P: AsRef<Path> + Send;
fn connect_env() -> Result<AgentClient<Self>, Error> {
let var = if let Ok(var) = std::env::var("SSH_AUTH_SOCK") {
var
} else {
let Ok(var) = std::env::var("SSH_AUTH_SOCK") else {
return Err(Error::EnvVar("SSH_AUTH_SOCK"));
};
match Self::connect(var) {

View File

@ -103,7 +103,7 @@ impl Encoding for Vec<u8> {
fn extend_list<'a, I: Iterator<Item = &'a [u8]>>(&mut self, list: I) {
let len0 = self.len();
self.extend(&[0, 0, 0, 0]);
self.extend([0, 0, 0, 0]);
let mut first = true;
for i in list {
@ -120,7 +120,7 @@ impl Encoding for Vec<u8> {
}
fn write_empty_list(&mut self) {
self.extend(&[0, 0, 0, 0]);
self.extend([0, 0, 0, 0]);
}
fn write_len(&mut self) {

View File

@ -8,7 +8,7 @@ fn main() -> anyhow::Result<()> {
let profile = radicle::Profile::load()?;
let (_, id) = radicle::rad::remote(&repo)?;
let output = radicle::git::run::<_, _, &str, &str>(&cwd, &["push", "rad"], None)?;
let output = radicle::git::run::<_, _, &str, &str>(&cwd, ["push", "rad"], None)?;
println!("{}", output);
let signer = profile.signer()?;

View File

@ -1,4 +1,5 @@
#![allow(clippy::match_like_matches_macro)]
#![allow(clippy::explicit_auto_deref)] // TODO: This can be removed when the clippy bugs are fixed
#![cfg_attr(not(test), warn(clippy::unwrap_used))]
pub extern crate radicle_crypto as crypto;

View File

@ -352,9 +352,7 @@ impl Repository {
let r = reference?;
let name = r.name().ok_or(refs::Error::InvalidRef)?;
let (namespace, refname) = git::parse_ref_namespaced::<RemoteId>(name)?;
let oid = if let Some(oid) = r.target() {
oid
} else {
let Some(oid) = r.target() else {
// Ignore symbolic refs, eg. `HEAD`.
return Ok(None);
};

View File

@ -1 +1 @@
1.64
1.65