Lukas Wirth's Avatar

Lukas Wirth

@lukaswirth.dev

Rust Engineer at @zed.dev rust-analyzer team lead Sponsor my rust-analyzer work here https://github.com/sponsors/Veykril

564
Followers
294
Following
135
Posts
21.11.2023
Joined
Posts Following

Latest posts by Lukas Wirth @lukaswirth.dev

But even without macros I don't think I would change my mind on this, it is just weird having a float token from the lexer stage that can be part of a field access chain depending on the preceding context and the actual text of the token itself, it unnecessarily complicates the parser imo.

09.03.2026 09:09 ๐Ÿ‘ 6 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0

So one solution would've been to completely revamp how we deal with the lexer output (both rustc and r-a use the same lexer), parser and macro TokenTree handling which for obvious reasons no one would ever want to bother with as that is way too much work.

09.03.2026 09:07 ๐Ÿ‘ 5 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0

I think kind of both? Rust's macro system forces you to think about two different sources of tokens, and rust-analyzer's current parser system makes specific requirements to the input. We differ a fair bit from rustc in how we model the parser input though I don't recall as to why.

09.03.2026 09:07 ๐Ÿ‘ 4 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0

It was a pain to make it work with macros in rust-analyzer, so much so that it took us years to fix. So this choice basically enforces specific requirements for your parser (which r-a's did not really support).

09.03.2026 07:23 ๐Ÿ‘ 1 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0

Starting the morning by having to review a pull request that merely changes a complex regex. Thus my morning is already in shambles as I am tasked to review a change in an unreadable language.

09.03.2026 07:22 ๐Ÿ‘ 18 ๐Ÿ” 0 ๐Ÿ’ฌ 2 ๐Ÿ“Œ 0

Removing field syntax for tuples/tuple struct, that is no `foo.0` etc. It makes parsing so incredibly annoying in Rust as you might have to split float tokens from the lexer depending on what was preceding it

08.03.2026 17:51 ๐Ÿ‘ 4 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0
Post image

** Speaker announcement ** Catch Vlad Beskrovny & Lukas Wirth's talk 'One Language, Two IDE Engines' at RustWeek 2026!
Info & tickets: 2026.rustweek.org/talks/ides/

See you in Utrecht May 18-23, 2026!

@lukaswirth.dev

#rustweek2026 #rustlang

27.02.2026 10:46 ๐Ÿ‘ 16 ๐Ÿ” 3 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0

oh sweet, I was wondering whether that was a thing already or not

19.02.2026 07:29 ๐Ÿ‘ 1 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0

Usually you want a reference to the `dyn Any` inside the box, `&Box<dyn Any>` will unfortunately be a reference to the box itself, just that the box is now unsized to `dyn Any`.

18.02.2026 15:06 ๐Ÿ‘ 9 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0
Preview
Talk schedule - RustWeek 2026 RustWeek 2026, The Netherlands - May 18 - 23 2026. The world's biggest Rust conference returns to beautiful Utrecht, welcoming over 900+ community members, professionals and the maintainers of Rust.

The RustWeek 2026 schedule, including the talk details for RustWeek 2026, is now published!

2026.rustweek.org/schedule/tue...
2026.rustweek.org/schedule/wed...

Don't forget to buy your ticket!

#rustweek2026 #rust

18.02.2026 14:00 ๐Ÿ‘ 4 ๐Ÿ” 2 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0

The fact that `&Box<dyn Any>` is coercible to `&dyn Any` is such a big footgun ...

18.02.2026 13:35 ๐Ÿ‘ 16 ๐Ÿ” 0 ๐Ÿ’ฌ 3 ๐Ÿ“Œ 0

This might get me to watch eurovision again, love that guy and some of his songs

17.02.2026 11:12 ๐Ÿ‘ 3 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
Preview
RustWeek Speakers Announced! - RustWeek 2026 RustWeek 2026, The Netherlands - May 18 - 23 2026. The world's biggest Rust conference returns to beautiful Utrecht, welcoming over 900+ community members, professionals and the maintainers of Rust.

** RustWeek Speakers Announced! **
Check out the selected speakers and talks here:
2026.rustweek.org/blog/2026-02...

Thanks to everyone who submitted to our CFP!

#rust #rustweek2026

16.02.2026 16:39 ๐Ÿ‘ 16 ๐Ÿ” 6 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 7
Post image

"Vestige"
It's been a while since I last dedicated an illustration to this duo and I wanted to practice drawing desert scenes again, so here's the result c:

11.02.2026 18:01 ๐Ÿ‘ 374 ๐Ÿ” 95 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0

hey uhhh. I got fired yesterday. if anyone has rust positions in the Netherlands let me know!

11.02.2026 10:24 ๐Ÿ‘ 67 ๐Ÿ” 40 ๐Ÿ’ฌ 6 ๐Ÿ“Œ 2
Preview
Reduce intensity of refreshing pull diagnostics by ConradIrwin ยท Pull Request #47510 ยท zed-industries/zed Before this change we&#39;d spawn N tasks in parallel on every keystroke, afterwards we only allow 1 background diagnostic refresh in flight at a time. This also fixed a bug where we&#39;d send O(n...

People are on it, we presume we are overloading rust-analyzer with diagnostic requests, filling the threadpool queue with lots of blocking work github.com/zed-industri...

23.01.2026 20:38 ๐Ÿ‘ 7 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0

This can vastly speed up initial project indexing depending on your project as the proc-macro server process can only expand a single macro at a given time (due to macros observing the process environment). Once rust-analyzer becomes a bit more parallel it will also speed up things in general.

23.01.2026 13:03 ๐Ÿ‘ 7 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0
internal: Parallelize proc macro expansion by Shourya742 ยท Pull Request #21385 ยท rust-lang/rust-analyzer This PR replaces the single proc-macro server per workspace with a small pool of server processes.

If you are on the preview rust-analyzer releases you can now enable using multiple proc-macro servers (or on stable next monday) by setting the `procMacro.processes` config to a higher number than one 1.

github.com/rust-lang/ru...

23.01.2026 13:03 ๐Ÿ‘ 23 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0
Post image

Oh so that's what you changed on my PR, this diff had me so confused lol

16.01.2026 14:30 ๐Ÿ‘ 0 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0

Gotta put rust-analyzer on this list as well

08.01.2026 20:30 ๐Ÿ‘ 9 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0

my "this isn't meant to be used for harassment" sign i put on my list of enemies is raising a lot of questions answered by the sign

08.01.2026 19:28 ๐Ÿ‘ 91 ๐Ÿ” 8 ๐Ÿ’ฌ 4 ๐Ÿ“Œ 0

Or well, I suppose turning the reference impl back into something template-ish for codegen is just far more annoying.

05.01.2026 08:20 ๐Ÿ‘ 1 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0

Curious why you used an LLM to duplicate this instead of having a codegen script with the codegen checked out in-tree over a macro then. The codegen approach would allow you to predictably make the same change across all places easily later. I guess because to be able to dupe the documentation?

05.01.2026 08:17 ๐Ÿ‘ 1 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0
error[E0277]: the trait bound `NoopEviction: HasCapacity` is not satisfied
    --> tests\cycle.rs:1306:5
     |
1306 |     #[salsa::tracked]
     |     ^^^^^^^^^^^^^^^^^ the trait `HasCapacity` is not implemented for `NoopEviction`
     |
help: the trait `HasCapacity` is implemented for `Lru`
    --> C:\Workspace\salsa\src\function\eviction\lru.rs:75:1
     |
  75 | impl HasCapacity for Lru {}
     | ^^^^^^^^^^^^^^^^^^^^^^^^
     = help: see issue #48214
     = note: this error originates in the macro `salsa::plumbing::setup_tracked_fn` which comes from the expansion of the attribute macro `salsa::tracked` (in Nightly builds, run with -Z macro-backtrace for more info)
help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
     |
   7 + #![feature(trivial_bounds)]
     |

error[E0277]: the trait bound `NoopEviction: HasCapacity` is not satisfied --> tests\cycle.rs:1306:5 | 1306 | #[salsa::tracked] | ^^^^^^^^^^^^^^^^^ the trait `HasCapacity` is not implemented for `NoopEviction` | help: the trait `HasCapacity` is implemented for `Lru` --> C:\Workspace\salsa\src\function\eviction\lru.rs:75:1 | 75 | impl HasCapacity for Lru {} | ^^^^^^^^^^^^^^^^^^^^^^^^ = help: see issue #48214 = note: this error originates in the macro `salsa::plumbing::setup_tracked_fn` which comes from the expansion of the attribute macro `salsa::tracked` (in Nightly builds, run with -Z macro-backtrace for more info) help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | 7 + #![feature(trivial_bounds)] |

                fn set_lru_capacity(db: &mut dyn $Db, value: usize)
                where
                    for<'trivial_bounds> $Eviction: $zalsa::function::HasCapacity
                {
                    $Configuration::fn_ingredient_mut(db).set_capacity(value);
                }

fn set_lru_capacity(db: &mut dyn $Db, value: usize) where for<'trivial_bounds> $Eviction: $zalsa::function::HasCapacity { $Configuration::fn_ingredient_mut(db).set_capacity(value); }

`#![feature(trivial_bounds)]` or as I like to call it on stable: `for<'trivial_bounds> Type: Bound`

31.12.2025 13:58 ๐Ÿ‘ 9 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0

we'd still only be able to execute proc-macros in parallel if they are run within the same environment (working dir, env vars) which only happens within the same crate really. So the alternative we are likely looking at is to just spawn multiple servers and handle them like a process pool.

23.12.2025 08:46 ๐Ÿ‘ 5 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0

The annoying part, you can't trivially parallelize this on the proc-macro server because proc-macros execute in (and are in control ๐Ÿ˜ตโ€๐Ÿ’ซ of) the process environment, so technically running multiple at once can cause issues. But even ignoring that they can change the environment,

23.12.2025 08:46 ๐Ÿ‘ 5 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0

And some additional notes for parallel proc-macro expansion, today r-a spawns a single proc-macro server that does expansion one at a time, meaning whenever r-a wants to expand a proc-macro, it takes a global lock on the proc-macro server!

23.12.2025 08:46 ๐Ÿ‘ 6 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0
TokenStream in proc_macro - Rust The main type provided by this crate, representing an abstract stream of tokens, or, more specifically, a sequence of token trees. The type provides interfaces for iterating over those token trees and...

For context as to why we still cannot implement `expand_expr`, that feature effectively turns all proc-macro into eager macro expansions which would basically prevent rust-analyzer from doing a lot of incremental caching, so we just cannot implement this as designed doc.rust-lang.org/stable/proc_...

23.12.2025 08:46 ๐Ÿ‘ 5 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0

super excited to see the proc-macro server RPC rewrite being worked on, once this here is finished it should allow us to implement all the remaining proc-macro features (except for `expand_expr`)! And afterwards we'll be tackling parallelization!

github.com/rust-lang/ru...

23.12.2025 08:46 ๐Ÿ‘ 22 ๐Ÿ” 2 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0

Oh yea, also performance of the standard view being really terrible is not great which I guess is part of the reason why this single file mode exists, but imo thats not a solution to that problem.

18.12.2025 13:08 ๐Ÿ‘ 1 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0