From 9fc9c4035e85f462fe50c3e625669fa06c6e7b8d Mon Sep 17 00:00:00 2001 From: acheron Date: Wed, 8 Jan 2025 08:22:13 +0100 Subject: [PATCH 1/2] cli: Fix altering user-provided lib name --- cli/src/config.rs | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/cli/src/config.rs b/cli/src/config.rs index f38100aba5..94afa6d075 100644 --- a/cli/src/config.rs +++ b/cli/src/config.rs @@ -79,24 +79,15 @@ impl Manifest { } pub fn lib_name(&self) -> Result { - if self.lib.is_some() && self.lib.as_ref().unwrap().name.is_some() { - Ok(self - .lib - .as_ref() - .unwrap() - .name - .as_ref() - .unwrap() - .to_string() - .to_snake_case()) - } else { - Ok(self + match &self.lib { + Some(cargo_toml::Product { + name: Some(name), .. + }) => Ok(name.to_owned()), + _ => self .package .as_ref() - .ok_or_else(|| anyhow!("package section not provided"))? - .name - .to_string() - .to_snake_case()) + .ok_or_else(|| anyhow!("package section not provided")) + .map(|pkg| pkg.name.to_snake_case()), } } From a447996a9c9451b60dec201786617e9cffc56fab Mon Sep 17 00:00:00 2001 From: acheron Date: Wed, 8 Jan 2025 17:47:33 +0100 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7543ce7e61..bf27615ca6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -108,6 +108,7 @@ The minor version will be incremented upon a breaking change and the patch versi - cli: Ignore non semver solana/agave releases to avoid panic ([#3432](https://github.com/coral-xyz/anchor/pull/3432)). - ts: Fix loading programs with numbers in their names using `workspace` ([#3450](https://github.com/coral-xyz/anchor/pull/3450)). - lang: Remove a potential panic while getting the IDL in `declare_program!` ([#3458](https://github.com/coral-xyz/anchor/pull/3458)). +- cli: Fix altering user-provided lib names ([#3467](https://github.com/coral-xyz/anchor/pull/3467)). ### Breaking