about summary refs log tree commit diff
path: root/library/std/src/sys/unix/stack_overflow.rs
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-04-11 20:00:40 +0200
committerGitHub <noreply@github.com>2022-04-11 20:00:40 +0200
commit2ad701e45036fb2ccab8d4b4e23f9a3325e12817 (patch)
treee3d2525106965b176aaecf20ca9fde36e80cc198 /library/std/src/sys/unix/stack_overflow.rs
parent625e4dd13a3abd0cc59807af66c3c4cd63440852 (diff)
parent6ee3c47a3a41c495fcf52f342fe4253231a257c8 (diff)
downloadrust-2ad701e45036fb2ccab8d4b4e23f9a3325e12817.tar.gz
rust-2ad701e45036fb2ccab8d4b4e23f9a3325e12817.zip
Rollup merge of #95008 - c410-f3r:let-chains-paren, r=wesleywiser
[`let_chains`] Forbid `let` inside parentheses

Parenthesizes are mostly a no-op in let chains, in other words, they are mostly ignored.

```rust
let opt = Some(Some(1i32));

if (let Some(a) = opt && (let Some(b) = a)) && b == 1 {
    println!("`b` is declared inside but used outside");
}
```

As seen above, such behavior can lead to confusion.

A proper fix or nested encapsulation would probably require research, time and a modified MIR graph so in this PR I simply denied any `let` inside parentheses. Non-let stuff are still allowed.

```rust
fn main() {
    let fun = || true;

    if let true = (true && fun()) && (true) {
        println!("Allowed");
    }
}
```

It is worth noting that `let ...`  is not an expression and the RFC did not mention this specific situation.

cc `@matthewjasper`
Diffstat (limited to 'library/std/src/sys/unix/stack_overflow.rs')
0 files changed, 0 insertions, 0 deletions