Conversation

😱😱😱 Is this for real? And if so, who came up with the idea of allowing this type of host code to be run from macros?!?!?
Quote Tweet
Did you know you can just fork() the @rustlang compiler from your proc_macro? :D This is, of course, a horrible idea.
Show this thread
fn main() {
    whichever_compiles! {
        try { thisfunctiondoesntexist(); }
        try { 1 2 3 invalid syntax }
        try { println!("missing arg: {}"); }
        try { println!("hello {}", world()); }
        try { 1 + 2 }
    }
}

whichever_compiles! {
    try { }
    try { fn world() {} }
    try { fn world() -> &'static str { "world" } }
}
$ cargo run
   Compiling ohno v0.1.0
    Finished dev [unoptimized + debuginfo] target(s) in 0.73s
     Running `target/debug/ohno`
hello world
2
8
Like, I've seen a lot of bad things about Rust, but this one, if I understand it, is the first that's so absolutely awful it simply must be changed, fuck backwards compatibility, for the language not to be utterly unacceptably broken.
7
4