Rule Template

2026-08-30 浏览 (1)

Rule Template

Use this template for all unsafe-checker rules.


---
id: {prefix}-{number}
original_id: P.UNS.XXX.YY or G.UNS.XXX.YY
level: P|G
impact: CRITICAL|HIGH|MEDIUM
clippy: <clippy_lint_name> (if applicable)
---

# {Rule Title}

## Summary

One-sentence description of what this rule requires.

## Rationale

Why this rule matters for safety/soundness.

## Bad Example

```rust
// DON'T: Description of the anti-pattern
<code that violates the rule>

Good Example

// DO: Description of the correct pattern
<code that follows the rule>

Common Violations

  1. Violation pattern 1
  2. Violation pattern 2

Checklist

  • Check item 1
  • Check item 2

Related Rules

  • {other-rule-id}: Brief description


## 你可能感兴趣的文章

[Do Not Expose Raw Pointers in Public APIs](https://seaxiang.com/blog/iCGnTgeT)

[Unsafe Code Authors Must Verify Safety Invariants](https://seaxiang.com/blog/MF6LCYyA)

[Ensure Consistent Data Layout for Custom Types](https://seaxiang.com/blog/vrnP50ZV)

[Add Safety Section in Docs for Public Unsafe Functions](https://seaxiang.com/blog/z9jlYTYl)

[Do Not Use Union Variants Across Different Lifetimes](https://seaxiang.com/blog/GXhsDZuy)

[Use MaybeUninit<T> for Uninitialized Memory](https://seaxiang.com/blog/PVBwLRGI)

[Ensure C-ABI Compatibility for Strings Between Rust and C](https://seaxiang.com/blog/RgPu3h1e)

[Do Not Dereference Pointers Cast to Misaligned Types](https://seaxiang.com/blog/f0rHrVzZ)

[Use Dedicated Opaque Type Pointers Instead of c_void for C Opaque Types](https://seaxiang.com/blog/kZsDs3pP)

[Choose Appropriate Data Layout for Struct/Tuple/Enum](https://seaxiang.com/blog/ptUZss4W)

  • 所属分类: AI
  • 本文标签: rust
  • 版权声明: 本文链接 https://seaxiang.com/blog/MfHonVnj