Skip to content

Commit 152d431

Browse files
authored
feat(cli): Add MSRV (#3873)
* Add MSRV * Make Clippy Happy * Do Not Pin Rust Version in Program Crate * Bump MSRV * Bump to 1.89.0 * Update CHANGELOG.md with MSRV PR
1 parent 56b21ed commit 152d431

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The minor version will be incremented upon a breaking change and the patch versi
1313
### Features
1414

1515
- lang: Add `#[error]` attribute to `declare_program!` ([#3757](https://github.com/coral-xyz/anchor/pull/3757)).
16+
- cli: Replace `anchor verify` to use `solana-verify` under the hood, adding automatic installation via AVM, local path support, and future-proof argument passing ([#3768](https://github.com/solana-foundation/anchor/pull/3768)).
1617
- lang: Replace `solana-program` crate with smaller crates ([#3819](https://github.com/solana-foundation/anchor/pull/3819)).
1718
- cli: Make `anchor deploy` to upload the IDL to the cluster by default unless `--no-idl` is passed ([#3863](https://github.com/solana-foundation/anchor/pull/3863)).
1819
- lang: Use `solana-invoke` instead of `solana_cpi::invoke` ([#3900](https://github.com/solana-foundation/anchor/pull/3900)).
@@ -23,6 +24,7 @@ The minor version will be incremented upon a breaking change and the patch versi
2324
- ts: Add support for Bun as a package manager ([#3586](https://github.com/solana-foundation/anchor/pull/3586)).
2425
- lang: Add support for tuple types in space calculation ([#3744](https://github.com/solana-foundation/anchor/pull/3744)).
2526
- lang: Add missing pubkey const generation ([#3677](https://github.com/solana-foundation/anchor/pull/3677)).
27+
- cli: Add the Minimum Supported Rust Version (MSRV) to the Rust template, since an arbitrary compiler version isn't supported ([#3873](https://github.com/solana-foundation/anchor/pull/3873)).
2628

2729
### Fixes
2830

cli/src/rust_template.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ use std::{
1818
process::Stdio,
1919
};
2020

21+
const ANCHOR_MSRV: &str = "1.89.0";
22+
2123
/// Program initialization template
2224
#[derive(Clone, Debug, Default, Eq, PartialEq, Parser, ValueEnum)]
2325
pub enum ProgramTemplate {
@@ -33,6 +35,7 @@ pub fn create_program(name: &str, template: ProgramTemplate, with_mollusk: bool)
3335
let program_path = Path::new("programs").join(name);
3436
let common_files = vec![
3537
("Cargo.toml".into(), workspace_manifest().into()),
38+
("rust-toolchain.toml".into(), rust_toolchain_toml()),
3639
(
3740
program_path.join("Cargo.toml"),
3841
cargo_toml(name, with_mollusk),
@@ -48,6 +51,18 @@ pub fn create_program(name: &str, template: ProgramTemplate, with_mollusk: bool)
4851
create_files(&[common_files, template_files].concat())
4952
}
5053

54+
/// Helper to create a rust-toolchain.toml at the workspace root
55+
fn rust_toolchain_toml() -> String {
56+
format!(
57+
r#"[toolchain]
58+
channel = "{msrv}"
59+
components = ["rustfmt","clippy"]
60+
profile = "minimal"
61+
"#,
62+
msrv = ANCHOR_MSRV
63+
)
64+
}
65+
5166
/// Create a program with a single `lib.rs` file.
5267
fn create_program_template_single(name: &str, program_path: &Path) -> Files {
5368
vec![(
@@ -732,11 +747,15 @@ name = "tests"
732747
version = "0.1.0"
733748
description = "Created with Anchor"
734749
edition = "2021"
750+
rust-version = "{msrv}"
735751
736752
[dependencies]
737-
anchor-client = "{VERSION}"
753+
anchor-client = "{version}"
738754
{name} = {{ version = "0.1.0", path = "../programs/{name}" }}
739755
"#,
756+
msrv = ANCHOR_MSRV,
757+
version = VERSION,
758+
name = name,
740759
)
741760
}
742761

0 commit comments

Comments
 (0)