Skip to content

Nightly Toolchain + (Stable) Rust-Analyzer breaks regex patterns in logos crate #19965

@nikolas-sturm

Description

@nikolas-sturm

rust-analyzer version: rust-analyzer version: 0.3.2482-standalone (2a388d1 2025-05-31) [c:\Users\storm.cursor\extensions\rust-lang.rust-analyzer-0.3.2482-win32-x64\server\rust-analyzer.exe]

rustc version: rustc 1.87.0 (17067e9ac 2025-05-09) [stable] / rustc 1.89.0-nightly (6f69710 2025-05-28) [nightly]

editor or extension: Cursor (VSCode), ext: 0.3.2482

min repro: https://github.com/nikolas-sturm/rust-analyzer-issue

code snippet to reproduce:

use logos::Logos;

#[derive(Logos)]
pub enum Token {
    #[regex("[a-z]")]
    Test
}

relevant settings: toolchain either nightly-x86_64-pc-windows-msvc or stable-x86_64-pc-windows-msvc

Issue

Ok this one is kinda weird. I found that when i set the nightly toolchain as my default, then rust-analyzer in vscode finds errors that don't exist for the logos crate. This is very unexpected because when manually running check or clippy with the nightly toolchain no errors are found.
This error disappears when switching to stable toolchain and restarting rust analyzer. I am unsure if this is a problem on the rust toolchain side, rust analyzer side or logos side, but i have been using the nightly toolchain with rust-analyzer for months without error in other projects.
Another weird thing is that upon restarting rust-analyzer the error does not appear on the first check. It only appears once you modify the file in any way.
To reproduce:

  1. clone min repro repo
  2. simply switch to the nightly chain: rustup default nightly-x86_64-pc-windows-msvc (have only tested with msvc, not sure if this is also a problem on windows-gnu or linux-*)
  3. open repo in vscode with rust analyzer running.
  4. modify any content in the lib.rs file (add a space anywhere for example)
  5. error will appear inline but running cargo clippy at this point will compile perfectly fine without error.

Another weird thing to note may be that removing the - hyphen char from the regex pattern sometimes makes the error disappear. Other times the brackets also have to be deleted. The error is just extremely inconsistent. If this error cannot be reproduced and is just some weird config anomaly on my system, feel free to just close this issue.

Connected issue: maciejhirsz/logos#487

Metadata

Metadata

Labels

C-bugCategory: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions