Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upUse associated constants in `std::num::{Zero,One}` #25684
Conversation
rust-highfive
assigned
aturon
May 21, 2015
This comment has been minimized.
This comment has been minimized.
|
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
|
What's the status of this in the face of #25687 ? |
This comment has been minimized.
This comment has been minimized.
|
It's a superset - I'll rebase this when #25687 lands. |
This comment has been minimized.
This comment has been minimized.
|
The extra bits just ICE, though, right? |
This comment has been minimized.
This comment has been minimized.
|
Yeah - I'd file an issue but I wasn't able to reduce the ICE down |
Manishearth
added a commit
to Manishearth/rust
that referenced
this pull request
May 22, 2015
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
Like I told @tamird on IRC, this particular ICE is a mishandling of unresolved paths to associated items. |
oli-obk
pushed a commit
to oli-obk/rust
that referenced
this pull request
May 23, 2015
oli-obk
pushed a commit
to oli-obk/rust
that referenced
this pull request
May 23, 2015
oli-obk
pushed a commit
to oli-obk/rust
that referenced
this pull request
May 23, 2015
oli-obk
pushed a commit
to oli-obk/rust
that referenced
this pull request
May 23, 2015
tamird
force-pushed the
tamird:num-associated-consts
branch
from
72e9aaa
to
9bef19d
May 23, 2015
This comment has been minimized.
This comment has been minimized.
|
@eddyb Ah, I see. We are asking if it is an lvalue before the type is checked, which is where |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
@bluss this is true, but not such a big problem given https://github.com/rust-lang/rust/pull/25609/files#diff-9e764fdb4b37fceaf4fdf1ddb027dbcaR15 |
This comment has been minimized.
This comment has been minimized.
|
BigNum are allocating and can never impl the new trait (?) I don't think it's important. |
This comment has been minimized.
This comment has been minimized.
|
@bluss if the |
This comment has been minimized.
This comment has been minimized.
|
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. |
tamird
force-pushed the
tamird:num-associated-consts
branch
2 times, most recently
from
7322ac0
to
8d7f2e4
May 26, 2015
alexcrichton
added
the
T-libs
label
May 26, 2015
This comment has been minimized.
This comment has been minimized.
|
As a temporary measure, #25091 rejects this code, so this PR is blocked behind a future change that allows associated constants to depend on |
tamird commentedMay 21, 2015
This refactor causes the following ICE: