# Limitations

## What Redline Can Catch

- Heap allocations via known patterns (Vec, Box, String, HashMap, clone, collect, etc.)
- System calls via known paths (fs, File, TcpStream, println, etc.)
- Loop costs when bounds are literal
- Worst-case branches (if/else, match)
- Closure bodies

## What Redline Cannot Catch

### Cross-Function Calls

Redline does not analyze callees. If `foo()` calls `bar()`, only `foo`'s body is analyzed. `bar`'s cost is estimated as a simple function call (5ns).

```rust
fn expensive() {
    std::thread::sleep(std::time::Duration::from_secs(10));
}

#[redline(latency = "< 1ms")]
fn looks_fine() {
    expensive();  // analyzer sees: 5ns function call. Actual: 10 seconds.
}
```

Cross-function analysis is planned for v0.2.

### Indirect Calls and Trait Objects

Function pointers, closures stored in variables, and trait object method calls are opaque.

```rust
#[redline(allocs = 0)]
fn indirect() -> String {
    let f: fn() -> String = String::new;
    f()  // analyzer sees a variable call, misses the allocation
}
```

### Dynamic Loop Bounds

Loops with non-literal bounds default to 1000 iterations:

```rust
#[redline(latency = "< 1ms")]
fn process(data: &[u8]) {
    for byte in data {  // how many? analyzer assumes 1000
        // ...
    }
}
```

### Type Aliases

If you alias a type, name matching fails:

```rust
use std::collections::HashMap as Map;

#[redline(allocs = 0)]
fn sneaky() {
    let m = Map::new();  // not caught: "Map" not in the known list
}
```

### unsafe and FFI

Unsafe blocks, raw pointer operations, and FFI calls are invisible:

```rust
#[redline(allocs = 0)]
fn ffi_alloc() {
    unsafe { libc::malloc(1024); }  // not caught
}
```

### Async Functions

`async fn` is not analyzed. The generated state machine is opaque to proc-macros.

## The Right Mental Model

Think of Redline as a **linter with teeth**, not a formal verifier. It catches the common cases: someone added a Vec, someone called println, someone wrote a hot loop that's too big. It does not catch every possible performance violation. It catches the ones that happen in practice.

Use Redline for hard bounds on the obvious stuff. Use benchmarks (Criterion) for precise measurement. They are complementary.
