rust-lang / rust-lang/rust-mode

Incorrect indentation of `if` when no parens are used

Open
#415 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

indentation
Dominant language
Emacs Lisp
Stars
1.3k
Forks
198
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the two Rust snippets in rust-mode and compare how indentation is calculated for the parenthesized and unparenthesized conditions. Trace the rust-mode indentation entry point responsible for those lines, then verify that both examples indent the true line at the same offset.

Written by the indexing model from the issue text.

Assessment

Tech stack
emacs, emacs-lisp, rust
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.