Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Fill match arms" inside #[async_trait]-annotated impl fills incorrectly (extra closing brace, incorrect indentation) #18863

Closed
maddiemort opened this issue Jan 7, 2025 · 1 comment
Labels
A-assists A-proc-macro proc macro C-bug Category: bug

Comments

@maddiemort
Copy link

maddiemort commented Jan 7, 2025

rust-analyzer version: rust-analyzer 1.83.0 (90b35a62 2024-11-26)

rustc version: rustc 1.83.0 (90b35a623 2024-11-26)

editor or extension: Observed with both helix 25.1 (dabfb6ce) with the stock configuration, and nvim v0.10.3 both with rustaceanvim and with rust-analyzer directly configured through nvim-lspconfig. This doesn't appear to be sensitive to editor or extension version.

relevant settings: No settings appear to be relevant, this happens with multiple editors. Rust is installed through Rustup, and the editors are using the rust-analyzer binary installed via rustup component add rust-analyzer.

code snippet to reproduce:

# Cargo.toml

[package]
name = "match-arm-bug"
version = "0.1.0"
edition = "2021"

[dependencies]
async-trait = "0.1.85"
// lib.rs

#[async_trait::async_trait]
trait Bug {
    async fn foo(result: Result<(), ()>);
}

struct Buggy;

#[async_trait::async_trait]
impl Bug for Buggy {
    async fn foo(result: Result<(), ()>) {
        match result {}
    }
}

Go to the line containing match result {} and choose the "Fill match arms" code action. This produces the following output:

// lib.rs

#[async_trait::async_trait]
trait Bug {
    async fn foo(result: Result<(), ()>);
}

struct Buggy;

#[async_trait::async_trait]
impl Bug for Buggy {
    async fn foo(result: Result<(), ()>) {
        match result {
    Ok(_) => todo!(),
    Err(_) => todo!(),
}}
    }
}
@maddiemort maddiemort added the C-bug Category: bug label Jan 7, 2025
@lnicola
Copy link
Member

lnicola commented Jan 7, 2025

This was fixed in yesterday's release, but it didn't reach the rustup component.

@lnicola lnicola closed this as completed Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-assists A-proc-macro proc macro C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants