-
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
Use associated constants in std::num::{Zero,One}
#25684
Conversation
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
What's the status of this in the face of #25687 ? |
It's a superset - I'll rebase this when #25687 lands. |
The extra bits just ICE, though, right? |
Yeah - I'd file an issue but I wasn't able to reduce the ICE down |
Cleanup extracted from rust-lang#25684. r? @alexcrichton
We are in the unhappy position where trait-associated constants are not really useful, because you can't actually use them from type parameters. For use of trait-associated constants in non-constant expressions, we need something similar to the existing type projections, so that the compiler isn't confused about constants that can't be resolved. For use in constant expressions, see: rust-lang/rfcs#1062. |
Like I told @tamird on IRC, this particular ICE is a mishandling of unresolved paths to associated items. |
Cleanup extracted from rust-lang#25684. r? @alexcrichton
Cleanup extracted from rust-lang#25684. r? @alexcrichton
Cleanup extracted from rust-lang#25684. r? @alexcrichton
Cleanup extracted from rust-lang#25684. r? @alexcrichton
72e9aaa
to
9bef19d
Compare
@eddyb Ah, I see. We are asking if it is an lvalue before the type is checked, which is where |
This makes the trait less general (only available to types that can produce a zero in constants). I suppose that's useful and ok, it just needs to be mentioned. |
@bluss this is true, but not such a big problem given https://github.com/rust-lang/rust/pull/25609/files#diff-9e764fdb4b37fceaf4fdf1ddb027dbcaR15 |
BigNum are allocating and can never impl the new trait (?) I don't think it's important. |
@bluss if the |
I agree with @bluss that this probably excludes bignum from implementing the trait, but I'm somewhat hesitant on casting it aside as not important. The These existence of these traits is necessitated by the iterators that use them, and I believe that's needed for inference to work out ok, so these need to stick around. I think it's fine to experiment with them having associated constants instead of methods, but we'd likely want to give everything a rethink still before stabilizing them. |
This commit causes an ICE!
7322ac0
to
8d7f2e4
Compare
As a temporary measure, #25091 rejects this code, so this PR is blocked behind a future change that allows associated constants to depend on |
This refactor causes the following ICE: