> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Rust Deny Attribute

The `deny` attribute is a compiler directive used to elevate the severity of specific lints or lint groups to compilation errors. When the Rust compiler (`rustc`) or a linter (like Clippy) encounters code that violates a rule specified within a `deny` attribute, it emits a compiler error and aborts the build prior to the code generation phase. The compiler does not short-circuit upon finding a violation; it continues analyzing the code to report as many errors and lint violations as possible before terminating.

## Syntax and Application

The attribute can be applied at different levels of the Abstract Syntax Tree (AST) using either inner or outer attribute syntax. It accepts a comma-separated list of lint identifiers or lint groups.

**Inner Attribute Syntax (`#![...]`)**
Applies to the enclosing scope, typically placed at the top of the crate root (`main.rs` or `lib.rs`) or a module file.

```rust theme={"dark"}
#![deny(missing_docs, unused_imports)]
#![deny(clippy::all)]
```

**Outer Attribute Syntax (`#[...]`)**
Applies lexically to the specific item that immediately follows it, such as a function, struct, or module, including all of its descendants.

```rust theme={"dark"}
#[deny(non_camel_case_types)]
struct my_struct { // Compiler error: type `my_struct` should have an upper camel case name
    id: i32,
}
```

## Scope and Overriding Mechanics

The `deny` attribute operates using lexical scoping. A lint level defined at a higher level of the AST propagates downward to all child nodes.

Crucially, `deny` establishes a strict baseline but **can be overridden** in narrower scopes. If a parent module denies a lint, a child module or specific function can explicitly downgrade that lint's severity using the `allow` or `warn` attributes.

```rust theme={"dark"}
#![deny(unused_variables)] // Denied globally for this file

fn strict_function() {
    let a = 1; // Compiler error: unused variable `a`
}

#[allow(unused_variables)] // Overrides the global `deny` for this function only
fn relaxed_function() {
    let b = 2; // Allowed by the override; no lint error triggered here
}
```

## `deny` vs. `forbid`

While both `deny` and `forbid` trigger compilation errors upon lint violations, their overriding mechanics differ strictly:

* **`deny`**: Can be overridden by `allow` or `warn` in a narrower scope.
* **`forbid`**: Locks the lint level. It cannot be overridden. If a lint is forbidden, any subsequent attempt to use `#[allow(...)]` or `#[warn(...)]` on that same lint in a child scope will itself trigger a compilation error.

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Rust Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
