intellij-rust/intellij-rust

Do not add parenthesis when completing methods in closures

Open

#4,450 创建于 2019年9月25日

在 GitHub 查看
 (0 评论) (1 反应) (0 负责人)Kotlin (4,526 star) (376 fork)batch import
E-easybughelp wantedsubsystem::сompletion

描述

Environment

  • IntelliJ Rust plugin version: 0.2.106.2134-193
  • Rust toolchain version: 1.37.0 (eae3437df 2019-08-13) x86_64-apple-darwin
  • IDE name and version: CLion 2019.3 EAP (CL-193.3519.24)
  • Operating system: macOS 10.14.6

Problem description

Rust allows omitting closure parameters and use functions in closures directly:

fn multiply_by_two(input: i32) -> i32 {
    input * 2
}

fn main() {
    let _ = Some(5).map(multiply_by_two);
}

When I try co compete such method, I get extra parenthesis added which breaks compilation.

fn multiply_by_two(input: i32) -> i32 {
    input * 2
}

fn main() {
    let _ = Some(5).map(mul/*caret*/);
}

Then I press tab and expect to get the example above. Instead I get:

fn multiply_by_two(input: i32) -> i32 {
    input * 2
}

fn main() {
    let _ = Some(5).map(multiply_by_two(/*caret*/));
}

贡献者指南