-
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
Unify unsized types in type inference #17178
Comments
Nominating for p-backcompat-lang. This is the last backwards incompatible part of DST, so we can unblock #12938 from 1.0. This change is backwards incompatible since it will introduce coherence errors for impls for both sized and unsized types. |
Plan A:
Plan B
|
Assigning P-backcompat-lang, 1.0 milestone. |
nikomatsakis
added a commit
to nikomatsakis/rust
that referenced
this issue
Oct 21, 2014
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.
bors
added a commit
that referenced
this issue
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
Merged
This is closed, yet still listed as blocking on #12938 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In order not have a tonne of coherence errors, we currently do not unify unsized types with type variables in type inference. For example,
[T]
withU
. This mimics our old behaviour where unsized types were not types.This prevents us having an impl for
&T
which will use an impl for[T]
, i.e., we need a separate impl for&[T]
. This is one of the primary benefits of DST. It also causes problems when the compiler needs to infer a DST for a type parameter, e.g., in function calls. See #17122 for one example.Blocks #16918, #12938
The text was updated successfully, but these errors were encountered: