{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/25875","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/25875/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/25875/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/25875/events","html_url":"https://github.com/rust-lang/rust/issues/25875","id":82226325,"number":25875,"title":"Using macro with literal patterns in other macro fails","user":{"login":"waucka","id":2433972,"avatar_url":"https://avatars.githubusercontent.com/u/2433972?v=3","gravatar_id":"","url":"https://api.github.com/users/waucka","html_url":"https://github.com/waucka","followers_url":"https://api.github.com/users/waucka/followers","following_url":"https://api.github.com/users/waucka/following{/other_user}","gists_url":"https://api.github.com/users/waucka/gists{/gist_id}","starred_url":"https://api.github.com/users/waucka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/waucka/subscriptions","organizations_url":"https://api.github.com/users/waucka/orgs","repos_url":"https://api.github.com/users/waucka/repos","events_url":"https://api.github.com/users/waucka/events{/privacy}","received_events_url":"https://api.github.com/users/waucka/received_events","type":"User","site_admin":false},"labels":[{"id":132910982,"url":"https://api.github.com/repos/rust-lang/rust/labels/A-macros","name":"A-macros","color":"d7e102","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2015-05-29T02:49:45Z","updated_at":"2016-11-29T21:04:52Z","closed_at":null,"body":"## Code\n\n``` rust\nfn foo1(x: &str) {\n        println!(\"foo1({})\", x);\n}\n\nfn foo2(x: &str) {\n        println!(\"foo2({})\", x);\n}\n\nmacro_rules! wtf {\n        (1) => (foo1);\n        (2) => (foo2);\n}\n\nmacro_rules! wtf_foo {\n        ($x:expr, $num:expr) => {\n                wtf!($num)($x);\n        }\n}\n\nfn main() {\n        //Fails\n        wtf_foo!(\"one\", 1);\n        //Works\n        wtf!(1)(\"one\");\n}\n```\n## Output\n\n```\n$ rustc foo.rs \nfoo.rs:16:8: 17:12 error: no rules expected the token `1`\nfoo.rs:16               wtf!($num)($x);\n                             ^~~~\n```\n## Expected Output\n\n```\n$ rustc foo.rs \nfoo.rs:5:1: 7:2 warning: function is never used: `foo2`, #[warn(dead_code)] on by default\nfoo.rs:5 fn foo2(x: &str) {\nfoo.rs:6        println!(\"foo2({})\", x);\nfoo.rs:7 }\n$ ./foo\nfoo1(one)\nfoo1(one)\n```\n## Other\n\nThis works fine, so the problem appears to be limited to literal patterns (not sure if that's the right term):\n\n``` rust\nmacro_rules! print_stuff_for_real {\n        ($x:expr) => (println!(\"Printing stuff: {}\", $x));\n}\n\nmacro_rules! print_stuff {\n        ($x:expr) => (print_stuff_for_real!($x));\n}\n\nfn main() {\n        print_stuff!(\"stuff\");\n}\n\n```\n## Meta\n\nI used two versions of rustc; they behaved identically.\n\n```\nrustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)\nbinary: rustc\ncommit-hash: a59de37e99060162a2674e3ff45409ac73595c0e\ncommit-date: 2015-05-13\nbuild-date: 2015-05-14\nhost: x86_64-unknown-linux-gnu\nrelease: 1.0.0\n```\n\n```\nrustc 1.2.0-nightly (f76d9bcfc 2015-05-28) (built 2015-05-28)\nbinary: rustc\ncommit-hash: f76d9bcfc2c269452522fbbe19f66fe653325646\ncommit-date: 2015-05-28\nbuild-date: 2015-05-28\nhost: x86_64-unknown-linux-gnu\nrelease: 1.2.0-nightly\n```\n"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/263698370","html_url":"https://github.com/rust-lang/rust/issues/25875#issuecomment-263698370","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/25875","id":263698370,"user":{"login":"steveklabnik","id":27786,"avatar_url":"https://avatars.githubusercontent.com/u/27786?v=3","gravatar_id":"","url":"https://api.github.com/users/steveklabnik","html_url":"https://github.com/steveklabnik","followers_url":"https://api.github.com/users/steveklabnik/followers","following_url":"https://api.github.com/users/steveklabnik/following{/other_user}","gists_url":"https://api.github.com/users/steveklabnik/gists{/gist_id}","starred_url":"https://api.github.com/users/steveklabnik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steveklabnik/subscriptions","organizations_url":"https://api.github.com/users/steveklabnik/orgs","repos_url":"https://api.github.com/users/steveklabnik/repos","events_url":"https://api.github.com/users/steveklabnik/events{/privacy}","received_events_url":"https://api.github.com/users/steveklabnik/received_events","type":"User","site_admin":false},"created_at":"2016-11-29T21:04:52Z","updated_at":"2016-11-29T21:04:52Z","body":"Triage: yes, it seems like we need a new feature for macros for this, though I'm not good at macros, so I very much could be wrong."}}
{"actor":{"display_login":"steveklabnik"}}