-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Forbid items with the same name from appearing in overlapping inherent impl blocks #31925
Conversation
☔ The latest upstream changes (presumably #31979) made this pull request unmergeable. Please resolve the merge conflicts. |
r=me once rebased, I think. I just had a few nits, nothing important. Address or don't. :) |
@bors: r=nikomatsakis |
📌 Commit 4804ef9 has been approved by |
⌛ Testing commit 4804ef9 with merge 2ca41f0... |
💔 Test failed - auto-linux-64-opt |
@bors: r=nikomatsakis |
📌 Commit 0038777 has been approved by |
🔒 Merge conflict |
☔ The latest upstream changes (presumably #31710) made this pull request unmergeable. Please resolve the merge conflicts. |
0038777
to
e3a74b9
Compare
@bors: r=nikomatsakis |
📌 Commit e3a74b9 has been approved by |
⌛ Testing commit e3a74b9 with merge a5f6b36... |
💔 Test failed - auto-mac-64-nopt-t |
This commit introduces the idea of an "impl header", which consists of everything outside the impl body: the Self type, the trait reference (when applicable), and predicates from `where` clauses. This type is usable with the type folding machinery, making it possible to work with impl headers at a higher and more generic level.
e3a74b9
to
66bdfe5
Compare
@bors: r=nikomatsakis |
📌 Commit 66bdfe5 has been approved by |
impl blocks. For example, the following is now correctly illegal: ```rust struct Foo; impl Foo { fn id() {} } impl Foo { fn id() {} } ``` "Overlapping" here is determined the same way it is for traits (and in fact shares the same code path): roughly, there must be some way of substituting any generic types to unify the impls, such that none of the `where` clauses are provably unsatisfiable under such a unification. Closes rust-lang#22889
…at a regression test already exists for *non*overlapping impls.
66bdfe5
to
2234b55
Compare
@bors: r=nikomatsakis |
📌 Commit 2234b55 has been approved by |
⌛ Testing commit 2234b55 with merge 62d4b8d... |
💔 Test failed - auto-mac-64-nopt-t |
@bors: r=nikomatsakis |
📌 Commit 6265b6b has been approved by |
⌛ Testing commit 6265b6b with merge 1a019dc... |
Forbid items with the same name from appearing in overlapping inherent impl blocks For example, the following is now correctly illegal: ```rust struct Foo; impl Foo { fn id() {} } impl Foo { fn id() {} } ``` "Overlapping" here is determined the same way it is for traits (and in fact shares the same code path): roughly, there must be some way of substituting any generic types to unify the impls, such that none of the `where` clauses are provably unsatisfiable under such a unification. Along the way, this PR also introduces an `ImplHeader` abstraction (the first commit) that makes it easier to work with impls abstractly (without caring whether they are trait or inherent impl blocks); see the first commit. Closes #22889 r? @nikomatsakis
For example, the following is now correctly illegal:
"Overlapping" here is determined the same way it is for traits (and in fact shares the same code path): roughly, there must be some way of substituting any generic types to unify the impls, such that none of the
where
clauses are provably unsatisfiable under such a unification.Along the way, this PR also introduces an
ImplHeader
abstraction (the first commit) that makes it easier to work with impls abstractly (without caring whether they are trait or inherent impl blocks); see the first commit.Closes #22889
r? @nikomatsakis