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:
parent
f3c4a53e1e
commit
45c7f3049b
|
|
@ -15,6 +15,7 @@ jobs:
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
profile: minimal
|
||||||
|
toolchain: 1.65
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cargo build --verbose --all-features
|
run: cargo build --verbose --all-features
|
||||||
env:
|
env:
|
||||||
|
|
@ -42,7 +43,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
profile: minimal
|
||||||
components: clippy, rustfmt
|
components: clippy, rustfmt
|
||||||
toolchain: 1.64
|
toolchain: 1.65
|
||||||
- name: Cache cargo registry
|
- name: Cache cargo registry
|
||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
|
|
@ -285,7 +285,7 @@ impl PublicKey {
|
||||||
buf[..2].copy_from_slice(&Self::MULTICODEC_TYPE);
|
buf[..2].copy_from_slice(&Self::MULTICODEC_TYPE);
|
||||||
buf[2..].copy_from_slice(self.0.deref());
|
buf[2..].copy_from_slice(self.0.deref());
|
||||||
|
|
||||||
multibase::encode(multibase::Base::Base58Btc, &buf)
|
multibase::encode(multibase::Base::Base58Btc, buf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ impl Keystore {
|
||||||
/// The `passphrase` is used to encrypt the private key.
|
/// The `passphrase` is used to encrypt the private key.
|
||||||
pub fn init(&self, comment: &str, passphrase: &str) -> Result<PublicKey, Error> {
|
pub fn init(&self, comment: &str, passphrase: &str) -> Result<PublicKey, Error> {
|
||||||
let pair = KeyPair::generate();
|
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 ssh_pair = ssh_key::private::KeypairData::Ed25519(ssh_pair);
|
||||||
let secret = ssh_key::PrivateKey::new(ssh_pair, comment)?;
|
let secret = ssh_key::PrivateKey::new(ssh_pair, comment)?;
|
||||||
let secret = secret.encrypt(ssh_key::rand_core::OsRng, passphrase)?;
|
let secret = secret.encrypt(ssh_key::rand_core::OsRng, passphrase)?;
|
||||||
|
|
|
||||||
|
|
@ -417,9 +417,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
let seeds = self.seeds(&id);
|
let seeds = self.seeds(&id);
|
||||||
let seeds = if let Some(seeds) = NonEmpty::from_vec(seeds) {
|
let Some(seeds) = NonEmpty::from_vec(seeds) else {
|
||||||
seeds
|
|
||||||
} else {
|
|
||||||
log::error!("No seeds found for {}", id);
|
log::error!("No seeds found for {}", id);
|
||||||
resp.send(FetchLookup::NotFound).ok();
|
resp.send(FetchLookup::NotFound).ok();
|
||||||
|
|
||||||
|
|
@ -755,9 +753,7 @@ where
|
||||||
message: Message,
|
message: Message,
|
||||||
) -> Result<(), session::Error> {
|
) -> Result<(), session::Error> {
|
||||||
let peer_ip = remote.ip();
|
let peer_ip = remote.ip();
|
||||||
let peer = if let Some(peer) = self.sessions.get_mut(&peer_ip) {
|
let Some(peer) = self.sessions.get_mut(&peer_ip) else {
|
||||||
peer
|
|
||||||
} else {
|
|
||||||
return Err(session::Error::NotFound(remote.ip()));
|
return Err(session::Error::NotFound(remote.ip()));
|
||||||
};
|
};
|
||||||
peer.last_active = self.clock.local_time();
|
peer.last_active = self.clock.local_time();
|
||||||
|
|
|
||||||
|
|
@ -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,
|
// It's also possible that the connection was only attempted and never succeeded,
|
||||||
// in which case we would return here.
|
// in which case we would return here.
|
||||||
let port = if let Some(port) = self.connections.get(&(node, remote.ip())) {
|
let Some(port) = self.connections.get(&(node, remote.ip())) else {
|
||||||
*port
|
|
||||||
} else {
|
|
||||||
debug!(target: "sim", "Ignoring disconnect of {remote} from {node}");
|
debug!(target: "sim", "Ignoring disconnect of {remote} from {node}");
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let local_addr: net::SocketAddr = (node, port).into();
|
let local_addr: net::SocketAddr = (node, *port).into();
|
||||||
let latency = self.latency(node, remote.ip());
|
let latency = self.latency(node, remote.ip());
|
||||||
|
|
||||||
// The remote node receives the disconnection with some delay.
|
// The remote node receives the disconnection with some delay.
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,8 @@ impl Encode for PublicKey {
|
||||||
|
|
||||||
impl<const T: usize> Encode for &[u8; T] {
|
impl<const T: usize> Encode for &[u8; T] {
|
||||||
fn encode<W: io::Write + ?Sized>(&self, writer: &mut W) -> Result<usize, io::Error> {
|
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)?;
|
writer.write_all(*self)?;
|
||||||
|
|
||||||
Ok(mem::size_of::<Self>())
|
Ok(mem::size_of::<Self>())
|
||||||
|
|
|
||||||
|
|
@ -63,9 +63,7 @@ pub trait ClientStream: Sized + Send + Sync {
|
||||||
P: AsRef<Path> + Send;
|
P: AsRef<Path> + Send;
|
||||||
|
|
||||||
fn connect_env() -> Result<AgentClient<Self>, Error> {
|
fn connect_env() -> Result<AgentClient<Self>, Error> {
|
||||||
let var = if let Ok(var) = std::env::var("SSH_AUTH_SOCK") {
|
let Ok(var) = std::env::var("SSH_AUTH_SOCK") else {
|
||||||
var
|
|
||||||
} else {
|
|
||||||
return Err(Error::EnvVar("SSH_AUTH_SOCK"));
|
return Err(Error::EnvVar("SSH_AUTH_SOCK"));
|
||||||
};
|
};
|
||||||
match Self::connect(var) {
|
match Self::connect(var) {
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ impl Encoding for Vec<u8> {
|
||||||
|
|
||||||
fn extend_list<'a, I: Iterator<Item = &'a [u8]>>(&mut self, list: I) {
|
fn extend_list<'a, I: Iterator<Item = &'a [u8]>>(&mut self, list: I) {
|
||||||
let len0 = self.len();
|
let len0 = self.len();
|
||||||
self.extend(&[0, 0, 0, 0]);
|
self.extend([0, 0, 0, 0]);
|
||||||
|
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
for i in list {
|
for i in list {
|
||||||
|
|
@ -120,7 +120,7 @@ impl Encoding for Vec<u8> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_empty_list(&mut self) {
|
fn write_empty_list(&mut self) {
|
||||||
self.extend(&[0, 0, 0, 0]);
|
self.extend([0, 0, 0, 0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_len(&mut self) {
|
fn write_len(&mut self) {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ fn main() -> anyhow::Result<()> {
|
||||||
let profile = radicle::Profile::load()?;
|
let profile = radicle::Profile::load()?;
|
||||||
let (_, id) = radicle::rad::remote(&repo)?;
|
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);
|
println!("{}", output);
|
||||||
|
|
||||||
let signer = profile.signer()?;
|
let signer = profile.signer()?;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#![allow(clippy::match_like_matches_macro)]
|
#![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))]
|
#![cfg_attr(not(test), warn(clippy::unwrap_used))]
|
||||||
|
|
||||||
pub extern crate radicle_crypto as crypto;
|
pub extern crate radicle_crypto as crypto;
|
||||||
|
|
|
||||||
|
|
@ -352,9 +352,7 @@ impl Repository {
|
||||||
let r = reference?;
|
let r = reference?;
|
||||||
let name = r.name().ok_or(refs::Error::InvalidRef)?;
|
let name = r.name().ok_or(refs::Error::InvalidRef)?;
|
||||||
let (namespace, refname) = git::parse_ref_namespaced::<RemoteId>(name)?;
|
let (namespace, refname) = git::parse_ref_namespaced::<RemoteId>(name)?;
|
||||||
let oid = if let Some(oid) = r.target() {
|
let Some(oid) = r.target() else {
|
||||||
oid
|
|
||||||
} else {
|
|
||||||
// Ignore symbolic refs, eg. `HEAD`.
|
// Ignore symbolic refs, eg. `HEAD`.
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
1.64
|
1.65
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue