{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/47950","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/47950/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/47950/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/47950/events","html_url":"https://github.com/rust-lang/rust/issues/47950","id":293710320,"number":47950,"title":"proc-macro panics when tokenizing `..=` in attributes","user":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars1.githubusercontent.com/u/64996?v=4","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"labels":[{"id":632573348,"url":"https://api.github.com/repos/rust-lang/rust/labels/A-macros-2.0","name":"A-macros-2.0","color":"d7e102","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-01T22:42:03Z","updated_at":"2018-02-02T06:13:01Z","closed_at":null,"author_association":"OWNER","body":"Given `lib.rs`:\r\n\r\n```rust\r\n#![crate_name = \"foo\"]\r\n#![crate_type = \"proc-macro\"]\r\n#![feature(proc_macro)]\r\n\r\nextern crate proc_macro;\r\n\r\nuse proc_macro::*;\r\n\r\n#[proc_macro_attribute]\r\npub fn foo(_a: TokenStream, b: TokenStream) -> TokenStream {\r\n    recreate(b)\r\n}\r\n\r\nfn recreate(a: TokenStream) -> TokenStream {\r\n    a.into_iter().map(|t| {\r\n        match t.kind {\r\n            TokenNode::Group(d, c) => TokenNode::Group(d, recreate(c)),\r\n            other => other,\r\n        }\r\n    }).collect()\r\n}\r\n```\r\n\r\nand `main.rs`\r\n\r\n```rust\r\n#![feature(proc_macro)]\r\n\r\nextern crate foo;\r\n\r\nuse foo::foo;\r\n\r\n#[foo]\r\nfn main() {\r\n    let a = 1..=3;\r\n}\r\n```\r\n\r\nyou can compile as:\r\n\r\n```\r\n$ rustc +nightly lib.rs\r\n$ rustc +nightly main.rs -L .\r\nthread 'rustc' panicked at 'internal error: entered unreachable code', libproc_macro/lib.rs:688:22\r\nnote: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.\r\nstack backtrace:\r\n   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace\r\n             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49\r\n   1: std::sys_common::backtrace::print\r\n             at libstd/sys_common/backtrace.rs:71\r\n             at libstd/sys_common/backtrace.rs:59\r\n   2: std::panicking::default_hook::{{closure}}\r\n             at libstd/panicking.rs:380\r\n   3: std::panicking::default_hook\r\n             at libstd/panicking.rs:396\r\n   4: std::panicking::rust_panic_with_hook\r\n             at libstd/panicking.rs:576\r\n   5: std::panicking::begin_panic\r\n   6: <proc_macro::TokenTreeIter as core::iter::iterator::Iterator>::next\r\n   7: <core::iter::Map<I, F> as core::iter::iterator::Iterator>::next\r\n   8: <proc_macro::TokenStream as core::iter::traits::FromIterator<T>>::from_iter\r\n   9: core::iter::iterator::Iterator::collect\r\n  10: foo::recreate\r\n  11: foo::recreate::{{closure}}\r\n  12: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &'a mut F>::call_once\r\n  13: <core::option::Option<T>>::map\r\n  14: <core::iter::Map<I, F> as core::iter::iterator::Iterator>::next\r\n  15: <proc_macro::TokenStream as core::iter::traits::FromIterator<T>>::from_iter\r\n  16: core::iter::iterator::Iterator::collect\r\n  17: foo::recreate\r\n  18: foo::foo\r\n  19: std::panicking::try::do_call\r\n  20: __rust_maybe_catch_panic\r\n             at libpanic_unwind/lib.rs:102\r\n  21: <std::thread::local::LocalKey<T>>::with\r\n  22: <syntax_ext::proc_macro_impl::AttrProcMacro as syntax::ext::base::AttrProcMacro>::expand\r\n  23: syntax::ext::expand::MacroExpander::expand_invoc\r\n  24: syntax::ext::expand::MacroExpander::expand\r\n  25: syntax::ext::expand::MacroExpander::expand_crate\r\n  26: rustc_driver::driver::phase_2_configure_and_expand_inner::{{closure}}\r\n  27: rustc::util::common::time\r\n  28: rustc_driver::driver::phase_2_configure_and_expand\r\n  29: rustc_driver::driver::compile_input\r\n  30: rustc_driver::run_compiler\r\nerror: custom attribute panicked\r\n --> src/main.rs:7:1\r\n  |\r\n7 | #[foo]\r\n  | ^^^^^^\r\n  |\r\n  = help: message: internal error: entered unreachable code\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/362496427","html_url":"https://github.com/rust-lang/rust/issues/47950#issuecomment-362496427","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/47950","id":362496427,"user":{"login":"dtolnay","id":1940490,"avatar_url":"https://avatars2.githubusercontent.com/u/1940490?v=4","gravatar_id":"","url":"https://api.github.com/users/dtolnay","html_url":"https://github.com/dtolnay","followers_url":"https://api.github.com/users/dtolnay/followers","following_url":"https://api.github.com/users/dtolnay/following{/other_user}","gists_url":"https://api.github.com/users/dtolnay/gists{/gist_id}","starred_url":"https://api.github.com/users/dtolnay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dtolnay/subscriptions","organizations_url":"https://api.github.com/users/dtolnay/orgs","repos_url":"https://api.github.com/users/dtolnay/repos","events_url":"https://api.github.com/users/dtolnay/events{/privacy}","received_events_url":"https://api.github.com/users/dtolnay/received_events","type":"User","site_admin":false},"created_at":"2018-02-02T06:13:01Z","updated_at":"2018-02-02T06:13:01Z","author_association":"MEMBER","body":"Strange! https://github.com/rust-lang/rust/blob/6741e416feb54b18de41c348ecc70ba5cbc961ce/src/libproc_macro/lib.rs#L688"}}
{"actor":{"display_login":"dtolnay"}}