about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2014-03-04Rename all variables that have uppercase characters in their names to use ↵Palmer Cox-22/+22
only lowercase characters
2014-03-04auto merge of #12694 : thestinger/rust/mut_iter, r=huonwbors-9/+19
This become `Pod` when it was switched to using marker types.
2014-03-04make `MutItems` iterator sound againDaniel Micay-9/+19
This become `Pod` when it was switched to using marker types.
2014-03-04auto merge of #12667 : Kimundi/rust/any_improv, r=cmrbors-119/+56
- Added `TraitObject` representation to `std::raw`. - Added doc to `std::raw`. - Removed `Any::as_void_ptr()` and `Any::as_mut_void_ptr()` methods as they are uneccessary now after the removal of headers on owned boxes. This reduces the number of virtual calls needed from 2 to 1. - Made the `..Ext` implementations work directly with the repr of a trait object. - Removed `Any`-related traits from the prelude. - Added bench. Bench before/after: ~~~ 7 ns/iter (+/- 0) 4 ns/iter (+/- 0) ~~~
2014-03-04Cleaned up `std::any`Marvin Löbel-119/+56
- Added `TraitObject` representation to `std::raw`. - Added doc to `std::raw`. - Removed `Any::as_void_ptr()` and `Any::as_mut_void_ptr()` methods as they are uneccessary now after the removal of headers on owned boxes. This reduces the number of virtual calls needed. - Made the `..Ext` implementations work directly with the repr of a trait object. - Removed `Any`-related traits from the prelude. - Added bench for `Any`
2014-03-04doc: use the newer faviconAdrien Tétar-1/+1
2014-03-04std: add reserve_additional and an Extendable impl to Vec.Huon Wilson-2/+66
2014-03-01libsyntax: Fix errors arising from the automated `~[T]` conversionPatrick Walton-0/+27
2014-03-01libstd: Add some functionality to `Vec<T>`Patrick Walton-1/+37
2014-03-01std: Switch stdout/stderr to buffered by defaultAlex Crichton-10/+32
Similarly to #12422 which made stdin buffered by default, this commit makes the output streams also buffered by default. Now that buffered writers will flush their contents when they are dropped, I don't believe that there's no reason why the output shouldn't be buffered by default, which is what you want in 90% of cases. As with stdin, there are new stdout_raw() and stderr_raw() functions to get unbuffered streams to stdout/stderr.
2014-03-01std: Flush when buffered writers are droppedAlex Crichton-14/+25
It's still not entirely clear what should happen if there was an error when flushing, but I'm deferring that decision to #12628. I believe that it's crucial for the usefulness of buffered writers to be able to flush on drop. It's just too easy to forget to flush them in small one-off use cases. cc #12628
2014-02-28std: Change assert_eq!() to use {} instead of {:?}Alex Crichton-183/+189
Formatting via reflection has been a little questionable for some time now, and it's a little unfortunate that one of the standard macros will silently use reflection when you weren't expecting it. This adds small bits of code bloat to libraries, as well as not always being necessary. In light of this information, this commit switches assert_eq!() to using {} in the error message instead of {:?}. In updating existing code, there were a few error cases that I encountered: * It's impossible to define Show for [T, ..N]. I think DST will alleviate this because we can define Show for [T]. * A few types here and there just needed a #[deriving(Show)] * Type parameters needed a Show bound, I often moved this to `assert!(a == b)` * `Path` doesn't implement `Show`, so assert_eq!() cannot be used on two paths. I don't think this is much of a regression though because {:?} on paths looks awful (it's a byte array). Concretely speaking, this shaved 10K off a 656K binary. Not a lot, but sometime significant for smaller binaries.
2014-02-28auto merge of #12616 : alexcrichton/rust/size, r=huonwbors-112/+117
I've been playing around with code size when linking to libstd recently, and these were some findings I found that really helped code size. I started out by eliminating all I/O implementations from libnative and instead just return an unimplemented error. In doing so, a `fn main() {}` executable was ~378K before this patch, and about 170K after the patch. These size wins are all pretty minor, but they all seemed pretty reasonable to me. With native I/O not stubbed out, this takes the size of an LTO executable from 675K to 400K.
2014-02-28std: Flag run_fmt() as #[inline(always)]Alex Crichton-1/+8
This function is a tiny wrapper that LLVM doesn't want to inline, and it ends up causing more bloat than necessary. The bloat is pretty small, but it's a win of at least 7k for small executables, and I imagine that the number goes up as there are more calls to fail!().
2014-02-28std: Avoid using "{:?}" in format stringsAlex Crichton-5/+5
This removes all usage of Poly in format strings from libstd. This doesn't prevent more future strings from coming in, but it at least removes the ones for now.
2014-02-28std: Remove lots of allocations from log settingsAlex Crichton-102/+96
Most of these are unnecessary because we're only looking at static strings. This also moves to Vec in a few places instead of ~[T]. This didn't end up getting much of a code size win (update_log_settings is the third largest function in the executables I'm looking at), but this seems like a generally nice improvement regardless.
2014-02-28std: Improve some I/O documentationAlex Crichton-33/+188
This lowers the #[allow(missing_doc)] directive into some of the lower modules which are less mature. Most I/O modules now require comprehensive documentation.
2014-02-28std: Add cfg(test) to UnsafeArc assertionsAlex Crichton-4/+8
This is a ubiquitous type in concurrent code, and the assertions are causing significant code bloat for simple operations such as reading the pointer (injecting a failure point, etc). I am testing executable sizes with no I/O implementations (everything stubbed out to return nothing), and this took the size of a libnative executable from 328K to 207K (37% reduction in size), so I think that this is one assertion that's well worth configuring off for now.
2014-02-28auto merge of #12622 : pnkfelix/rust/fsk-improve-vec-partition-doc, r=huonwbors-6/+5
Explicitly note in vec `partition` and `partitioned` that the left and right parts each map to satisfying and non-satisfying elements.
2014-02-28Improve vec `partition` and `partitioned` method doc.Felix S. Klock II-6/+5
Explicitly note in vec `partition` and `partitioned` that the left and right parts each map to satisfying and non-satisfying elements.
2014-03-01Publicise types/add #[allow(visible_private_types)] to a variety of places.Huon Wilson-2/+5
There's a lot of these types in the compiler libraries, and a few of the older or private stdlib ones. Some types are obviously meant to be public, others not so much.
2014-02-28auto merge of #12544 : erickt/rust/hash, r=acrichtobors-9/+42
This PR allows `HashMap`s to work with custom hashers. Also with this patch are: * a couple generic implementations of `Hash` for a variety of types. * added `Default`, `Clone` impls to the hashers. * added a `HashMap::with_hasher()` constructor.
2014-02-27auto merge of #12614 : alexcrichton/rust/rollup, r=alexcrichtonbors-19/+112
Closes #12546 (Add new target 'make dist-osx' to create a .pkg installer for OS X) r=brson Closes #12575 (rustc: Move local native libs back in link-args) r=brson Closes #12587 (Provide a more helpful error for tests that fail due to noexec) r=brson Closes #12589 (rustc: Remove codemap and reachable from metadata encoder) r=alexcrichton Closes #12591 (Fix syntax::ext::deriving{,::*} docs formatting.) r=huonw Closes #12592 (Miscellaneous Vim improvements) r=alexcrichton Closes #12596 (path: Implement windows::make_non_verbatim()) r=alexcrichton Closes #12598 (Improve the ctags function regular expression) r=alexcrichton Closes #12599 (Tutorial improvement (new variant of PR #12472).) r=pnkfelix Closes #12603 (std: Export the select! macro) r=pcwalton Closes #12605 (Fix typo in doc of Binary trait in std::fmt) r=alexcrichton Closes #12613 (Fix bytepos_to_file_charpos) r=brson
2014-02-27auto merge of #12348 : brunoabinader/rust/libcollections-list-refactory, ↵bors-0/+9
r=alexcrichton This PR includes: - Create an iterator for ```List<T>``` called ```Items<T>```; - Move all list operations inside ```List<T>``` impl; - Removed functions that are already provided by ```Iterator``` trait; - Refactor on ```len()``` and ```is_empty``` using ```Container``` trait; - Bunch of minor fixes; A replacement for using @ is intended, but still in discussion. Closes #12344.
2014-02-27Fix typo in doc of Binary trait in std::fmtMickaël Delahaye-1/+1
2014-02-27std: Export the select! macroAlex Crichton-16/+44
Mark it as #[experimental] for now. In theory this attribute will be read in the future. I believe that the implementation is solid enough for general use, although I would not be surprised if there were bugs in it still. I think that it's at the point now where public usage of it will start to uncover hopefully the last few remaining bugs. Closes #12044
2014-02-27path: Implement windows::make_non_verbatim()Kevin Ballard-0/+66
make_non_verbatim() takes a WindowsPath and returns a new one that does not use the \\?\ verbatim prefix, if possible.
2014-02-27path: clean up some lint warnings and an obsolete commentKevin Ballard-2/+1
Get rid of the unnecessary parenthesies that crept into some macros. Remove a FIXME that was already fixed. Fix a comment that wasn't rendering correctly in rustdoc.
2014-02-27std: cut down on the memory usage of `SipHasher`Erick Tryzelaar-6/+6
2014-02-27collections: allow `HashMap` to work with generic hashersErick Tryzelaar-9/+42
2014-02-27native: Recognize EISDIRAlex Crichton-0/+1
This recognizes the EISDIR error code on both windows and unix platforms to provide a more descriptive error condition.
2014-02-27rustc: Use libnative for the compilerAlex Crichton-1/+1
The compiler itself doesn't necessarily need any features of green threading such as spawning tasks and lots of I/O, so libnative is slightly more appropriate for rustc to use itself. This should also help the rusti bot which is currently incompatible with libuv.
2014-02-27native: Improve windows file handlingAlex Crichton-0/+21
This commit splits the file implementation into file_unix and file_win32. The two implementations have diverged to the point that they share almost 0 code at this point, so it's easier to maintain as separate files. The other major change accompanied with this commit is that file::open is no longer based on libc's open function on windows, but rather windows's CreateFile function. This fixes dealing with binary files on windows (test added in previous commit). This also changes the read/write functions to use ReadFile and WriteFile instead of libc's read/write. Closes #12406
2014-02-27std: Small cleanup and test improvementAlex Crichton-158/+182
This weeds out a bunch of warnings building stdtest on windows, and it also adds a check! macro to the io::fs tests to help diagnose errors that are cropping up on windows platforms as well. cc #12516
2014-02-27Implement Eq for Cell<T>Bruno de Oliveira Abinader-0/+9
2014-02-26auto merge of #12490 : zslayton/rust/doc-fix-12386, r=alexcrichtonbors-19/+9
Attn: @huonw Addresses #12386.
2014-02-25auto merge of #12505 : alexcrichton/rust/fix-stack-overflow, r=brsonbors-5/+10
The printing of the error message on stack overflow had two sometimes false assumptions previously. The first is that a local task was always available (it called Local::take) and the second is that it used `println!` instead of manually writing. The first assumption isn't necessarily true because while stack overflow will likely only be detected in situations that a local task is available, it's not guaranteed to always be in TLS. For example, during a `println!` call a task may be blocking, causing it to be unavailable. By using Local::try_take(), we can be resilient against these occurrences. The second assumption could lead to odd behavior because the stdout logger can be overwritten to run arbitrary code. Currently this should be possible, but the utility is much diminished because a stack overflow translates to an abort() instead of a failure.
2014-02-25std: Tweak stack overflow printing for robustnessAlex Crichton-5/+10
The printing of the error message on stack overflow had two sometimes false assumptions previously. The first is that a local task was always available (it called Local::take) and the second is that it used println! instead of manually writing. The first assumption isn't necessarily true because while stack overflow will likely only be detected in situations that a local task is available, it's not guaranteed to always be in TLS. For example, during a println! call a task may be blocking, causing it to be unavailable. By using Local::try_take(), we can be resilient against these occurrences. The second assumption could lead to odd behavior because the stdout logger can be overwritten to run arbitrary code. Currently this should be possible, but the utility is much diminished because a stack overflow translates to an abort() instead of a failure.
2014-02-25Add a method of manually specifying the crate mapAlex Crichton-8/+43
Apparently weak linkage and dlopen aren't quite working out for applications like servo on android. There appears to be a bug or two in how android loads dynamic libraries and for some reason libservo.so isn't being found. As a temporary solution, add an extern "C" function to libstd which can be called if you have a handle to the crate map manually. When crawling the crate map, we then check this manual symbol before falling back to the old solutions. cc #11731
2014-02-25auto merge of #12522 : erickt/rust/hash, r=alexcrichtonbors-11/+1
This patch series does a couple things: * replaces manual `Hash` implementations with `#[deriving(Hash)]` * adds `Hash` back to `std::prelude` * minor cleanup of whitespace and variable names.
2014-02-25auto merge of #12525 : eddyb/rust/gate-default-type-param-usage, r=alexcrichtonbors-0/+2
Also reverted `#[deriving(Hash)]` to implement `Hash` only for `SipState`, until we decide what to do about default type params.
2014-02-25Remove std::bool::{Bool, all_values}Brendan Zabarauskas-162/+43
These were never used outside of the tests
2014-02-24Remove std::num::ToStrRadix from the preludeBrendan Zabarauskas-2/+4
2014-02-24Remove std::from_str::FromStr from the preludeBrendan Zabarauskas-1/+14
2014-02-24Remove std::default::Default from the preludeBrendan Zabarauskas-1/+2
2014-02-24std: Add Vec.reserve for rounding-up reservation.Huon Wilson-1/+8
`.reserve_exact` can cause pathological O(n^2) behaviour, so providing a `.reserve` that ensures that capacity doubles (if you step 1, 2, ..., n) is more efficient. cc #11949
2014-02-24std: make .swap_remove return Option<T>.Huon Wilson-26/+34
This is one of the last raw "indexing" method on vectors that returns `T` instead of the Option.
2014-02-24replace manual Hash impls with `#[deriving(Hash)]`Erick Tryzelaar-9/+1
2014-02-24std: minor whitespace cleanupErick Tryzelaar-2/+0
2014-02-24auto merge of #12445 : huonw/rust/less-unsafe, r=alexcrichtonbors-8/+4
Commits for details. Highlights: - `flate` returns `CVec<u8>` to save reallocating a whole new `&[u8]` - a lot of `transmute`s removed outright or replaced with `as` (etc.)