3 ms·
> [ https://github.com/m-ou-se/nightly-crimes https://github.com/m-ou-se/nightly-crimes nightly-crimes! blows away your compiler, running it again in a new envi
by akiselev 5y ago
> [ https://github.com/m-ou-se/nightly-crimes https://github.com/m-ou-se/nightly-crimes nightly-crimes! blows away your compiler, running it again in a new environment where it will allow nightly features even though you've got a stable compiler installed... ]
That macros have access to the entire language including arbitrary IO is the defining feature of proc macros (not without controversy). The insanity here is the Rust compiler team adding the `RUSTC_BOOTSTRAP` env var which is a hack used to bootstrap rustc using a stable compiler despite the nightly features used by the codebase.
All nightly-crimes does is use `std::process::Command` to rerun the compiler with the variable set [1], which tells rustc to throw all concepts of stability out the window.
I haven't been following developments but one of the ideas (even has a PoC iirc) was to distribute and run proc macros as web assembly to improve build times and prevent such shenanigans.
[1] https://github.com/m-ou-se/nightly-crimes/blob/main/yolo-rustc-bootstrap/src/lib.rs#L34 https://github.com/m-ou-se/nightly-crimes/blob/main/yolo-rus...
- tialaramex 5y agoI don't see RUSTC_BOOTSTRAP as "insanity". Mara could do whatever here. Even if Rust's stable compilers had an internal parameter totally disabling nightly features, Mara's macro could take your compiler apart, identify the parameter, flip it, and re-assemble the compiler then run that. Indeed even if nightly was abolished, and new versions of the compiler simply didn't have these features, Mara's macro could go to github, download the old compiler that did have these features, install and run that. night_crimes! must be possible unless/ until sandboxing is implementing for proc macros and so the insanity is the same regardless of how it's possible. Which is fine, but like I said, these are big guns, not good to use just because they're tidier than a couple of declarative macros to get your job done.