about summary refs log tree commit diff
path: root/src/libstd/bitflags.rs
AgeCommit message (Collapse)AuthorLines
2014-12-08librustc: Make `Copy` opt-in.Niko Matsakis-0/+9
This change makes the compiler no longer infer whether types (structures and enumerations) implement the `Copy` trait (and thus are implicitly copyable). Rather, you must implement `Copy` yourself via `impl Copy for MyType {}`. A new warning has been added, `missing_copy_implementations`, to warn you if a non-generic public type has been added that could have implemented `Copy` but didn't. For convenience, you may *temporarily* opt out of this behavior by using `#![feature(opt_out_copy)]`. Note though that this feature gate will never be accepted and will be removed by the time that 1.0 is released, so you should transition your code away from using it. This breaks code like: #[deriving(Show)] struct Point2D { x: int, y: int, } fn main() { let mypoint = Point2D { x: 1, y: 1, }; let otherpoint = mypoint; println!("{}{}", mypoint, otherpoint); } Change this code to: #[deriving(Show)] struct Point2D { x: int, y: int, } impl Copy for Point2D {} fn main() { let mypoint = Point2D { x: 1, y: 1, }; let otherpoint = mypoint; println!("{}{}", mypoint, otherpoint); } This is the backwards-incompatible part of #13231. Part of RFC #3. [breaking-change]
2014-12-05Utilize fewer reexportsCorey Farwell-3/+3
In regards to: https://github.com/rust-lang/rust/issues/19253#issuecomment-64836729 This commit: * Changes the #deriving code so that it generates code that utilizes fewer reexports (in particur Option::* and Result::*), which is necessary to remove those reexports in the future * Changes other areas of the codebase so that fewer reexports are utilized
2014-11-05Repair various cases where values of distinct types were being operatedNiko Matsakis-2/+2
upon (e.g., `&int` added to `int`).
2014-10-28Update code with new lint namesAaron Turon-1/+1
2014-10-16libstd: Inline more methods on bitflags.Patrick Walton-0/+11
Servo really wants this.
2014-10-13Clean up rustc warnings.NODA, Kai-2/+29
compiletest: compact "linux" "macos" etc.as "unix". liballoc: remove a superfluous "use". libcollections: remove invocations of deprecated methods in favor of their suggested replacements and use "_" for a loop counter. libcoretest: remove invocations of deprecated methods; also add "allow(deprecated)" for testing a deprecated method itself. libglob: use "cfg_attr". libgraphviz: add a test for one of data constructors. libgreen: remove a superfluous "use". libnum: "allow(type_overflow)" for type cast into u8 in a test code. librustc: names of static variables should be in upper case. libserialize: v[i] instead of get(). libstd/ascii: to_lowercase() instead of to_lower(). libstd/bitflags: modify AnotherSetOfFlags to use i8 as its backend. It will serve better for testing various aspects of bitflags!. libstd/collections: "allow(deprecated)" for testing a deprecated method itself. libstd/io: remove invocations of deprecated methods and superfluous "use". Also add #[test] where it was missing. libstd/num: introduce a helper function to effectively remove invocations of a deprecated method. libstd/path and rand: remove invocations of deprecated methods and superfluous "use". libstd/task and libsync/comm: "allow(deprecated)" for testing a deprecated method itself. libsync/deque: remove superfluous "unsafe". libsync/mutex and once: names of static variables should be in upper case. libterm: introduce a helper function to effectively remove invocations of a deprecated method. We still see a few warnings about using obsoleted native::task::spawn() in the test modules for libsync. I'm not sure how I should replace them with std::task::TaksBuilder and native::task::NativeTaskBuilder (dependency to libstd?) Signed-off-by: NODA, Kai <nodakai@gmail.com>
2014-10-09std: Convert statics to constantsAlex Crichton-17/+17
This commit repurposes most statics as constants in the standard library itself, with the exception of TLS keys which precisely have their own memory location as an implementation detail. This commit also rewrites the bitflags syntax to use `const` instead of `static`. All invocations will need to replace the word `static` with `const` when declaring flags. Due to the modification of the `bitflags!` syntax, this is a: [breaking-change]
2014-10-06Remove the #[allow(non_uppercase_statics)] attr from bitflags!P1start-23/+18
2014-10-03Set the `non_uppercase_statics` lint to warn by defaultP1start-2/+8
2014-09-25Added bitflag toggling.Clark Gaebel-5/+25
2014-09-22auto merge of #17339 : treeman/rust/doc-things, r=alexcrichtonbors-4/+4
Also some cleanup to conform to documentation style.
2014-09-19std: Don't require bitflags! be u32Alex Crichton-1/+7
If you didn't have a trailing comma at the end of the variants, you could use any type you wanted, but if you used a trailing comma the macro would erroneously require the bits be a u32.
2014-09-17doc: Cleanup.Jonas Hietala-4/+4
Remove ~~~ for code block specification. Use /// Over /** */ for doc blocks.
2014-09-14inlines contains in bitflags!Felix Raimundo-0/+1
Closes #17210
2014-09-05Use {} for bitflags! definition and invocationsBrendan Zabarauskas-14/+14
This looks nicer because it reflects Rust's other syntactic structures.
2014-09-05Attach documentation to the bitflags! macro itselfBrendan Zabarauskas-97/+98
This is in consistent with the style demonstrated in the std::macros module.
2014-09-05Test attributesBrendan Zabarauskas-0/+8
2014-09-05Allow trailing commas in bitflags! macroBrendan Zabarauskas-4/+14
2014-07-30Derive PartialOrd, Ord and Hash for bitflags types.nham-1/+40
In order to prevent users from having to manually implement Hash and Ord for bitflags types, this commit derives these traits automatically. This breaks code that has manually implemented any of these traits for types created by the bitflags! macro. Change this code by removing implementations of these traits. [breaking-change]
2014-06-30libstd: set baseline stability levels.Aaron Turon-0/+1
Earlier commits have established a baseline of `experimental` stability for all crates under the facade (so their contents are considered experimental within libstd). Since `experimental` is `allow` by default, we should use the same baseline stability for libstd itself. This commit adds `experimental` tags to all of the modules defined in `std`, and `unstable` to `std` itself.
2014-06-01std: Drop Total from Total{Eq,Ord}Alex Crichton-1/+1
This completes the last stage of the renaming of the comparison hierarchy of traits. This change renames TotalEq to Eq and TotalOrd to Ord. In the future the new Eq/Ord will be filled out with their appropriate methods, but for now this change is purely a renaming change. [breaking-change]
2014-05-30std: Rename {Eq,Ord} to Partial{Eq,Ord}Alex Crichton-2/+2
This is part of the ongoing renaming of the equality traits. See #12517 for more details. All code using Eq/Ord will temporarily need to move to Partial{Eq,Ord} or the Total{Eq,Ord} traits. The Total traits will soon be renamed to {Eq,Ord}. cc #12517 [breaking-change]
2014-05-15Updates with core::fmt changesAlex Crichton-1/+1
1. Wherever the `buf` field of a `Formatter` was used, the `Formatter` is used instead. 2. The usage of `write_fmt` is minimized as much as possible, the `write!` macro is preferred wherever possible. 3. Usage of `fmt::write` is minimized, favoring the `write!` macro instead.
2014-05-15Make `from_bits` in `bitflags!` safe; add `from_bits_truncate`Aaron Turon-7/+30
Previously, the `from_bits` function in the `std::bitflags::bitflags` macro was marked as unsafe, as it did not check that the bits being converted actually corresponded to flags. This patch changes the function to check against the full set of possible flags and return an `Option` which is `None` if a non-flag bit is set. It also adds a `from_bits_truncate` function which simply zeros any bits not corresponding to a flag. This addresses the concern raised in https://github.com/mozilla/rust/pull/13897
2014-05-14auto merge of #14009 : jcmoyer/rust/bitflags-complement, r=alexcrichtonbors-1/+31
I feel that this is a very vital, missing piece of functionality. This adds on to #13072. Only bits used in the definition of the bitflag are considered for the universe set. This is a bit safer than simply inverting all of the bits in the wrapped value. ```rust bitflags!(flags Flags: u32 { FlagA = 0x00000001, FlagB = 0x00000010, FlagC = 0x00000100, FlagABC = FlagA.bits | FlagB.bits | FlagC.bits }) ... // `Not` implements set complement assert!(!(FlagB | FlagC) == FlagA); // `all` and `is_all` are the inverses of `empty` and `is_empty` assert!(Flags::all() - FlagA == !FlagA); assert!(FlagABC.is_all()); ```
2014-05-14Implement set complement and universe for bitflagsJ.C. Moyer-1/+31
2014-05-13Add tests for from_bits.OGINO Masanori-0/+7
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-05-05Add (unsafe) coercion from bits to std::bitflagsAaron Turon-0/+6
The intent of `std::bitflags` is to allow building type-safe wrappers around C-style flags APIs. But in addition to construction these flags from the Rust side, we need a way to convert them from the C side. This patch adds a `from_bits` function, which is unsafe since the bits in question may not represent a valid combination of flags.
2014-05-05Allow attributes in std::bitflags::bitflags!Aaron Turon-25/+40
The `std::bitflags::bitflags!` macro did not provide support for adding attributes to the generated structure or flags, due to limitations in the parser for macros. This patch works around the parser limitations by requiring a `flags` keyword in the overall `bitflags!` invocation, and a `static` keyword for each flag: bitflags!( #[deriving(Hash)] #[doc="Three flags"] flags Flags: u32 { #[doc="The first flag"] static FlagA = 0x00000001, static FlagB = 0x00000010, static FlagC = 0x00000100 } )
2014-05-01remove leftover obsolete string literalsDaniel Micay-1/+1
2014-04-30Update for language changesBrendan Zabarauskas-1/+1
2014-04-30Move bitflags module to libstdBrendan Zabarauskas-0/+257
This will allow us to provide type-safe APIs in libstd that are C-compatible.