{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/19700","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/19700/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/19700/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/19700/events","html_url":"https://github.com/rust-lang/rust/issues/19700","id":51579305,"number":19700,"title":"No macro hygiene for items","user":{"login":"maxsnew","id":1479741,"avatar_url":"https://avatars.githubusercontent.com/u/1479741?v=3","gravatar_id":"","url":"https://api.github.com/users/maxsnew","html_url":"https://github.com/maxsnew","followers_url":"https://api.github.com/users/maxsnew/followers","following_url":"https://api.github.com/users/maxsnew/following{/other_user}","gists_url":"https://api.github.com/users/maxsnew/gists{/gist_id}","starred_url":"https://api.github.com/users/maxsnew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxsnew/subscriptions","organizations_url":"https://api.github.com/users/maxsnew/orgs","repos_url":"https://api.github.com/users/maxsnew/repos","events_url":"https://api.github.com/users/maxsnew/events{/privacy}","received_events_url":"https://api.github.com/users/maxsnew/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-macros","name":"A-macros","color":"d7e102"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2014-12-10T16:32:30Z","updated_at":"2015-03-03T19:34:50Z","closed_at":"2015-03-03T16:52:51Z","body":"Uses of identifiers in a macro expansion refer to identifiers in the macro use-site and not the macro-definition site, effectively giving macros dynamic scope.\r\n\r\nMinimal example:\r\n```rust\r\n#![feature(macro_rules)]\r\n\r\nfn foo() -> bool {\r\n    true\r\n}\r\n\r\nmacro_rules! bar(\r\n    () => (foo())\r\n)\r\n    \r\n#[cfg(test)]\r\nmod test {\r\n    fn foo() -> bool {\r\n        false\r\n    }\r\n    #[test]\r\n    fn test() {\r\n        assert!(bar!());\r\n    }\r\n}\r\n```\r\nTesting this program will result in a test failure because when `bar!()` expands to `foo()` the `foo` is the `foo` in the test submodule, whereas it should refer to the `foo` in the top-level module where `bar!` was defined.\r\n\r\nThis paper is a good resource for implementing this: http://www.cs.utah.edu/plt/publications/macromod.pdf"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/77017347","html_url":"https://github.com/rust-lang/rust/issues/19700#issuecomment-77017347","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/19700","id":77017347,"user":{"login":"kmcallister","id":444997,"avatar_url":"https://avatars.githubusercontent.com/u/444997?v=3","gravatar_id":"","url":"https://api.github.com/users/kmcallister","html_url":"https://github.com/kmcallister","followers_url":"https://api.github.com/users/kmcallister/followers","following_url":"https://api.github.com/users/kmcallister/following{/other_user}","gists_url":"https://api.github.com/users/kmcallister/gists{/gist_id}","starred_url":"https://api.github.com/users/kmcallister/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kmcallister/subscriptions","organizations_url":"https://api.github.com/users/kmcallister/orgs","repos_url":"https://api.github.com/users/kmcallister/repos","events_url":"https://api.github.com/users/kmcallister/events{/privacy}","received_events_url":"https://api.github.com/users/kmcallister/received_events","type":"User","site_admin":false},"created_at":"2015-03-03T19:34:50Z","updated_at":"2015-03-03T19:34:50Z","body":"This aspect of `macro_rules!` can't be fixed in a backwards-compatible way, and it can't be fixed in time for Rust 1.0, when the [backwards-compatibility guarantees](http://blog.rust-lang.org/2014/10/30/Stability.html) kick in.\r\n\r\nWe will at some point introduce a new macro system, first in Rust nightlies, then in some stable Rust 1.x.  This would happen through the [RFC process](https://github.com/rust-lang/rfcs/).  It would coexist with the current `macro_rules!` until Rust 2.0.  The item hygiene issue will not be overlooked by the people designing the new macro system. It is probably the top consideration.\r\n\r\nUntil there's a full RFC, we can discuss this further on rust-lang/rfcs#440."}}