Skip to content
This repository was archived by the owner on Dec 27, 2022. It is now read-only.

Rust interpreter hanging with println!(add_one!(two)) #35

Closed
brainstorm opened this issue Jul 3, 2019 · 2 comments
Closed

Rust interpreter hanging with println!(add_one!(two)) #35

brainstorm opened this issue Jul 3, 2019 · 2 comments

Comments

@brainstorm
Copy link

Hello @dtolnay,

There's an ongoing Rust interpreter issue related with your package on rust-lang/rust#62167, the following changeset reproduces the issue (the second format-less println! hangs the building process forever):

$ git diff
diff --git a/example/src/main.rs b/example/src/main.rs
index 127a36c..d72f1c2 100644
--- a/example/src/main.rs
+++ b/example/src/main.rs
@@ -1,7 +1,7 @@
 use demo_hack::add_one;

 fn main() {
-    let two = 2;
-    let nine = add_one!(two) + add_one!(2 + 3);
-    println!("nine = {}", nine);
+    let one = 1;
+    println!("{}", add_one(one));
+    println!(add_one!(one));
 }

Then building triggers Rust's interpreter hanging forever with the example code above:

(base) brainstorm:proc-macro-hack romanvg$ cargo build
    Finished dev [unoptimized + debuginfo] target(s) in 0.09s
(base) brainstorm:proc-macro-hack romanvg$ cd example/
(base) brainstorm:example romanvg$ cargo build
   Compiling example v0.0.0 (/Users/romanvg/tmp/proc-macro-hack/example)
    Building [===================================================>     ] 11/12: example(bin)

Can you give some feedback to the aforementioned rustlang issue? Thanks in advance!

/cc dotenv-rs/dotenv#22

@brainstorm
Copy link
Author

brainstorm commented Jul 3, 2019

I guess that the "nested macros" remark in proc-macro-hack limitations in the README.md relates directly to the core of the issue? The minimal code to trigger this is just a nested macro inside println!:

use demo_hack::add_one;

fn main() {
    println!(add_one!(1))
}

I would really like to know what's going on here :)

@dtolnay
Copy link
Owner

dtolnay commented Jul 3, 2019

I've already reported this as a compiler bug in rust-lang/rust#44692. This is not related to the documented limitation which is about calling one proc-macro-hack macro inside another (println is not a proc-macro-hack macro).

@dtolnay dtolnay closed this as completed Jul 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants