# Troubleshooting

## "function has N allocation(s), limit is 0" but I'm not allocating

Common causes:

1. **`.clone()` on a heap type.** Even `my_string.clone()` counts. Use references instead.
2. **`.to_string()` or `.to_owned()`.** These allocate. Pass `&str` instead.
3. **`.collect()`.** Collecting into a Vec/String/HashMap allocates. Process inline.
4. **`format!()` macro.** Allocates a String. Use `write!` to a pre-allocated buffer.

## Latency estimate is way too high

The cost model is pessimistic. Common inflators:

1. **Large loop bounds.** `for i in 0..1000000` = 1M iterations * body cost. Break into smaller functions.
2. **Unknown loop bounds.** `for x in data.iter()` defaults to 1000 iterations. Use literal ranges when possible.
3. **Nested loops.** Costs multiply. 100 * 100 = 10,000 iterations.

## "unknown redline constraint"

Check spelling. Valid constraints: `latency`, `throughput`, `allocs`, `syscalls`, `max_stack`.

## "redline requires at least one constraint"

Empty `#[redline()]` is not allowed. Add at least one constraint.

## Build works locally but fails in CI

Check Rust version. Redline requires edition 2021 and syn 2.x. Run `rustup update` in CI.

## False positive: `.get()` on a slice

Fixed in v0.1.0. If you see this, update to the latest version.

## My function calls another function that allocates

Redline v0.1 does not analyze across function boundaries. The callee is estimated as a 5ns function call. Cross-function analysis is planned for v0.2.

**Workaround:** Annotate both functions:

```rust
#[redline(allocs = 0)]
fn inner() -> u64 { 42 }

#[redline(allocs = 0)]
fn outer() -> u64 { inner() }
```

If `inner` allocates, it fails to compile on its own annotation.
