-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
EnumSet with more variants than bits in uint silently corrupts data #13756
Comments
Closed
SimonSapin
added a commit
to SimonSapin/rust
that referenced
this issue
Nov 7, 2014
Assert at run time instead. Fixes rust-lang#13756. I’d rather have this be detected at compile-time, but I don’t know how to do that.
bors
added a commit
that referenced
this issue
Nov 7, 2014
Assert at run time instead. Fixes #13756. I’d rather have this be detected at compile-time, but I don’t know how to do that.
arcnmx
pushed a commit
to arcnmx/rust
that referenced
this issue
Dec 17, 2022
… r=flodiebold Make assoc_resolutions always have a Substitution
flip1995
pushed a commit
to flip1995/rust
that referenced
this issue
Dec 15, 2024
The new cases are the application of `Into::into` or `From::from` through the following functions with no effect: - `Option::map()` - `Result::map()` and `Result::map_err()` - `ControlFlow::map_break()` and `ControlFlow::map_err()` - `Iterator::map()` changelog: [`useless_conversion`]: detect useless calls to `Into::into` and `From::from` application through `map*` methods
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Test case:
Expected result, in decreasing order of preference:
~[V63, V64, V65]
, compile-time failure, or run-time failure.Actual result with rustc eea4909 on a 64 bit system:
~[V00, V01, V63]
Use case: Servo currently handles CSS declarations in order, later ones overwriting earlier ones. I’d like instead to process declarations in reverse order, and skip those for properties for which we already have a value. "Already have a value" would be stored in an EnumSet with one variant for every CSS property. There are a few hundreds of them. (The enum is automatically generated.) (Values can not be
Option
s, because they’re initialized to the inherited or initial value rather thanNone
.)Possible fixes:
bit
function assert (non-disablable) thate.to_uint() < (size_of<uint>() * 8)
BigEnumSet
type that usesVec<uint>
or~[uint]
internally for storage rather than just a singleuint
.EnumSet
to decide at run-time to use~[uint]
or a singleuint
for storage, likecollections::bitv::Bitv
does.EnumSet
is being monomorphized anyway.) I don’t know if this is possible.3 or 4 might need the
CLike
trait to gain amax_value
associated function (or something), which would ideally be based on introspection rather than leaving the counting to the user.The text was updated successfully, but these errors were encountered: