rust-lang / rust-mode

Emacs configuration for Rust
Apache License 2.0
1.1k stars 176 forks source link

Incorrect indentation of `if` when no parens are used #415

Open Hi-Angel opened 2 years ago

Hi-Angel commented 2 years ago

Steps to reproduce

  1. In rust-mode insert the code below:
    fn foo() {
        if (foo
            && bar) {
            true;
        }
    }
    fn foo() {
        if foo
            && bar {
                true;
            }
    }
  2. Try to indent it.

Expected

The line true in both paragraphs has the same offset

Actual

The line true has different offset in one and another paragraph

Additional information

Tested on 20210423 version in Elpa as well as the latest code in repo as of 494d59f commit.

Hi-Angel commented 2 years ago

Hmm, I tried figuring out where's the problem, but I only have found if being handled once where it's added to rust-looking-back-symbols; and since it's being added together with while which has no indentation problem, the fact it doesn't work correctly looks very odd to me. No idea what could go wrong here.

Hi-Angel commented 2 years ago

it's being added together with while which has no indentation problem

Oh wait, I take it back, the while has the exact same problem