-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Deref not applying to things that implement Index #16821
Comments
Same with |
Nominated. @pcwalton What's the intended behavior here? |
cc me |
I would expect this to work. When we check to see if we can index we should search for the Index trait the same way we do when explicitly writing It is backwards compatible though, so shouldn't need to block 1.0. |
I think this is not a 1.0 issue. |
What's the reason this was removed? It's true that it's not backwards compatible, but it leads to really unfortunate code. |
@steveklabnik The nomination hasn't been removed -- we'll discuss this at tomorrow's triage meeting to determine whether to put it on the 1.0 milestone. At that point we'll remove the nomination tag and replace it with priorities/milestones. FWIW, I agree that this is really unfortunate as it stands. But the question for the milestone is: would we hold back the 1.0 release until it was fixed? The answer can be "no" even for very high priority items. I do think that @nikomatsakis's work on method resolution, as part of trait reform, is likely to fix this well before 1.0. |
Oh yeah, and honestly, I'm willing to make sacrifices for a 1.0, I guess |
P-high, not a 1.0 blocker. |
I think this'll probably wind up being fixed as fallout from various changes. |
Oh, @aturon , when I said 'was removed,' I wasn't talking about the nomination, I was asking how the regression in behaviour happened. |
Is this a dupe of #15757? |
This would be fixed by #18486 |
This branch cleans up overloaded operator resolution so that it is strictly based on the traits in `ops`, rather than going through the normal method lookup mechanism. It also adds full support for autoderef to overloaded index (whereas before autoderef only worked for non-overloaded index) as well as for the slicing operators. This is a [breaking-change]: in the past, we were accepting combinations of operands that were not intended to be accepted. For example, it was possible to compare a fixed-length array and a slice, or apply the `!` operator to a `&int`. See the first two commits in this pull-request for examples. One downside of this change is that comparing fixed-length arrays doesn't always work as smoothly as it did before. Before this, comparisons sometimes worked due to various coercions to slices. I've added impls for `Eq`, `Ord`, etc for fixed-lengths arrays up to and including length 32, but if the array is longer than that you'll need to either newtype the array or convert to slices. Note that this plays better with deriving in any case than the previous scheme. Fixes #4920. Fixes #16821. Fixes #15757. cc @alexcrichton cc @aturon
It seems that when |
This should compile, but doesn't:
The text was updated successfully, but these errors were encountered: