Subject: Re: bug#78862: 31.0.50; Eglot couldn't refresh Flymake diagnostics on Rust project

From: Eason Huang <[email-masked]>
Date: Sun, 22 Jun 2025 19:27:56 +0800

Eli Zaretskii <[email-masked]> writes:

>> From: Eason Huang <[email-masked]>
>> Date: Sun, 22 Jun 2025 15:05:06 +0800
>> 
>> Hello Emacs dev,
>> 
>> Recently, I found that if flymake-mode enabled before eglot,eglot can not
>> refresh the Flymake diagnostics.
>> Disable flymake with `M-x flymake-mode`, and then enable eglot
>> with `M-x eglot` can fix the issue. Or with the below snippet can fix
>> it:
>> 
>> ```
>> (with-eval-after-load 'eglot
>>     (add-hook 'eglot-managed-mode-hook (lambda ()
>>                                          (flymake-mode -1)
>>                                          (flymake-mode 1))))
>> 
>> ```
>> 
>> Steps to reproduce:
>> 
>> 1. put below config into the init.el file
>> ```
>> (use-package flymake
>>   :hook (prog-mode . flymake-mode))
>> 
>> (use-package rust-mode
>>   :ensure t
>>   :defer t
>>   :custom (rust-mode-treesitter-derive (and (fboundp 'treesit-available-p)
>>                                             (treesit-available-p))))
>> ```
>> 2. Start Emacs 31
>> 3. Open any Rust project with a dependency
>> 4. Open any Rust file in a rust project(make sure it use a dependency),
>> such as main.rs, then flymake will report errors. Because I don't have
>> flymake rust backends,the errors is expected.
>>   
>> 5. Make sure `rust-analyzer` is in the PATH,My rust toolchain is as
>> below:
>> 
>> ```
>> rustc --version
>> rustc 1.87.0 (17067e9ac 2025-05-09)
>> 
>> rust-analyzer --version
>> rust-analyzer 1.87.0 (17067e9ac6d 2025-05-09)
>> ``
>> 6. Start eglot with `M-x eglot`, now the errors still exist. This is the
>> issue.
>> 
>> 7. `M-x flymake-mode` to disable flymake
>> 8. `M-x eglot-reconnect` will refresh the Flymake diagnostics,and no
>> errors reported if your Rust project is compiled.
>> 
>> 
>> The issue only happened on Emacs 31, it works as expected on Emacs 30.  
>
> Thanks, I hope João and Spencer will have comments or suggestions
> about this.
>

Hello Eli, João and Spencer,

I find out that it is related to `rust-ts-flymake-command`, when
customize it's value to `'("cargo" "clippy")`, it works as expected.

It works with below rust config:

```
(use-package rust-mode
  :defer t
  :custom
  (rust-mode-treesitter-derive (and (fboundp 'treesit-available-p)
                                    (treesit-available-p)))
  (rust-ts-flymake-command '("cargo" "clippy")))

```

May be this information help.

-- 
Eason Huang