浏览代码

docs: Document disabling safety checks (#3370)

Zhang ShengYan 10 月之前
父节点
当前提交
6dbe5a6ccd

+ 13 - 0
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.
 

+ 12 - 0
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

+ 17 - 0
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)

+ 2 - 0
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(),