{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/35900","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/35900/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/35900/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/35900/events","html_url":"https://github.com/rust-lang/rust/issues/35900","id":172498288,"number":35900,"title":"Tracking issue for \"Macros 1.1\" (RFC #1681)","user":{"login":"nikomatsakis","id":155238,"avatar_url":"https://avatars.githubusercontent.com/u/155238?v=3","gravatar_id":"","url":"https://api.github.com/users/nikomatsakis","html_url":"https://github.com/nikomatsakis","followers_url":"https://api.github.com/users/nikomatsakis/followers","following_url":"https://api.github.com/users/nikomatsakis/following{/other_user}","gists_url":"https://api.github.com/users/nikomatsakis/gists{/gist_id}","starred_url":"https://api.github.com/users/nikomatsakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikomatsakis/subscriptions","organizations_url":"https://api.github.com/users/nikomatsakis/orgs","repos_url":"https://api.github.com/users/nikomatsakis/repos","events_url":"https://api.github.com/users/nikomatsakis/events{/privacy}","received_events_url":"https://api.github.com/users/nikomatsakis/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/B-RFC-implemented","name":"B-RFC-implemented","color":"e102d8"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/B-unstable","name":"B-unstable","color":"e102d8"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/final-comment-period","name":"final-comment-period","color":"207de5"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/T-lang","name":"T-lang","color":"bfd4f2"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/T-tools","name":"T-tools","color":"bfd4f2"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":126,"created_at":"2016-08-22T16:37:11Z","updated_at":"2016-10-09T21:24:38Z","closed_at":null,"body":"Tracking issue for rust-lang/rfcs#1681.\r\n\r\ncc @alexcrichton \r\n\r\n## Stabilization TODO\r\n\r\nLitmus tests:\r\n\r\n* [x] - Does diesel work? https://github.com/rust-lang/rust/issues/35900#issuecomment-251242313\r\n* [x] - Does serde work? https://users.rust-lang.org/t/serde-transitioning-to-macros-1-1/7437\r\n\r\nFeatures:\r\n\r\n* Crate name, currently is `proc_macro`\r\n* Crate type, currently `proc-macro`\r\n* The `#[proc_macro_derive(Foo)]` attribute \r\n* Loading `proc-macro` crates with `-L` and `#[macro_use]` to load them\r\n* shadowing is an error\r\n* no hygiene\r\n* passing a token stream for the entire struct and receiving it all back\r\n* Cargo manifest attribute, currently `proc-macro = true`\r\n\r\nKnown bugs:\r\n\r\n* [ ] - order still matters - https://github.com/rust-lang/rust/issues/35900#issuecomment-252430957\r\n* [ ] - custom attributes for multiple modes is hard - https://github.com/rust-lang/rust/issues/35900#issuecomment-252499766\r\n* [ ] - Panicking derive may have the wrong span - #36935\r\n* [ ] - token streams with `mod foo` fail - #36691\r\n* [x] - Can't document rustc-macro crates - https://github.com/rust-lang/rust/issues/36820 (fixed in #36847)\r\n* [x] - Cargo rebuilds too often - https://github.com/rust-lang/rust/issues/36625 (fixed in https://github.com/rust-lang/rust/pull/36776)\r\n* [x] - Attributes generated by the compiler make custom derive authors' lives difficult - https://github.com/rust-lang/rust/issues/35900#issuecomment-245978831\r\n  * [x] - Change order of expansions to users-first - https://github.com/rust-lang/rust/issues/35900#issuecomment-246840357 (fixed in https://github.com/rust-lang/rust/pull/36782)\r\n\r\n## Implementation TODO\r\n\r\n* [x] - Create a `rustc_macro` crate\r\n  * [x] - Have `librustc_macro` link to `libsyntax`. Depend on `librustc_macro` in `librustc_driver`\r\n  * [x] - Tag `rustc_macro` as unstable with our [standard header](https://github.com/rust-lang/rust/blob/master/src/libsyntax/lib.rs#L17-L25).\r\n  * [x] - Only tag `rustc_macro` with `#![crate_type = \"rlib\"]`, do not produce a dylib.\r\n  * [x] - Implement [the API](https://github.com/rust-lang/rfcs/blob/master/text/1681-macros-1.1.md#librustc_macro) of `rustc_macro` using `libsyntax`'s `TokenStream` internally\r\n  * [x] - tag `rustc_macro` with a `TokenStream` lang item so the compiler knows about it.\r\n* [x] - Add `rustc_macro_derive` attribute\r\n  * [x] - validate it's of the exact form `foo(bar)`, no other arguments/formats\r\n  * [x] - verify it's only applied to functions\r\n  * [x] - verify it's only applied to functions in the root module\r\n  * [x]  - verify the signature with the `TokenStream` lang item added above\r\n  * [x] - encode all function symbols with `rustc_macro_derive` into metadata along with the derive mode they're used for.\r\n* [x] - Add a `rustc-macro` crate type for other crates\r\n  * [x] - wire it up to produce a dylib\r\n  * [x] - ensure the dylib gets metadata\r\n  * [x] - ensure `rustc-macro` crates **cannot be linked as dylibs**\r\n  * [x] - ensure there are no *reachable* items other than those tagged with `#[rustc_macro_derive]`\r\n  * [x] - Add `cfg(rustc_macro)` as an unstable `cfg` directive, set it for the `rustc-macro` crate type\r\n  * [x] - ensure that `rustc-macro` crates link dynamically to libsytnax\r\n* [x] - Fill in `#[macro_use]` support for `rustc-macro` crates\r\n  * [x] - extend library loader to find `rustc-macro` crates separately from dylib/rlib tracked today when loding crates\r\n  * [x] - Parse metadata for `rustc-macro` crates to learn about symbol/derive mode pairings\r\n  * [x] - `dlopen` the dylib\r\n  * [x] - generate an error if any derive mode would shadow any other.\r\n* [x] - Add cargo integeration\r\n  * [x] - recognize `rustc-macro` similar to `plugin = true`\r\n  * [x] - pass `--crate-type=rustc-macro` when depending on it\r\n  * [x] - plumb the same host/target logic for rustc-macro crates as is present for plugin crates (e.g. always compile rustc-macro crates for hosts)\r\n* [x] - Tests\r\n  * [x] - smoke test loading a rustc-macro, dummy `#[derive]` trait \r\n  * [x] - name conflicts are an error\r\n  * [x] - compiling for the wrong architecture is an error\r\n  * [x] - cannot emit crate type rustc-macro and anything else (e.g. rustc-macro+dylib) is an error\r\n  * [x] - span information not being horrendous\r\n  * [x] - removing attributes from a struct, as well as fields\r\n  * [x] - adding impls next to a struct\r\n  * [x] - cross compilation looks for the host rustc-macro crate type\r\n  * [x] - don't load vanilla dylibs as rustc-macro crate types\r\n  * [x] - can't have public exports beyond macro derive functions in a rustc-macro crate\r\n  * [x] - derive macros must have required signature\r\n  * [x] - load two macro crates in one compilation\r\n"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/252513634","html_url":"https://github.com/rust-lang/rust/issues/35900#issuecomment-252513634","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/35900","id":252513634,"user":{"login":"jseyfried","id":8652869,"avatar_url":"https://avatars.githubusercontent.com/u/8652869?v=3","gravatar_id":"","url":"https://api.github.com/users/jseyfried","html_url":"https://github.com/jseyfried","followers_url":"https://api.github.com/users/jseyfried/followers","following_url":"https://api.github.com/users/jseyfried/following{/other_user}","gists_url":"https://api.github.com/users/jseyfried/gists{/gist_id}","starred_url":"https://api.github.com/users/jseyfried/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jseyfried/subscriptions","organizations_url":"https://api.github.com/users/jseyfried/orgs","repos_url":"https://api.github.com/users/jseyfried/repos","events_url":"https://api.github.com/users/jseyfried/events{/privacy}","received_events_url":"https://api.github.com/users/jseyfried/received_events","type":"User","site_admin":false},"created_at":"2016-10-09T21:24:38Z","updated_at":"2016-10-09T21:24:38Z","body":"@alexcrichton \r\n> when one `#[derive]` attribute is being expanded it could try to slurp up all the future ones\r\n\r\nI like this idea. Since `#[cfg]`s and and `#[cfg_attr]`s are processed before `#[derive]`s, `#[cfg]`-guarded `#[derive]`s are not a problem for this approach (or for @sfackler's analogous solution to the attribute stripping issue).\r\n\r\nThis approach would make @sfackler's solution slightly simpler, since other relevant derives could only be in the last attribute (I also think @eddyb's [suggestion](https://github.com/rust-lang/rust/issues/35900#issuecomment-252499941) would simplify things)."}}
{"actor":{"display_login":"jseyfried"}}