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

only provide traits like Eq/Ord on @T and @mut T when they're known to be non-cyclic #6553

Closed
thestinger opened this issue May 17, 2013 · 4 comments
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@thestinger
Copy link
Contributor

Based on #5767.

We should really only be providing these default implementations when we know they're valid.

An easy way of doing it is only implementing them by default on T: Const. It's still possible to make user-defined implementations for types containing non-Const @T, you just can't use deriving and implicitly end up with a faulty implementation.

@thestinger
Copy link
Contributor Author

Nominating for the backwards compatible milestone.

@huonw
Copy link
Member

huonw commented Aug 19, 2013

Triage visit: it would be neat if we could somehow implement it so that == worked perfectly on possibly cyclic structures, e.g. Python handles it fine:

>>> L = []
>>> L.append(L)
>>> L == L
True
>>> x = [L, 1]
>>> y = [L, 2]
>>> x == y
False

At the very least, for @ and @mut, using TLS and keeping track of the nodes(memory locations?) already examined, and substituting in the appropriate value for the trait being implemented rather than recursing again.

(This would presumably have to be careful in the presence of a possibly-moving GC, but I'd guess that such a function call would freeze the pointers in memory?)

@catamorphism
Copy link
Contributor

Just a bug

@thestinger
Copy link
Contributor Author

This will be dealt with by the move to Gc<T>.

flip1995 pushed a commit to flip1995/rust that referenced this issue Jan 15, 2021
…cros, r=flip1995

Fix derive and macro related false positives in `field_reassign_with_default`

Closes rust-lang#6545

changelog: Fix derive and macro related false positives in [`field_reassign_with_default`]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

3 participants