-
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
Auto-derefencing is too eager #6257
Comments
The equivalent of |
@nikomatsakis The type of However |
@huonw there is some subtlety here regarding how we select matching trait methods. In this case, you are expecting that we will match That said, something just occurred to me. I think that the problem is not with autoderef per se, but rather with the way that we define the binary operator traits. We ought to define them as follows:
meaning that
The same would apply to other binary operator traits. Note that there would be no auto-deref in this case. |
I'm inclined to close this issue. @huonw re-open is you disagree. |
…omatsakis This "finishes" the generic deriving code (which I started in #5640), in the sense it supports everything that I can think of being useful. (Including lifetimes and type parameters on methods and traits, arguments and return values of (almost) any type, static methods.) It closes #6149, but met with #6257, so the following doesn't work: ```rust #[deriving(TotalEq)] struct Foo<'self>(&'self int); ``` (It only fails for `TotalOrd`, `TotalEq` and `Clone`, since they are the only ones that call a method directly on sub-elements of the type, which means that the auto-deref interferes with the pointer.) It also makes `Rand` (chooses a random variant, fills the fields with random values, including recursively for recursive types) and `ToStr` (`x.to_str()` is the same as `fmt!("%?", x)`) derivable, as well as converting IterBytes to the generic code (which made the code 2.5x shorter, more robust and added support for tuple structs). ({En,De}codable are trickier, so I'll convert them over later.)
The following seems annoying (and is especially so for writing macros/syntax extensions)
The text was updated successfully, but these errors were encountered: