Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix several clippy warnings #3556

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion avm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ pub fn install_version(
let target = core::str::from_utf8(&output.stdout)?
.lines()
.find(|line| line.starts_with("host:"))
.and_then(|line| line.split(':').last())
.and_then(|line| line.split(':').next_back())
.ok_or_else(|| anyhow!("`host` not found from `rustc -vV` output"))?
.trim();
let ext = if cfg!(target_os = "windows") {
Expand Down
4 changes: 2 additions & 2 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4237,14 +4237,14 @@ fn airdrop(cfg_override: &ConfigOverride) -> Result<()> {
let url = cfg_override
.cluster
.as_ref()
.unwrap_or_else(|| &Cluster::Devnet)
.unwrap_or(&Cluster::Devnet)
.url();
loop {
let exit = std::process::Command::new("solana")
.arg("airdrop")
.arg("10")
.arg("--url")
.arg(&url)
.arg(url)
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.output()
Expand Down
2 changes: 1 addition & 1 deletion client/src/nonblocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use solana_sdk::{
use std::{marker::PhantomData, ops::Deref, sync::Arc};
use tokio::sync::RwLock;

impl<'a> EventUnsubscriber<'a> {
impl EventUnsubscriber<'_> {
/// Unsubscribe gracefully.
pub async fn unsubscribe(self) {
self.unsubscribe_internal().await
Expand Down
2 changes: 1 addition & 1 deletion lang/src/accounts/account_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use std::ops::DerefMut;
/// for example, the [`Account`](crate::accounts::account::Account). Namely,
/// one must call
/// - `load_init` after initializing an account (this will ignore the missing
/// account discriminator that gets added only after the user's instruction code)
/// account discriminator that gets added only after the user's instruction code)
/// - `load` when the account is not mutable
/// - `load_mut` when the account is mutable
///
Expand Down
6 changes: 3 additions & 3 deletions lang/src/accounts/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ use std::ops::Deref;
/// The required constraints are as follows:
///
/// - `program` is the account of the program itself.
/// Its constraint checks that `program_data` is the account that contains the program's upgrade authority.
/// Implicitly, this checks that `program` is a BPFUpgradeable program (`program.programdata_address()?`
/// will be `None` if it's not).
/// Its constraint checks that `program_data` is the account that contains the program's upgrade authority.
/// Implicitly, this checks that `program` is a BPFUpgradeable program (`program.programdata_address()?`
/// will be `None` if it's not).
/// - `program_data`'s constraint checks that its upgrade authority is the `authority` account.
/// - Finally, `authority` needs to sign the transaction.
///
Expand Down
6 changes: 3 additions & 3 deletions lang/src/accounts/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ use std::ops::Deref;
/// The required constraints are as follows:
///
/// - `program` is the account of the program itself.
/// Its constraint checks that `program_data` is the account that contains the program's upgrade authority.
/// Implicitly, this checks that `program` is a BPFUpgradeable program (`program.programdata_address()?`
/// will be `None` if it's not).
/// Its constraint checks that `program_data` is the account that contains the program's upgrade authority.
/// Implicitly, this checks that `program` is a BPFUpgradeable program (`program.programdata_address()?`
/// will be `None` if it's not).
/// - `program_data`'s constraint checks that its upgrade authority is the `authority` account.
/// - Finally, `authority` needs to sign the transaction.
///
Expand Down
8 changes: 4 additions & 4 deletions lang/syn/src/idl/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,10 @@ impl SeedPath {

// Check unsupported cases e.g. `&(account.field + 1).to_le_bytes()`
if !seed_str.contains('"')
&& seed_str.contains(|c: char| matches!(c, '+' | '-' | '*' | '/' | '%' | '^'))
{
return Err(anyhow!("Seed expression not supported: {seed:#?}"));
}
&& seed_str.contains(|c: char| ['+', '-', '*', '/', '%', '^'].contains(&c))
{
return Err(anyhow!("Seed expression not supported: {seed:#?}"));
}

// Break up the seed into each subfield component.
let mut components = seed_str.split('.').collect::<Vec<_>>();
Expand Down
2 changes: 1 addition & 1 deletion lang/syn/src/idl/defined.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ pub fn gen_idl_type(
if path.path.segments.len() != 1 {
return false;
};
return get_first_segment(path).ident == cmp;
get_first_segment(path).ident == cmp
}

fn get_angle_bracketed_type_args(seg: &syn::PathSegment) -> Vec<&syn::Type> {
Expand Down
2 changes: 1 addition & 1 deletion lang/syn/src/idl/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fn parse_lock_file(path: impl AsRef<Path>) -> Result<Vec<(String, String)>> {
let get_value = |key: &str| -> String {
pkg.lines()
.find(|line| line.starts_with(key))
.expect(&format!("`{key}` line not found"))
.unwrap_or_else(|| panic!("`{key}` line not found"))
.split('"')
.nth(1)
.unwrap()
Expand Down
2 changes: 1 addition & 1 deletion lang/syn/src/parser/program/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub fn parse_return(method: &syn::ItemFn) -> ParseResult<IxReturn> {
// Assume unit return by default
let default_generic_arg = syn::GenericArgument::Type(syn::parse_str("()").unwrap());
let generic_args = match &ty.path.segments.last().unwrap().arguments {
syn::PathArguments::AngleBracketed(params) => params.args.iter().last().unwrap(),
syn::PathArguments::AngleBracketed(params) => params.args.iter().next_back().unwrap(),
_ => &default_generic_arg,
};
let ty = match generic_args {
Expand Down