From 459314eb7910fcd2499db77141842296d007ea56 Mon Sep 17 00:00:00 2001 From: Zhang ShengYan Date: Mon, 18 Nov 2024 10:01:43 +0800 Subject: [PATCH 1/3] feat:introduce skip-lint in safety_checks error --- lang/syn/src/parser/context.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lang/syn/src/parser/context.rs b/lang/syn/src/parser/context.rs index ea0e4ee077..00a0937d22 100644 --- a/lang/syn/src/parser/context.rs +++ b/lang/syn/src/parser/context.rs @@ -70,6 +70,8 @@ impl CrateContext { {}:{}:{} Struct field "{}" is unsafe, but is not documented. Please add a `/// CHECK:` doc comment explaining why no checks through types are necessary. + Alternatively, for reasons like quick prototyping, you may disable the safety checks + by using the `skip-lint` option. See https://www.anchor-lang.com/docs/the-accounts-struct#safety-checks for more information. "#, ctx.file.canonicalize().unwrap().display(), From 1e3870058dfa9e3c8b137d4d2cbdf8a6962a7385 Mon Sep 17 00:00:00 2001 From: Zhang ShengYan Date: Mon, 18 Nov 2024 10:49:25 +0800 Subject: [PATCH 2/3] chore: add doc of skip-lint --- docs/src/pages/docs/the-accounts-struct.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/src/pages/docs/the-accounts-struct.md b/docs/src/pages/docs/the-accounts-struct.md index 7b0acce7ff..56ca9f054c 100644 --- a/docs/src/pages/docs/the-accounts-struct.md +++ b/docs/src/pages/docs/the-accounts-struct.md @@ -173,6 +173,23 @@ pub struct Initialize<'info> { The doc comment needs to be a [line or block doc comment](https://doc.rust-lang.org/reference/comments.html#doc-comments) (/// or /\*\*) to be interpreted as doc attribute by Rust. Double slash comments (//) are not interpreted as such. {% /callout %} +#### Disabling safety checks + +For purposes like quick prototyping, you can disable the safety checks by appending the `--skip-lint` option to Anchor CLI commands: + +```bash +anchor build --skip-lint +# or +anchor test --skip-lint +``` + +Or, you can disable the safety checks globally by setting `skip-lint` to `true` in the `[features]` section of your `Anchor.toml` file. + +```toml +[features] +skip-lint = true +``` + ## Other Resources - [Solana Cookbook](https://solanacookbook.com/core-concepts/accounts.html) From 1a94ded4b7997fa591e4962c34db81f2aa8781e9 Mon Sep 17 00:00:00 2001 From: Zhang ShengYan Date: Mon, 18 Nov 2024 13:51:31 +0800 Subject: [PATCH 3/3] doc: add intro of --skip-lint and link to Safety Checks --- docs/src/pages/docs/cli.md | 13 +++++++++++++ docs/src/pages/docs/manifest.md | 12 ++++++++++++ docs/src/pages/docs/the-accounts-struct.md | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/docs/src/pages/docs/cli.md b/docs/src/pages/docs/cli.md index 24b63409b0..95430c5456 100644 --- a/docs/src/pages/docs/cli.md +++ b/docs/src/pages/docs/cli.md @@ -69,6 +69,13 @@ anchor build Builds programs in the workspace targeting Solana's BPF runtime and emitting IDLs in the `target/idl` directory. + +```shell +anchor build --skip-lint +``` + +Disables [Safety Checks](/docs/the-accounts-struct#safety-checks) during the build process. + ```shell anchor build --verifiable ``` @@ -283,6 +290,12 @@ anchor test Run an integration test suit against the configured cluster, deploying new versions of all workspace programs before running them. +```shell +anchor test --skip-lint +``` + +Similar to `anchor build`, `--skip-lint` option disables [Safety Checks](/docs/the-accounts-struct#safety-checks). + If the configured network is a localnet, then automatically starts the localnetwork and runs the test. diff --git a/docs/src/pages/docs/manifest.md b/docs/src/pages/docs/manifest.md index d029f03767..4285bfb597 100644 --- a/docs/src/pages/docs/manifest.md +++ b/docs/src/pages/docs/manifest.md @@ -50,6 +50,18 @@ Example: resolution = true ``` +#### skip-lint + +This disables the safety checks globally. The default is `false`. + +Example: + +``` +[features] +skip-lint = true +``` +See [Safety Checks](/docs/the-accounts-struct#safety-checks) for more information. + ## workspace #### types diff --git a/docs/src/pages/docs/the-accounts-struct.md b/docs/src/pages/docs/the-accounts-struct.md index 56ca9f054c..fc4839ceb8 100644 --- a/docs/src/pages/docs/the-accounts-struct.md +++ b/docs/src/pages/docs/the-accounts-struct.md @@ -173,7 +173,7 @@ pub struct Initialize<'info> { The doc comment needs to be a [line or block doc comment](https://doc.rust-lang.org/reference/comments.html#doc-comments) (/// or /\*\*) to be interpreted as doc attribute by Rust. Double slash comments (//) are not interpreted as such. {% /callout %} -#### Disabling safety checks +### Disabling safety checks For purposes like quick prototyping, you can disable the safety checks by appending the `--skip-lint` option to Anchor CLI commands: