4 ms·
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.gi
by czei002 4y 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-macros.html https://rust-analyzer.github.io/blog/2021/11/21/ides-and-mac...
- pizza234 4y agoIt 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).
- tialaramex 4y agoprintln! 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.
- pornel 4y agoprintln! depends on a proc macro: https://doc.rust-lang.org/stable/src/core/macros/mod.rs.html#902-907 https://doc.rust-lang.org/stable/src/core/macros/mod.rs.html...
- tialaramex 4y agoI see a built-in there. Are you really seeing a proc macro?
- shepmaster 4y ago> 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# https://github.com/rust-lang/rust-analyzer/issues/11260#