{"action":"created","issue":{"url":"https://api.github.com/repos/dtolnay/syn/issues/357","repository_url":"https://api.github.com/repos/dtolnay/syn","labels_url":"https://api.github.com/repos/dtolnay/syn/issues/357/labels{/name}","comments_url":"https://api.github.com/repos/dtolnay/syn/issues/357/comments","events_url":"https://api.github.com/repos/dtolnay/syn/issues/357/events","html_url":"https://github.com/dtolnay/syn/issues/357","id":294211377,"node_id":"MDU6SXNzdWUyOTQyMTEzNzc=","number":357,"title":"syn cannot be used with cdylibs due to proc_macro dependency","user":{"login":"Rantanen","id":385385,"node_id":"MDQ6VXNlcjM4NTM4NQ==","avatar_url":"https://avatars0.githubusercontent.com/u/385385?v=4","gravatar_id":"","url":"https://api.github.com/users/Rantanen","html_url":"https://github.com/Rantanen","followers_url":"https://api.github.com/users/Rantanen/followers","following_url":"https://api.github.com/users/Rantanen/following{/other_user}","gists_url":"https://api.github.com/users/Rantanen/gists{/gist_id}","starred_url":"https://api.github.com/users/Rantanen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rantanen/subscriptions","organizations_url":"https://api.github.com/users/Rantanen/orgs","repos_url":"https://api.github.com/users/Rantanen/repos","events_url":"https://api.github.com/users/Rantanen/events{/privacy}","received_events_url":"https://api.github.com/users/Rantanen/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-02-04T16:50:19Z","updated_at":"2018-07-22T17:07:13Z","closed_at":"2018-07-22T17:07:13Z","author_association":"CONTRIBUTOR","body":"Running\r\n\r\n```\r\ncargo init\r\necho syn = \\\"0.12\\\" >> Cargo.toml\r\necho [lib] >> Cargo.toml\r\necho crate-type = [ \\\"cdylib\\\" ] >> Cargo.toml\r\necho extern crate syn\\; >> src/lib.rs\r\ncargo build\r\n```\r\n\r\nResults in\r\n\r\n```\r\n    Updating registry `https://github.com/rust-lang/crates.io-index`\r\n   Compiling unicode-xid v0.1.0\r\n   Compiling proc-macro2 v0.2.2\r\n   Compiling quote v0.4.2\r\n   Compiling syn v0.12.12\r\n   Compiling syn-cdylib v0.1.0 (file:///home/rantanen/test/syn-cdylib)\r\nerror: crate `proc_macro` required to be available in rlib format, but was not found in this form\r\n\r\nerror: crate `syntax` required to be available in rlib format, but was not found in this form\r\n\r\nerror: crate `rustc_cratesio_shim` required to be available in rlib format, but was not found in this form\r\n\r\nerror: crate `rustc_errors` required to be available in rlib format, but was not found in this form\r\n\r\nerror: crate `rustc_data_structures` required to be available in rlib format, but was not found in this form\r\n\r\nerror: crate `syntax_pos` required to be available in rlib format, but was not found in this form\r\n\r\nerror: aborting due to 6 previous errors\r\n\r\nerror: Could not compile `syn-cdylib`.\r\n```\r\n\r\nMaking `proc_macro` an optional default dependency for `syn` is easy. However `proc_macro2` depends on that as well, and I'm guessing in the (somewhat distant) future the use of `proc_macro2` will be replaced with `proc_macro` in syn so trying to get rid of `proc_macro2` and/or making `proc_macro` optional for `proc_macro2` wouldn't really work as a long term solution.\r\n\r\nIn my specific use case `syn` is an indirect dependency to the `cdylib` crate and I'm probably able to split the crate that depends on `syn` in two in such a way that the `cdylib` doesn't receive `syn` as a dependency.\r\n\r\nHowever this would still be an issue for any `cdylib` that needs to be able to parse Rust code for example, which might be a case for IDEs and such.\r\n\r\nWhat does `syn` need from `proc_macro2` for usage that depends on `parse_str` instead of parsing `TokenStream`s? It seemed like structs such as `Span` come directly from `proc_macro2`, but I'd imagine that if the number of dependent structs for the `syn` AST is small, these could be re-implemented in syn, with a `not(feature = \"proc_macro\")` guard or some such."},"comment":{"url":"https://api.github.com/repos/dtolnay/syn/issues/comments/406881968","html_url":"https://github.com/dtolnay/syn/issues/357#issuecomment-406881968","issue_url":"https://api.github.com/repos/dtolnay/syn/issues/357","id":406881968,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNjg4MTk2OA==","user":{"login":"dtolnay","id":1940490,"node_id":"MDQ6VXNlcjE5NDA0OTA=","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-07-22T17:07:13Z","updated_at":"2018-07-22T17:07:13Z","author_association":"OWNER","body":"This is actively being worked on in https://github.com/rust-lang/rust/issues/45601 and https://github.com/rust-lang/rust/pull/49219, and I don't think there is anything that can be done about it on our end, so I am closing the issue. Please follow up on one of those threads as necessary."}}
{"actor":{"display_login":"dtolnay"}}