Skip to content

Commit

Permalink
Add workspace lints, start fixing doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
joncinque committed Oct 30, 2024
1 parent 79572ba commit f23917a
Show file tree
Hide file tree
Showing 24 changed files with 76 additions and 25 deletions.
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ exclude = [

resolver = "2"

[workspace.lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
'cfg(target_os, values("solana"))',
'cfg(feature, values("frozen-abi", "no-entrypoint"))',
]

[workspace.metadata.release]
pre-release-commit-message = "Publish {{crate_name}} v{{version}}"
tag-message = "Publish {{crate_name}} v{{version}}"
Expand Down
3 changes: 3 additions & 0 deletions binary-option/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ uint = "0.10"

[lib]
crate-type = ["cdylib", "lib"]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions binary-oracle-pair/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ solana-sdk = "2.1.0"

[lib]
crate-type = ["cdylib", "lib"]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions examples/rust/custom-heap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ crate-type = ["cdylib", "lib"]

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions feature-proposal/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ crate-type = ["cdylib", "lib"]

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions governance/addin-mock/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ spl-governance-test-sdk = { version = "0.1.4", path = "../../test-sdk" }

[lib]
crate-type = ["cdylib", "lib"]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions governance/chat/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ spl-governance-addin-mock = { version = "0.1.4", path = "../../addin-mock/progra

[lib]
crate-type = ["cdylib", "lib"]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions governance/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ spl-governance-addin-mock = { version = "0.1.4", path = "../addin-mock/program"

[lib]
crate-type = ["cdylib", "lib"]

[lints]
workspace = true
4 changes: 2 additions & 2 deletions libraries/program-error/derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ pub fn print_program_error(input: TokenStream) -> TokenStream {
/// a unique `u32` _starting_ error codes from the names of the enum variants.
/// Notes:
/// - The _error_ variant will start at this value, and the rest will be
/// incremented by one
/// incremented by one
/// - The value provided is only for code readability, the actual error code
/// will be a hash of the input string and is checked against your input
/// will be a hash of the input string and is checked against your input
///
/// Syntax: `#[spl_program_error(hash_error_code_start = 1275525928)]`
/// Hash Input: `spl_program_error:<enum name>:<variant name>`
Expand Down
2 changes: 1 addition & 1 deletion memo/program/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ solana_program::declare_id!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr");
/// Accounts expected by this instruction:
///
/// 0. ..0+N. `[signer]` Expected signers; if zero provided, instruction will
/// be processed as a normal, unsigned spl-memo
/// be processed as a normal, unsigned spl-memo
pub fn build_memo(memo: &[u8], signer_pubkeys: &[&Pubkey]) -> Instruction {
Instruction {
program_id: id(),
Expand Down
3 changes: 3 additions & 0 deletions record/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ crate-type = ["cdylib", "lib"]

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions single-pool/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ approx = "0.5.1"

[lib]
crate-type = ["cdylib", "lib"]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions stake-pool/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ test-case = "3.3"

[lib]
crate-type = ["cdylib", "lib"]

[lints]
workspace = true
1 change: 0 additions & 1 deletion stake-pool/program/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,6 @@ impl Sealed for ValidatorStakeInfo {}
impl Pack for ValidatorStakeInfo {
const LEN: usize = 73;
fn pack_into_slice(&self, data: &mut [u8]) {
let data = data;
// Removing this unwrap would require changing from `Pack` to some other
// trait or `bytemuck`, so it stays in for now
borsh::to_writer(data, self).unwrap();
Expand Down
3 changes: 3 additions & 0 deletions stateless-asks/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ crate-type = ["cdylib", "lib"]

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[lints]
workspace = true
5 changes: 0 additions & 5 deletions token-group/interface/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,6 @@ pub fn initialize_member(
mod test {
use {super::*, crate::NAMESPACE, solana_program::hash};

#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable, SplDiscriminate)]
#[discriminator_hash_input("mock_group")]
struct MockGroup;

fn instruction_pack_unpack<I>(instruction: TokenGroupInstruction, discriminator: &[u8], data: I)
where
I: core::fmt::Debug + PartialEq + Pod + Zeroable + SplDiscriminate,
Expand Down
2 changes: 1 addition & 1 deletion token-lending/flash_loan_receiver/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn unpack_amount(input: &[u8]) -> Result<u64, ProgramError> {
.and_then(|slice| slice.try_into().ok())
.map(u64::from_le_bytes)
.ok_or(ProgramError::InvalidInstructionData)
.inspect_err(|e| {
.inspect_err(|_| {
msg!("Failed to unpack amount.");
})?;
Ok(amount)
Expand Down
3 changes: 3 additions & 0 deletions token-lending/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ solana-sdk = "2.1.0"

[lib]
crate-type = ["cdylib", "lib"]

[lints]
workspace = true
29 changes: 14 additions & 15 deletions token-lending/program/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ pub enum LendingInstruction {
/// 8. `[]` Pyth product account.
/// 9. `[]` Pyth price account. This will be used as the reserve liquidity
/// oracle account.
/// 10 `[]` Lending market account.
/// 11 `[]` Derived lending market authority.
/// 12 `[signer]` Lending market owner.
/// 13 `[signer]` User transfer authority ($authority).
/// 14 `[]` Clock sysvar.
/// 15 `[]` Rent sysvar.
/// 16 `[]` Token program id.
/// 10. `[]` Lending market account.
/// 11. `[]` Derived lending market authority.
/// 12. `[signer]` Lending market owner.
/// 13. `[signer]` User transfer authority ($authority).
/// 14. `[]` Clock sysvar.
/// 15. `[]` Rent sysvar.
/// 16. `[]` Token program id.
InitReserve {
/// Initial amount of liquidity to deposit into the new reserve
liquidity_amount: u64,
Expand Down Expand Up @@ -158,9 +158,8 @@ pub enum LendingInstruction {
///
/// 0. `[writable]` Obligation account.
/// 1. `[]` Clock sysvar.
/// .. `[]` Collateral deposit reserve accounts - refreshed, all, in
/// order. .. `[]` Liquidity borrow reserve accounts - refreshed, all,
/// in order.
/// .. `[]` Collateral deposit reserve accounts - refreshed, all, in order.
/// .. `[]` Liquidity borrow reserve accounts - refreshed, all, in order.
RefreshObligation,

// 8
Expand Down Expand Up @@ -227,7 +226,7 @@ pub enum LendingInstruction {
/// 7. `[signer]` Obligation owner.
/// 8. `[]` Clock sysvar.
/// 9. `[]` Token program id.
/// 10 `[optional, writable]` Host fee receiver account.
/// 10. `[optional, writable]` Host fee receiver account.
BorrowObligationLiquidity {
/// Amount of liquidity to borrow - u64::MAX for 100% of borrowing power
liquidity_amount: u64,
Expand Down Expand Up @@ -276,8 +275,8 @@ pub enum LendingInstruction {
/// 7. `[]` Lending market account.
/// 8. `[]` Derived lending market authority.
/// 9. `[signer]` User transfer authority ($authority).
/// 10 `[]` Clock sysvar.
/// 11 `[]` Token program id.
/// 10. `[]` Clock sysvar.
/// 11. `[]` Token program id.
LiquidateObligation {
/// Amount of liquidity to repay - u64::MAX for up to 100% of borrowed
/// amount
Expand All @@ -303,7 +302,7 @@ pub enum LendingInstruction {
/// 8. `[]` Flash loan receiver program id. Must implement an instruction
/// that has tag of 0 and a signature of `(amount: u64)` This
/// instruction must return the amount to the source liquidity account.
/// .. `[any]` Additional accounts expected by the receiving program's
/// .. `[any]` Additional accounts expected by the receiving program's
/// `ReceiveFlashLoan` instruction.
///
/// The flash loan receiver program that is to be invoked should contain
Expand All @@ -323,7 +322,7 @@ pub enum LendingInstruction {
/// `FlashLoan` instruction above. ReceiveFlashLoan {
/// // Amount that must be repaid by the receiver program
/// amount: u64
/// }
/// }
FlashLoan {
/// The amount that is to be borrowed - u64::MAX for up to 100% of
/// available liquidity
Expand Down
3 changes: 3 additions & 0 deletions token-wrap/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ crate-type = ["cdylib", "lib"]

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions token/confidential-transfer/elgamal-registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ crate-type = ["cdylib", "lib"]

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions token/confidential-transfer/proof-generation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ thiserror = "1.0.65"

[lib]
crate-type = ["cdylib", "lib"]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions token/program-2022/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ crate-type = ["cdylib", "lib"]

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions token/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ crate-type = ["cdylib", "lib"]

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[lints]
workspace = true

0 comments on commit f23917a

Please sign in to comment.