{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/30652","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/30652/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/30652/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/30652/events","html_url":"https://github.com/rust-lang/rust/pull/30652","id":124415868,"number":30652,"title":"Implement RFC 1210: impl specialization","user":{"login":"aturon","id":709807,"avatar_url":"https://avatars.githubusercontent.com/u/709807?v=3","gravatar_id":"","url":"https://api.github.com/users/aturon","html_url":"https://github.com/aturon","followers_url":"https://api.github.com/users/aturon/followers","following_url":"https://api.github.com/users/aturon/following{/other_user}","gists_url":"https://api.github.com/users/aturon/gists{/gist_id}","starred_url":"https://api.github.com/users/aturon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aturon/subscriptions","organizations_url":"https://api.github.com/users/aturon/orgs","repos_url":"https://api.github.com/users/aturon/repos","events_url":"https://api.github.com/users/aturon/events{/privacy}","received_events_url":"https://api.github.com/users/aturon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"nikomatsakis","id":155238,"avatar_url":"https://avatars.githubusercontent.com/u/155238?v=3","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},"milestone":null,"comments":40,"created_at":"2015-12-30T23:59:30Z","updated_at":"2016-03-11T23:52:53Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/30652","html_url":"https://github.com/rust-lang/rust/pull/30652","diff_url":"https://github.com/rust-lang/rust/pull/30652.diff","patch_url":"https://github.com/rust-lang/rust/pull/30652.patch"},"body":"This PR implements [impl specialization](https://github.com/rust-lang/rfcs/pull/1210), \r\ncarefully following the proposal laid out in the RFC.\r\n\r\nThe implementation covers the bulk of the RFC. The remaining gaps I know of are: \r\n\r\n- no checking for lifetime-dependent specialization (a soundness hole);\r\n- no `default impl` yet;\r\n- no support for `default` with associated consts;\r\n\r\nI plan to cover these gaps in follow-up PRs, as per @nikomatsakis's preference.\r\n\r\nThere are also a few TODOs remaining; tidy will prevent us from landing\r\nuntil those have been dealt with.\r\n\r\nThe basic strategy is to build up a *specialization graph* during\r\ncoherence checking. Insertion into the graph locates the right place\r\nto put an impl in the specialization hierarchy; if there is no right\r\nplace (due to partial overlap but no containment), you get an overlap\r\nerror. Specialization is consulted when selecting an impl (of course),\r\nand the graph is consulted when propagating defaults down the\r\nspecialization hierarchy.\r\n\r\nYou might expect that the specialization graph would be used during\r\nselection -- i.e., when actually performing specialization. This is\r\nnot done for two reasons:\r\n\r\n- It's merely an optimization: given a set of candidates that apply,\r\n  we can determine the most specialized one by comparing them directly\r\n  for specialization, rather than consulting the graph. Given that we\r\n  also cache the results of selection, the benefit of this\r\n  optimization is questionable.\r\n\r\n- To build the specialization graph in the first place, we need to use\r\n  selection (because we need to determine whether one impl specializes\r\n  another). Dealing with this reentrancy would require some additional\r\n  mode switch for selection. Given that there seems to be no strong\r\n  reason to use the graph anyway, we stick with a simpler approach in\r\n  selection, and use the graph only for propagating default\r\n  implementations.\r\n\r\nTrait impl selection can succeed even when multiple impls can apply,\r\nas long as they are part of the same specialization family. In that\r\ncase, it returns a *single* impl on success -- this is the most\r\nspecialized impl *known* to apply. However, if there are any inference\r\nvariables in play, the returned impl may not be the actual impl we\r\nwill use at trans time. Thus, we take special care to avoid projecting\r\nassociated types unless either (1) the associated type does not use\r\n`default` and thus cannot be overridden or (2) all input types are\r\nknown concretely.\r\n\r\nr? @nikomatsakis "},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/195606544","html_url":"https://github.com/rust-lang/rust/pull/30652#issuecomment-195606544","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/30652","id":195606544,"user":{"login":"bors","id":3372342,"avatar_url":"https://avatars.githubusercontent.com/u/3372342?v=3","gravatar_id":"","url":"https://api.github.com/users/bors","html_url":"https://github.com/bors","followers_url":"https://api.github.com/users/bors/followers","following_url":"https://api.github.com/users/bors/following{/other_user}","gists_url":"https://api.github.com/users/bors/gists{/gist_id}","starred_url":"https://api.github.com/users/bors/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bors/subscriptions","organizations_url":"https://api.github.com/users/bors/orgs","repos_url":"https://api.github.com/users/bors/repos","events_url":"https://api.github.com/users/bors/events{/privacy}","received_events_url":"https://api.github.com/users/bors/received_events","type":"User","site_admin":false},"created_at":"2016-03-11T23:52:53Z","updated_at":"2016-03-11T23:52:53Z","body":":pushpin: Commit 559aa19 has been approved by `nikomatsakis`\n\n<!-- @bors r=nikomatsakis 559aa19793a5fa76d421d67ac29f554346f92146 -->"}}