# needless-question-mark

Disallow propagation immediately wrapped in the same Result type

Propagating a Result payload and immediately rebuilding an identical successful Result performs two redundant operations.
Instead, you SHOULD return the original Result directly.

- Category: style
- Level: warning
- Fix: automatic
- Scope: module

## Reported

```ds title="main.ds"
function forward(result: Result<int32, string>): Result<int32, string> {
    return Result.ok(result?);
}
```

## Accepted

```ds title="main.ds"
function forward(result: Result<int32, string>): Result<int32, string> {
    return result;
}
```

## Prior art

- [Clippy · needless_question_mark](https://rust-lang.github.io/rust-clippy/master/index.html#needless_question_mark)

[language/linter/src/rules/style/needless_question_mark.rs:8](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/style/needless_question_mark.rs#L8)
