Hacker News new | ask | show | jobs
by kibwen 4033 days ago
I'm actually working right now on a `cargo check` command which only runs those phases of the compiler to do with typechecking, to accommodate workflows based around tweaking types and then running the compiler to check your work. Given that the vast majority of compilation time is currently based in code generation and linking, this should drastically improve usability for this sort of rapid-iteration, dynamic-language-style workflow. (Though also note that improving the speed of codegen and linking is an ongoing task as well.)
1 comments

This is a great idea. I wish other compilers would offer this feature (scalac is in dire need of such an option).

Does the Rust macro system require compile-time compilation before type-checking?

Not really. Macro expansion occurs during its own phase of compilation (which, in my experience, is generally really fast).
Macro expansion can lead to programs that don't typecheck, unless a very restrictive typing system is used (e.g. MetaML, MetaOcaml). I don't think Rust has such restrictions, therefore I assume that type-checking happens after macro expansion.
It does, but what I was getting at was that full compilation doesn't need to occur first. Macro expansion is one of the very first phases of compilation (and doesn't have access to typechecking information, incidentally).
So Rust macros don't offer full compile-time meta-programming?
Not in Rust 1.0. In the nightlies there are syntax extensions available that give you more power, but those are likely to see significant revisions before they're available in a stable version since they're a major backwards compatibility hazard.