about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2014-03-07std: stop `vec!()` warning about unused mutability.Huon Wilson-3/+5
If no arguments are given to `vec!` then no pushes are emitted and so the compiler (rightly) complains that the mutability of `temp` is never used. This behaviour is rather annoying for users.
2014-03-06fix typos with with repeated words, just like this sentence.Kang Seonghoon-8/+8
2014-03-06auto merge of #12705 : alexcrichton/rust/issue-12692, r=brsonbors-3/+64
Details are in the commit messages, but this closes a few issues seen with `libnative` recently.
2014-03-05std: Move libnative task count bookkeeping to stdAlex Crichton-0/+56
When using tasks in Rust, the expectation is that the runtime does not exit before all tasks have exited. This is enforced in libgreen through the `SchedPool` type, and it is enforced in libnative through a `bookkeeping` module and a global count/mutex pair. Unfortunately, this means that a process which originates with libgreen will not wait for spawned native tasks. In order to fix this problem, the bookkeeping module was moved from libnative to libstd so the runtime itself can wait for native tasks to exit. Green tasks do not manage themselves through this bookkeeping module, but native tasks will continue to manage themselves through this module. Closes #12684
2014-03-05add tests for `min` and `max` from `Float`Daniel Micay-0/+24
2014-03-05native: Move from usleep() to nanosleep()Alex Crichton-0/+2
Using nanosleep() allows us to gracefully recover from EINTR because on error it fills in the second parameter with the remaining time to sleep. Closes #12689
2014-03-05native: Stop using readdir()Alex Crichton-3/+6
This function is not threadsafe, and is deprecated in favor of the threadsafe readdir_r variant. Closes #12692
2014-03-05auto merge of #12700 : thestinger/rust/float, r=cmrbors-89/+42
2014-03-05consistently use LLVM floating point intrinsicsDaniel Micay-87/+18
2014-03-05add correct floating point `min` and `max` methods.Daniel Micay-2/+24
The `std::cmp` functions are not correct for floating point types. `min(NaN, 2.0)` and `min(2.0, NaN)` return different values, because these functions assume a total order. Floating point types need special `min`, `max` and `clamp` functions.
2014-03-05Str::slice_chars() is O(end), not O(end - begin)Simon Sapin-2/+2
2014-03-04auto merge of #12491 : eddyb/rust/deref, r=nikomatsakisbors-3/+54
Add the `Deref` and `DerefMut` traits and implement overloading explicit dereferences.
2014-03-04auto merge of #12300 : DaGenix/rust/uppercase-variable-lint, r=alexcrichtonbors-25/+26
I added a new lint for variables whose names contain uppercase characters, since, by convention, variable names should be all lowercase. What motivated me to work on this was when I ran into something like the following: ```rust use std::io::File; use std::io::IoError; fn main() { let mut f = File::open(&Path::new("/something.txt")); let mut buff = [0u8, ..16]; match f.read(buff) { Ok(cnt) => println!("read this many bytes: {}", cnt), Err(IoError{ kind: EndOfFile, .. }) => println!("Got end of file: {}", EndOfFile.to_str()), } } ``` I then got compile errors when I tried to add a wildcard match pattern at the end which I found very confusing since I believed that the 2nd match arm was only matching the EndOfFile condition. The problem is that I hadn't imported io::EndOfFile into the local scope. So, I thought that I was using EndOfFile as a sub-pattern, however, what I was actually doing was creating a new local variable named EndOfFile. This lint makes this error easier to spot by providing a warning that the variable name EndOfFile contains a uppercase characters which provides a nice hint as to why the code isn't doing what is intended. The lint warns on local bindings as well: ```rust let Hi = 0; ``` And also struct fields: ```rust struct Something { X: uint } ```
2014-03-05Allow uppercase_variables in libstd/libc.rsPalmer Cox-0/+1
2014-03-04Rename struct fields with uppercase characters in their names to use lowercasePalmer Cox-4/+4
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 #12697 : thestinger/rust/vec, r=huonwbors-0/+1
This exists for the sake of compatibility during the ~[T] -> Vec<T> transition. It will be removed in the future.
2014-03-04mark the `map` method on Vec<T> as deprecatedDaniel Micay-0/+1
This exists for the sake of compatibility during the ~[T] -> Vec<T> transition. It will be removed in the future.
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-04Implement DerefImm for Rc and DerefImm/DerefMut for RefCell's Ref/RefMut.Eduard Burtescu-2/+31
2014-03-04Add the DerefImm and DerefMut traits.Eduard Burtescu-1/+23
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.