Skip to content
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

Make method calls use trait matching infrastructure #18121

Conversation

nikomatsakis
Copy link
Contributor

Convert trait method dispatch to use new trait matching machinery.

This fixes about 90% of #17918. What remains to be done is to make inherent dispatch work with conditional dispatch as well. I plan to do this in a future patch by generalizing the "method match" code slightly to work for inherent impls as well (the basic algorithm is precisely the same).

Fixes #17178.

This is a [breaking-change] for two reasons:

  1. The old code was a bit broken. I found various minor cases, particularly around operators, where the old code incorrectly matched, but an extra * or other change is now required. (See commit e8cef25 ("Correct case where the old version of method lookup...") for examples.)
  2. The old code didn't type check calls against the method signature from the trait but rather the impl. The two can be different in subtle ways. This makes the new method dispatch both more liberal and more conservative than the original. (See commit 8308332 ("The new method lookup mechanism typechecks...") for examples.)

r? @pcwalton since he's been reviewing most of this series of changes
f? @nick29581 for commit 39df55f ("Permit DST types to unify like other types")
cc @aturon as this relates to library stabilization

@nikomatsakis
Copy link
Contributor Author

cc @flaper87 (this is mostly orthogonal to what we've been talking about, but related)

@aturon
Copy link
Member

aturon commented Oct 17, 2014

Awesome!

@pcwalton
Copy link
Contributor

r=me with questions/nits addressed

…twist that we

have to take the transformed self type into account, and allow for coercion between
the receiver and the actual type declared on the impl.
Also:
1. stop eagerly coercing from `[T, ..n]` to `[T]` only do so if requested.
2. permit error to be interact more freely.

Fixes rust-lang#17178.
over anything that is foldable, not just fn signatures.
@nikomatsakis nikomatsakis force-pushed the method-call-use-trait-matching-infrastructure-2 branch from 951b095 to 98ca778 Compare October 21, 2014 15:57
of tracking individual candidates per impl, we just track one
candidate for the extension trait itself, and let the trait resolution
handle walking the individual impls and so forth. Also change the
interface to report back a richer notion of error.
…ype declared in the trait, not in the impl. In some cases that results in tighter rules, and in some cases looser. Correct for that.
…-ambiguities. These

are mostly new tests though I also revamped (and renamed) some of the existing tests.
@nikomatsakis nikomatsakis force-pushed the method-call-use-trait-matching-infrastructure-2 branch from 98ca778 to 646ec7d Compare October 21, 2014 16:32
bors added a commit that referenced this pull request Oct 22, 2014
…ng-infrastructure-2, r=pcwalton

Convert trait method dispatch to use new trait matching machinery.

This fixes about 90% of #17918. What remains to be done is to make inherent dispatch work with conditional dispatch as well. I plan to do this in a future patch by generalizing the "method match" code slightly to work for inherent impls as well (the basic algorithm is precisely the same).

Fixes #17178.

This is a [breaking-change] for two reasons:

1. The old code was a bit broken. I found various minor cases, particularly around operators, where the old code incorrectly matched, but an extra `*` or other change is now required. (See commit e8cef25 ("Correct case where the old version of method lookup...") for examples.)
2. The old code didn't type check calls against the method signature from the *trait* but rather the *impl*. The two can be different in subtle ways. This makes the new method dispatch both more liberal and more conservative than the original. (See commit 8308332 ("The new method lookup mechanism typechecks...") for examples.)

r? @pcwalton since he's been reviewing most of this series of changes
f? @nick29581 for commit 39df55f ("Permit DST types to unify like other types")
cc @aturon as this relates to library stabilization
@bors bors closed this Oct 22, 2014
@bors bors merged commit b066d09 into rust-lang:master Oct 22, 2014
@nikomatsakis nikomatsakis deleted the method-call-use-trait-matching-infrastructure-2 branch March 30, 2016 16:16
lnicola pushed a commit to lnicola/rust that referenced this pull request Sep 25, 2024
…, r=Veykril

fix: fix ambigious package name in flycheck

fixes rust-lang#18121
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unify unsized types in type inference
4 participants