{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/51934","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/51934/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/51934/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/51934/events","html_url":"https://github.com/rust-lang/rust/issues/51934","id":337178015,"node_id":"MDU6SXNzdWUzMzcxNzgwMTU=","number":51934,"title":"Change behavior of `?` as a macro separator and Kleene op in 2018 edition","user":{"login":"mark-i-m","id":8827840,"node_id":"MDQ6VXNlcjg4Mjc4NDA=","avatar_url":"https://avatars0.githubusercontent.com/u/8827840?v=4","gravatar_id":"","url":"https://api.github.com/users/mark-i-m","html_url":"https://github.com/mark-i-m","followers_url":"https://api.github.com/users/mark-i-m/followers","following_url":"https://api.github.com/users/mark-i-m/following{/other_user}","gists_url":"https://api.github.com/users/mark-i-m/gists{/gist_id}","starred_url":"https://api.github.com/users/mark-i-m/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mark-i-m/subscriptions","organizations_url":"https://api.github.com/users/mark-i-m/orgs","repos_url":"https://api.github.com/users/mark-i-m/repos","events_url":"https://api.github.com/users/mark-i-m/events{/privacy}","received_events_url":"https://api.github.com/users/mark-i-m/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2018-06-30T02:08:12Z","updated_at":"2018-06-30T16:46:12Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"This is a request for FCP on PR #51587, according to https://github.com/rust-lang/rust/pull/51587#issuecomment-401428361.\r\n\r\nTracking issue: #48075 (`?` macro repetition)\r\n\r\nCurrent behavior:\r\n- `?` is a macro separator, not a Kleene op.\r\n\r\nProposed new behavior (implemented in #51587):\r\n- Edition 2015: `?` is a macro separator, not a kleene op, but using it as a separator triggers a migration lint.\r\n- Edition 2018: `?` is _not_ a valid separator. `?` _is_ a valid Kleene op.\r\n\r\nEDIT: To clarify: Under this proposal, `$(a)?+` matches `+` and `a+` unambiguously.\r\n\r\nWhy we chose this behavior:\r\n- It's the cleanest choice both in terms of end-user experience and implementation. See the alternatives.\r\n\r\nAlternatives:  The main problem to address is ambiguity. Currently, `?` is a valid separator, so there are a lot of ambiguous possibilities like `$(a)?+`. Is the `?` a separator for 1 or more iterations OR is it a zero-or-one kleene op followed by a `+` token? The solutions fall into 2 categories: make breaking changes or add fallbacks.\r\n1. Fallbacks\r\n    - The original implementation (currently on nightly behind feature gate `macro_at_most_once_rep`):\r\n        - The `?` kleene op is allowed to take a separator which can never be used (we don't allow trailing separators and `?` allows at most one repetition).\r\n        - When parsing a macro, we disambiguate by looking after the separator: if `?` is followed by `+`, `*`, or `?`, we treat the `?` as a separator and the second token as a kleene op.\r\n    - On the tracking issue, we decided that it is confusing for `?` to take a separator, so the rules would be that `?` followed by `+` or `*` is a separator, but `?` followed by `?` or any other token would be a `?` kleene op followed by the other token.\r\n        - This is a viable implementation, but it seems like a lot of special cases and the code gets messy. This led us more towards the breaking changes options.\r\n    - There are probably lots of variations of fallbacks we could do, but they all have weird corner cases.\r\n\r\n2. Breaking changes\r\n    - Make a breaking change in the _2015_ edition (implemented in #49719, accidentally merged without FCP, and rolled back).\r\n        - Disallow `?` as a separator in _2015_ edition.\r\n        - Disallow `?` kleene op from taking a separator.\r\n        - This means that `$(a)?+` matches `+` and `a+` unambiguously. However, it is a _breaking change_. This was deemed not worthy of a breaking change in the 2015 edition.\r\n    - Make a breaking change in the _2018_ edition and lint in the _2015_ edition. No change to behavior in _2015_. This is the current proposal implemented in #51587 and is the subject of this FCP.\r\n        - The primary downside here is that it's not clear what happens if you import a macro from 2015 into 2018 that uses `?` as a separator. Currently, you would just get a compile error.\r\n        - I believe the breakage is likely to be extremely rare. A crater run showed no breakage (https://github.com/rust-lang/rust/pull/49719#issuecomment-381364742). However, we did found out later that there was apparently some breakage elsewhere (https://github.com/rust-lang/rust/pull/49719#issuecomment-394190428).\r\n        - The implementation is significantly cleaner and more maintainable and the behavior is more consistent for end-users.\r\n\r\ncc @nikomatsakis \r\ncc @petrochenkov Reviewed the second attempt\r\ncc @durka @alexreg @clarcharr @Centril @kennytm @ExpHP  Who participated extensively in the original design discussions (EDIT: apologies if I missed anyone; there were a lot of people who came in at various points)\r\ncc @oli-obk Who brought up clippy breakage\r\ncc @sgrif @pietroalbini  Who wanted to see an FCP\r\n\r\nWhew... that's a lot of people :)"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/401552526","html_url":"https://github.com/rust-lang/rust/issues/51934#issuecomment-401552526","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/51934","id":401552526,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMTU1MjUyNg==","user":{"login":"ExpHP","id":1411280,"node_id":"MDQ6VXNlcjE0MTEyODA=","avatar_url":"https://avatars0.githubusercontent.com/u/1411280?v=4","gravatar_id":"","url":"https://api.github.com/users/ExpHP","html_url":"https://github.com/ExpHP","followers_url":"https://api.github.com/users/ExpHP/followers","following_url":"https://api.github.com/users/ExpHP/following{/other_user}","gists_url":"https://api.github.com/users/ExpHP/gists{/gist_id}","starred_url":"https://api.github.com/users/ExpHP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ExpHP/subscriptions","organizations_url":"https://api.github.com/users/ExpHP/orgs","repos_url":"https://api.github.com/users/ExpHP/repos","events_url":"https://api.github.com/users/ExpHP/events{/privacy}","received_events_url":"https://api.github.com/users/ExpHP/received_events","type":"User","site_admin":false},"created_at":"2018-06-30T16:46:12Z","updated_at":"2018-06-30T16:46:12Z","author_association":"CONTRIBUTOR","body":"> What is the distinction from @kennytm's point?\r\n\r\nNone that I know of, it just sounded to me like you and I interpreted his question differently, especially due to the quote\r\n\r\n> The fix is frankly trivial: use any other separator than ?...\r\n\r\nwhich is not something a 2018 consumer of a 2015 macro crate can do."}}
{"actor":{"display_login":"ExpHP"}}