Hacker News new | ask | show | jobs
by czei002 1478 days ago
Totally agree, macros are the worst Rust feature for me, they are way too powerful and break the tooling, e.g. fmt or language server.

https://rust-analyzer.github.io/blog/2021/11/21/ides-and-mac...

1 comments

It ultimately depends on how they're written. println! is a macro, and doesn't "break the tooling". on the other end of the spectrum, using a crate like demonstrate (unit testing) produces hard to understand errors and slows down the IDE.

I don't remember experiencing Rust Analyzer crashes for a long time, though (I do remember some in the past).

> println! is a macro, and doesn't "break the tooling"

I like, use, and write macros, but this isn't fully true. For example, recent Rust versions allow writing identifiers directly in the format string:

    println!("{some_identifier}")
However, this breaks rust-analyzer's ability to rename variables [1].

[1]: https://github.com/rust-lang/rust-analyzer/issues/11260#

println! is only a declarative macro, whereas Maud is a proc macro.

The declarative macros aren't too head-twisting for tools, they just expand as declared, this can sometimes have a few surprising effects but generally it is very manageable. Procedural macros have essentially unlimited power and thus are sometimes entirely impossible to analyse.

I see a built-in there. Are you really seeing a proc macro?