-
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
Allow a minimum complete implementation to be specified for mutually recursive default methods #7771
Comments
This feature recently landed in GHC: http://ghc.haskell.org/trac/ghc/ticket/7633. Example of the syntax: {-# MINIMAL (.&.), (.|.), xor, complement,
(shift | (shiftL, shiftR)),
(rotate | (rotateL, rotateR)),
bitSize, bitSizeMaybe, isSigned, testBit, bit, popCount #-} Of particular note is that it supports nested conjunction/disjunction ( (taken from http://ghc.haskell.org/trac/ghc/changeset/7ab62490dbc1ea7430fe60d5dad9c3b0fa0bedad/base) |
Triage, no change. |
cc me |
I think this can be entirely implemented as a lint plugin out of the the compiler, although some traits in the standard library ( |
@huonw would that mean that incorrect |
Yes it would, which is a good point, since it reduces the usefulness of the lint. But, it is just some assistance for avoiding accidental infinite recursion, i.e. not required for safety, or to get a correct It can certainly be prototyped out of tree to avoid the horrendous bootstrap times. |
Yeah, that’s fine for prototyping, but I’d say that this limitation makes this feature useless as far as I’m concerned. Just because infinite recursion is not a memory-safety problem doesn’t mean it’s not a problem that the type system should help solve :) |
This isn't a type system feature... but yes, your point stands. |
We can copy the syntax for #[requires(any(foo, bar), any(baz, qux))]
trait A {
// ...
} I'm not sure whether we should allow |
I'm pulling a massive triage effort to get us ready for 1.0. As part of this, I'm moving stuff that's wishlist-like to the RFCs repo, as that's where major new things should get discussed/prioritized. This issue has been moved to the RFCs repo: rust-lang/rfcs#628 |
remove FIXME(rust-lang#13101) since `assert_receiver_is_total_eq` stays. remove FIXME(rust-lang#19649) now that stability markers render. remove FIXME(rust-lang#13642) now the benchmarks were moved. remove FIXME(rust-lang#6220) now that floating points can be formatted. remove FIXME(rust-lang#18248) and write tests for `Rc<str>` and `Rc<[u8]>` remove reference to irelevent issues in FIXME(rust-lang#1697, rust-lang#2178...) update FIXME(rust-lang#5516) to point to getopts issue 7 update FIXME(rust-lang#7771) to point to RFC 628 update FIXME(rust-lang#19839) to point to issue 26925
It should be possible to tell the compiler that at least one of a given set of default methods is required to be implemented, e.g.
This allows e.g.
Eq
to writeeq
andne
in terms of each other, without allowing the infinitely recursiveimpl Eq for Foo {}
.It could even allow saying "either
foo
or bothbar
andbaz
", e.g.#[requires(one_of(foo, all_of(bar, baz)))]
, and would hopefully warn if a non-default method was listed.The text was updated successfully, but these errors were encountered: