Skip to content

Commit f4cc16b

Browse files
committed
Interaction with Method dispatch, Unsatisfiable trait members
1 parent 166024a commit f4cc16b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

text/3245-refined-impls.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,26 @@ impl Iterator for Foo {
254254

255255
Should the `nth` method also be considered `const fn`?
256256

257+
### Method dispatch
258+
259+
The [method dispatch rules] can be confusing when there are multiple candidates with the same name but that differ in their `self` type. Refinement on `impl Trait` return types can interact with this by adding new candidates for method dispatch. See [this comment][resolution-comment] for an example.
260+
261+
Method dispatch rules can be improved in a future edition, for example by making callers disambiguate the method they want to call in these situations.
262+
263+
[method dispatch rules]: https://doc.rust-lang.org/stable/reference/expressions/method-call-expr.html
264+
[resolution-comment]: https://github.com/rust-lang/rfcs/pull/3245#issuecomment-1105959958
265+
266+
### Unsatisfiable trait members
267+
268+
Today we [require trait members with unsatisfiable `where` clauses to be implemented][2829]. This leads to dropping the unsatisfiable bounds in the impl (a form of refinement) and, in some cases, relying on the property that the item can never be used. See [this comment][unsat-comment] for an example. This RFC would relax that property.
269+
270+
It should be considered a bug for any code to rely on this unusability property for correctness purposes, though a panic may be necessary in some cases.
271+
272+
We should solve this problem separately and allow implementers to omit items like this, but that is out of the scope of this RFC.
273+
274+
[2829]: https://github.com/rust-lang/rfcs/issues/2829
275+
[unsat-comment]: https://github.com/rust-lang/rfcs/pull/3245#issuecomment-1120097693
276+
257277
# Drawbacks
258278
[drawbacks]: #drawbacks
259279

0 commit comments

Comments
 (0)