{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/comments/140242982","pull_request_review_id":64283875,"id":140242982,"diff_hunk":"@@ -301,6 +301,44 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {\n     }\n \n     pub fn lower_pattern(&mut self, pat: &'tcx hir::Pat) -> Pattern<'tcx> {\n+        // When implicit dereferences have been inserted in this pattern, the unadjusted lowered\n+        // pattern has the type that results *after* dereferencing. For example, in this code:\n+        //\n+        // ```\n+        // match &&Some(0i32) {\n+        //     Some(n) => { ... },\n+        //     _ => { ... },\n+        // }\n+        // ```\n+        //\n+        // the type assigned to `Some(n)` in `unadjusted_pat` would be `Option<i32>` (this is\n+        // determined in rustc_typeck::check::match). The adjustments would be\n+        //\n+        // `vec![&&Option<i32>, &Option<i32>]`.\n+        //\n+        // Applying the adjustments, we want to instead output `&&Some(n)` (as a HAIR pattern). So\n+        // we wrap the unadjusted pattern in `PatternKind::Deref` repeatedly, consuming the\n+        // adjustments in *reverse order* (last-in-first-out, so that the last `Deref` inserted\n+        // gets the least-dereferenced type).\n+        let unadjusted_pat = self.lower_pattern_unadjusted(pat);\n+        self.tables\n+            .pat_adjustments()\n+            .get(pat.hir_id)\n+            .unwrap_or(&vec![])\n+            .iter()\n+            .rev()\n+            .fold(unadjusted_pat, |pat, ref_ty| {\n+                    debug!(\"{:?}: wrapping pattern with type {:?}\", pat, ref_ty);\n+                    Pattern {\n+                        span: pat.span,\n+                        ty: ref_ty,\n+                        kind: Box::new(PatternKind::Deref { subpattern: pat }),\n+                    }\n+                },\n+            )\n+    }\n+\n+    pub fn lower_pattern_unadjusted(&mut self, pat: &'tcx hir::Pat) -> Pattern<'tcx> {","path":"src/librustc_const_eval/pattern.rs","position":41,"original_position":41,"commit_id":"5c972f4c8b3b8ee9386744c9ff15a48999ca8deb","original_commit_id":"5c972f4c8b3b8ee9386744c9ff15a48999ca8deb","user":{"login":"nikomatsakis","id":155238,"avatar_url":"https://avatars0.githubusercontent.com/u/155238?v=4","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},"body":"Make this private.","created_at":"2017-09-21T13:38:50Z","updated_at":"2017-09-21T13:59:43Z","html_url":"https://github.com/rust-lang/rust/pull/44614#discussion_r140242982","pull_request_url":"https://api.github.com/repos/rust-lang/rust/pulls/44614","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments/140242982"},"html":{"href":"https://github.com/rust-lang/rust/pull/44614#discussion_r140242982"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/44614"}}},"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/44614","id":141402217,"html_url":"https://github.com/rust-lang/rust/pull/44614","diff_url":"https://github.com/rust-lang/rust/pull/44614.diff","patch_url":"https://github.com/rust-lang/rust/pull/44614.patch","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/44614","number":44614,"state":"open","locked":false,"title":"implement pattern-binding-modes RFC","user":{"login":"tschottdorf","id":5076964,"avatar_url":"https://avatars1.githubusercontent.com/u/5076964?v=4","gravatar_id":"","url":"https://api.github.com/users/tschottdorf","html_url":"https://github.com/tschottdorf","followers_url":"https://api.github.com/users/tschottdorf/followers","following_url":"https://api.github.com/users/tschottdorf/following{/other_user}","gists_url":"https://api.github.com/users/tschottdorf/gists{/gist_id}","starred_url":"https://api.github.com/users/tschottdorf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tschottdorf/subscriptions","organizations_url":"https://api.github.com/users/tschottdorf/orgs","repos_url":"https://api.github.com/users/tschottdorf/repos","events_url":"https://api.github.com/users/tschottdorf/events{/privacy}","received_events_url":"https://api.github.com/users/tschottdorf/received_events","type":"User","site_admin":false},"body":"See the [RFC] and [tracking issue].\n\nThis is a work in progress. The basic examples from the RFC are in place and work,\nand tests are passing. TODO list:\n\n- [x] update the [mem-categorization code]\n- [ ] address various `FIXME(tschottdorf)`s (made some spurious changes to highlight older ones)\n- [ ] audit the test changes. In particular, I *think* that it might be considered unfortunate that\n      typeck is now unaware of the fact that autoderefs were inserted, and so the error messages may\n      refer to types that weren't written down.\n- [ ] add more test cases for all kinds of non-reference patterns.\n\n[tracking issue]: https://github.com/rust-lang/rust/issues/42640\n[RFC]: https://github.com/rust-lang/rfcs/blob/491e0af/text/2005-match-ergonomics.md\n[mem-categorization code]: https://github.com/rust-lang/rust/issues/42640#issuecomment-329740459","created_at":"2017-09-15T21:09:00Z","updated_at":"2017-09-21T13:59:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cb12b4dea85118734ab27c4398fbc4f92918b87e","assignee":{"login":"nikomatsakis","id":155238,"avatar_url":"https://avatars0.githubusercontent.com/u/155238?v=4","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},"assignees":[{"login":"nikomatsakis","id":155238,"avatar_url":"https://avatars0.githubusercontent.com/u/155238?v=4","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}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/rust/pulls/44614/commits","review_comments_url":"https://api.github.com/repos/rust-lang/rust/pulls/44614/comments","review_comment_url":"https://api.github.com/repos/rust-lang/rust/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/44614/comments","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/5c972f4c8b3b8ee9386744c9ff15a48999ca8deb","head":{"label":"tschottdorf:pat_adjustments","ref":"pat_adjustments","sha":"5c972f4c8b3b8ee9386744c9ff15a48999ca8deb","user":{"login":"tschottdorf","id":5076964,"avatar_url":"https://avatars1.githubusercontent.com/u/5076964?v=4","gravatar_id":"","url":"https://api.github.com/users/tschottdorf","html_url":"https://github.com/tschottdorf","followers_url":"https://api.github.com/users/tschottdorf/followers","following_url":"https://api.github.com/users/tschottdorf/following{/other_user}","gists_url":"https://api.github.com/users/tschottdorf/gists{/gist_id}","starred_url":"https://api.github.com/users/tschottdorf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tschottdorf/subscriptions","organizations_url":"https://api.github.com/users/tschottdorf/orgs","repos_url":"https://api.github.com/users/tschottdorf/repos","events_url":"https://api.github.com/users/tschottdorf/events{/privacy}","received_events_url":"https://api.github.com/users/tschottdorf/received_events","type":"User","site_admin":false},"repo":{"id":89545970,"name":"rust","full_name":"tschottdorf/rust","owner":{"login":"tschottdorf","id":5076964,"avatar_url":"https://avatars1.githubusercontent.com/u/5076964?v=4","gravatar_id":"","url":"https://api.github.com/users/tschottdorf","html_url":"https://github.com/tschottdorf","followers_url":"https://api.github.com/users/tschottdorf/followers","following_url":"https://api.github.com/users/tschottdorf/following{/other_user}","gists_url":"https://api.github.com/users/tschottdorf/gists{/gist_id}","starred_url":"https://api.github.com/users/tschottdorf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tschottdorf/subscriptions","organizations_url":"https://api.github.com/users/tschottdorf/orgs","repos_url":"https://api.github.com/users/tschottdorf/repos","events_url":"https://api.github.com/users/tschottdorf/events{/privacy}","received_events_url":"https://api.github.com/users/tschottdorf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tschottdorf/rust","description":"A safe, concurrent, practical language.","fork":true,"url":"https://api.github.com/repos/tschottdorf/rust","forks_url":"https://api.github.com/repos/tschottdorf/rust/forks","keys_url":"https://api.github.com/repos/tschottdorf/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tschottdorf/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tschottdorf/rust/teams","hooks_url":"https://api.github.com/repos/tschottdorf/rust/hooks","issue_events_url":"https://api.github.com/repos/tschottdorf/rust/issues/events{/number}","events_url":"https://api.github.com/repos/tschottdorf/rust/events","assignees_url":"https://api.github.com/repos/tschottdorf/rust/assignees{/user}","branches_url":"https://api.github.com/repos/tschottdorf/rust/branches{/branch}","tags_url":"https://api.github.com/repos/tschottdorf/rust/tags","blobs_url":"https://api.github.com/repos/tschottdorf/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tschottdorf/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tschottdorf/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/tschottdorf/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tschottdorf/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/tschottdorf/rust/languages","stargazers_url":"https://api.github.com/repos/tschottdorf/rust/stargazers","contributors_url":"https://api.github.com/repos/tschottdorf/rust/contributors","subscribers_url":"https://api.github.com/repos/tschottdorf/rust/subscribers","subscription_url":"https://api.github.com/repos/tschottdorf/rust/subscription","commits_url":"https://api.github.com/repos/tschottdorf/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/tschottdorf/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/tschottdorf/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/tschottdorf/rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/tschottdorf/rust/contents/{+path}","compare_url":"https://api.github.com/repos/tschottdorf/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tschottdorf/rust/merges","archive_url":"https://api.github.com/repos/tschottdorf/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tschottdorf/rust/downloads","issues_url":"https://api.github.com/repos/tschottdorf/rust/issues{/number}","pulls_url":"https://api.github.com/repos/tschottdorf/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/tschottdorf/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/tschottdorf/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tschottdorf/rust/labels{/name}","releases_url":"https://api.github.com/repos/tschottdorf/rust/releases{/id}","deployments_url":"https://api.github.com/repos/tschottdorf/rust/deployments","created_at":"2017-04-27T02:17:02Z","updated_at":"2017-04-27T02:17:23Z","pushed_at":"2017-09-16T14:25:14Z","git_url":"git://github.com/tschottdorf/rust.git","ssh_url":"git@github.com:tschottdorf/rust.git","clone_url":"https://github.com/tschottdorf/rust.git","svn_url":"https://github.com/tschottdorf/rust","homepage":"https://www.rust-lang.org","size":325356,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rust-lang:master","ref":"master","sha":"b965d55a3214b78ec9ffdd3017cb6aaa62c28059","user":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars1.githubusercontent.com/u/5430905?v=4","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":724712,"name":"rust","full_name":"rust-lang/rust","owner":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars1.githubusercontent.com/u/5430905?v=4","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rust-lang/rust","description":"A safe, concurrent, practical language.","fork":false,"url":"https://api.github.com/repos/rust-lang/rust","forks_url":"https://api.github.com/repos/rust-lang/rust/forks","keys_url":"https://api.github.com/repos/rust-lang/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rust-lang/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rust-lang/rust/teams","hooks_url":"https://api.github.com/repos/rust-lang/rust/hooks","issue_events_url":"https://api.github.com/repos/rust-lang/rust/issues/events{/number}","events_url":"https://api.github.com/repos/rust-lang/rust/events","assignees_url":"https://api.github.com/repos/rust-lang/rust/assignees{/user}","branches_url":"https://api.github.com/repos/rust-lang/rust/branches{/branch}","tags_url":"https://api.github.com/repos/rust-lang/rust/tags","blobs_url":"https://api.github.com/repos/rust-lang/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rust-lang/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rust-lang/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/rust-lang/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/rust-lang/rust/languages","stargazers_url":"https://api.github.com/repos/rust-lang/rust/stargazers","contributors_url":"https://api.github.com/repos/rust-lang/rust/contributors","subscribers_url":"https://api.github.com/repos/rust-lang/rust/subscribers","subscription_url":"https://api.github.com/repos/rust-lang/rust/subscription","commits_url":"https://api.github.com/repos/rust-lang/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/rust-lang/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/rust-lang/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/rust-lang/rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/rust-lang/rust/contents/{+path}","compare_url":"https://api.github.com/repos/rust-lang/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rust-lang/rust/merges","archive_url":"https://api.github.com/repos/rust-lang/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rust-lang/rust/downloads","issues_url":"https://api.github.com/repos/rust-lang/rust/issues{/number}","pulls_url":"https://api.github.com/repos/rust-lang/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/rust-lang/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/rust-lang/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rust-lang/rust/labels{/name}","releases_url":"https://api.github.com/repos/rust-lang/rust/releases{/id}","deployments_url":"https://api.github.com/repos/rust-lang/rust/deployments","created_at":"2010-06-16T20:39:03Z","updated_at":"2017-09-21T13:57:25Z","pushed_at":"2017-09-21T13:34:03Z","git_url":"git://github.com/rust-lang/rust.git","ssh_url":"git@github.com:rust-lang/rust.git","clone_url":"https://github.com/rust-lang/rust.git","svn_url":"https://github.com/rust-lang/rust","homepage":"https://www.rust-lang.org","size":326579,"stargazers_count":23499,"watchers_count":23499,"language":"Rust","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4322,"mirror_url":null,"open_issues_count":2845,"forks":4322,"open_issues":2845,"watchers":23499,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/44614"},"html":{"href":"https://github.com/rust-lang/rust/pull/44614"},"issue":{"href":"https://api.github.com/repos/rust-lang/rust/issues/44614"},"comments":{"href":"https://api.github.com/repos/rust-lang/rust/issues/44614/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/44614/comments"},"review_comment":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/44614/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/rust/statuses/5c972f4c8b3b8ee9386744c9ff15a48999ca8deb"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"nikomatsakis"}}