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

Code action "fill match arms" adds extra } inside #[tokio::main] #18027

Closed
mawkler opened this issue Sep 2, 2024 · 0 comments · Fixed by #18794
Closed

Code action "fill match arms" adds extra } inside #[tokio::main] #18027

mawkler opened this issue Sep 2, 2024 · 0 comments · Fixed by #18794
Labels
A-assists C-bug Category: bug

Comments

@mawkler
Copy link

mawkler commented Sep 2, 2024

rust-analyzer version: 2024-09-02

rustc version: rustc 1.80.1 (3f5fd8dd4 2024-08-06)

editor or extension: Neovim + nvim-lspconfig. Here's my full (minimal) config:

Click to expand
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    'git',
    'clone',
    '--filter=blob:none',
    'https://github.com/folke/lazy.nvim.git',
    '--branch=stable', -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

-- install plugins
require('lazy').setup({
  "folke/tokyonight.nvim",
  {
    'neovim/nvim-lspconfig',
    dependencies = {
      { 'williamboman/mason.nvim', config = true },
      'williamboman/mason-lspconfig.nvim',
      'WhoIsSethDaniel/mason-tool-installer.nvim',
    },
    config = function()
      require('mason').setup()

      local servers = {}

      require('mason-tool-installer').setup {
        ensure_installed = { 'rust-analyzer' },
      }

      require('mason-lspconfig').setup {
        handlers = {
          function(server_name)
            local server = servers[server_name] or {}
            require('lspconfig')[server_name].setup(server)
          end,
        },
      }
    end,
  },
})

relevant settings: I need to have tokio installed for the bug to appear

repository link (if public, optional): ?

code snippet to reproduce:

#[tokio::main]
fn main() {
    match true {}
}

After executing the code action "Fill match arms" on match true:

#[tokio::main]
async fn main() {
    match true {
    true => todo!(),
    false => todo!(),
}} // <-- notice the extra `}`
}

If I remove #[tokio::main] I no longer have this issue.

Here's my Cargo.toml:

[package]
name = "rust-test"
version = "0.1.0"
edition = "2021"

[dependencies]
tokio = { version = "1.39.3", features = ["full"] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-assists C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants