{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/48944","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/48944/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/48944/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/48944/events","html_url":"https://github.com/rust-lang/rust/issues/48944","id":304211655,"number":48944,"title":"`Span` issues with `FromStr` in unstable `proc_macro`","user":{"login":"mystor","id":1261662,"avatar_url":"https://avatars1.githubusercontent.com/u/1261662?v=4","gravatar_id":"","url":"https://api.github.com/users/mystor","html_url":"https://github.com/mystor","followers_url":"https://api.github.com/users/mystor/followers","following_url":"https://api.github.com/users/mystor/following{/other_user}","gists_url":"https://api.github.com/users/mystor/gists{/gist_id}","starred_url":"https://api.github.com/users/mystor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mystor/subscriptions","organizations_url":"https://api.github.com/users/mystor/orgs","repos_url":"https://api.github.com/users/mystor/repos","events_url":"https://api.github.com/users/mystor/events{/privacy}","received_events_url":"https://api.github.com/users/mystor/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-12T00:50:56Z","updated_at":"2018-03-12T00:52:50Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"While writing improved tests for `proc_macro2`, I noticed some surprising behaviour of the `FromStr` impl for `proc_macro::TokenStream`.\r\n\r\nWhen parsing a string with `FromStr`, a token parsed from the very beginning of the string can have a different `source_file()` than a token parsed elsewhere. For example:\r\n\r\n```rust\r\nlet tokens = \"aaa\\nbbb\".parse::<proc_macro::TokenStream>().unwrap().into_iter().collect::<Vec<_>>();\r\nprintln!(\"span: {:?}\", tokens[0].span);\r\nprintln!(\"source_file: {:?}\", tokens[0].span.source_file());\r\nprintln!(\"\");\r\nprintln!(\"span: {:?}\", tokens[1].span);\r\nprintln!(\"source_file: {:?}\", tokens[1].span.source_file());\r\n```\r\n\r\nWill produce the output:\r\n```\r\nspan: Span(Span { lo: BytePos(6734829), hi: BytePos(6734832), ctxt: #0 })\r\nsource_file: SourceFile { path: ProcMacroSourceCode, is_real: false }\r\n\r\nspan: Span(Span { lo: BytePos(50), hi: BytePos(58), ctxt: #25 })\r\nsource_file: SourceFile { path: Real(\"pm_test.rs\"), is_real: true }\r\n```\r\n\r\nI would've expected both tokens to have the same context, and similar BytePos-es. Specifically I would have expected both of these tokens to have a span located in a fake ProcMacroSourceCode file, but set to resolve in the context of the enclosing scope (as if span.resolved_at(Span::call_site()) was called)."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/372165522","html_url":"https://github.com/rust-lang/rust/issues/48944#issuecomment-372165522","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/48944","id":372165522,"user":{"login":"mystor","id":1261662,"avatar_url":"https://avatars1.githubusercontent.com/u/1261662?v=4","gravatar_id":"","url":"https://api.github.com/users/mystor","html_url":"https://github.com/mystor","followers_url":"https://api.github.com/users/mystor/followers","following_url":"https://api.github.com/users/mystor/following{/other_user}","gists_url":"https://api.github.com/users/mystor/gists{/gist_id}","starred_url":"https://api.github.com/users/mystor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mystor/subscriptions","organizations_url":"https://api.github.com/users/mystor/orgs","repos_url":"https://api.github.com/users/mystor/repos","events_url":"https://api.github.com/users/mystor/events{/privacy}","received_events_url":"https://api.github.com/users/mystor/received_events","type":"User","site_admin":false},"created_at":"2018-03-12T00:52:50Z","updated_at":"2018-03-12T00:52:50Z","author_association":"CONTRIBUTOR","body":"I should note that adding a `' '` (space) character to the beginning of the string causes all tokens to have spans matching the second one."}}
{"actor":{"display_login":"mystor"}}