8000 Fix precedence parenthesis for replace_arith_op by A4-Tacks · Pull Request #20611 · rust-lang/rust-analyzer · GitHub
[go: up one dir, main page]

Skip to content

Conversation

A4-Tacks
Copy link
Contributor
@A4-Tacks A4-Tacks commented Sep 4, 2025

Example

fn main() {
    let x = 1*x $0+ 2;
}

Before this PR:

fn main() {
    let x = 1*x.wrapping_add(2);
}

After this PR:

fn main() {
    let x = (1*x).wrapping_add(2);
}

Example
---
```rust
fn main() {
    let x = 1*x $0+ 2;
}
```

**Before this PR**:

```rust
fn main() {
    let x = 1*x.wrapping_add(2);
}
```

**After this PR**:

```rust
fn main() {
    let x = (1*x).wrapping_add(2);
}
```
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 4, 2025
builder.replace(range, format!("({lhs}).{method_name}({rhs})"))
} else {
builder.replace(range, format!("{lhs}.{method_name}({rhs})"))
}
Copy link
Member
@ShoyuVanilla ShoyuVanilla Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to migrate this to SyntaxEditor but I think this PR doesn't worsen things

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, in #20748

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, in #20748

Copy link
Member
@ShoyuVanilla ShoyuVanilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ShoyuVanilla ShoyuVanilla added this pull request to the merge queue Sep 26, 2025
Merged via the queue into rust-lang:master with commit 6135c07 Sep 26, 2025
15 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 26, 2025
@A4-Tacks A4-Tacks deleted the replace-arith-op-prec branch September 26, 2025 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0