summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2014-03-13auto merge of #12573 : lbonn/rust/unrecurs, r=alexcrichtonbors-11/+85
As mentioned in #6109, ```mkdir_recursive``` doesn't really need to use recursive calls, so here is an iterative version. The other points of the proposed overhaul (renaming and existing permissions) still need to be resolved. I also bundled an iterative ```rmdir_recursive```, for the same reason. Please do not hesitate to provide feedback on style as this is my first code change in rust.
2014-03-13auto merge of #12561 : pzol/rust/char-case, r=alexcrichtonbors-1388/+1115
Added common and simple case folding, i.e. mapping one to one character mapping. For more information see http://www.unicode.org/faq/casemap_charprop.html Removed auto-generated dead code which wasn't used.
2014-03-13auto merge of #12238 : ktt3ja/rust/lifetime-error-msg, r=nikomatsakisbors-0/+29
For the following code snippet: ```rust struct Foo { bar: int } fn foo1(x: &Foo) -> &int { &x.bar } ``` This PR generates the following error message: ```rust test.rs:2:1: 4:2 note: consider using an explicit lifetime parameter as shown: fn foo1<'a>(x: &'a Foo) -> &'a int test.rs:2 fn foo1(x: &Foo) -> &int { test.rs:3 &x.bar test.rs:4 } test.rs:3:5: 3:11 error: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements test.rs:3 &x.bar ^~~~~~ ``` Currently it does not support methods.
2014-03-13auto merge of #12610 : eddyb/rust/deref-now-auto, r=nikomatsakisbors-24/+19
Enables the dereference overloads introduced by #12491 to be applied wherever automatic dereferences would be used (field accesses, method calls and indexing).
2014-03-13Remove Rc's borrow method to avoid conflicts with RefCell's borrow in ↵Eduard Burtescu-24/+19
Rc<RefCell<T>>.
2014-03-13auto merge of #12845 : eddyb/rust/vec-no-drop-flag, r=thestingerbors-0/+50
2014-03-13Remove code duplicationPiotr Zolnierek-52/+32
Remove whitespace Update documentation for to_uppercase, to_lowercase
2014-03-13Implement lower, upper case conversion for charPiotr Zolnierek-1/+1088
2014-03-13std::unicode: remove unused category tablesPiotr Zolnierek-1340/+0
2014-03-13auto merge of #12602 : alexcrichton/rust/backtrace, r=brsonbors-100/+914
Whenever a failure happens, if a program is run with `RUST_LOG=std::rt::backtrace` a backtrace will be printed to the task's stderr handle. Stack traces are uncondtionally printed on double-failure and rtabort!(). This ended up having a nontrivial implementation, and here's some highlights of it: * We're bundling libbacktrace for everything but OSX and Windows * We use libgcc_s and its libunwind apis to get a backtrace of instruction pointers * On OSX we use dladdr() to go from an instruction pointer to a symbol * On unix that isn't OSX, we use libbacktrace to get symbols * Windows, as usual, has an entirely separate implementation Lots more fun details and comments can be found in the source itself. Closes #10128
2014-03-13Add basic backtrace functionalityAlex Crichton-100/+914
Whenever a failure happens, if a program is run with `RUST_LOG=std::rt::backtrace` a backtrace will be printed to the task's stderr handle. Stack traces are uncondtionally printed on double-failure and rtabort!(). This ended up having a nontrivial implementation, and here's some highlights of it: * We're bundling libbacktrace for everything but OSX and Windows * We use libgcc_s and its libunwind apis to get a backtrace of instruction pointers * On OSX we use dladdr() to go from an instruction pointer to a symbol * On unix that isn't OSX, we use libbacktrace to get symbols * Windows, as usual, has an entirely separate implementation Lots more fun details and comments can be found in the source itself. Closes #10128
2014-03-12auto merge of #12414 : DaGenix/rust/failing-iterator-wrappers, r=alexcrichtonbors-46/+53
Most IO related functions return an IoResult so that the caller can handle failure in whatever way is appropriate. However, the `lines`, `bytes`, and `chars` iterators all supress errors. This means that code that needs to handle errors can't use any of these iterators. All three of these iterators were updated to produce IoResults. Fixes #12368
2014-03-12auto merge of #12822 : erickt/rust/cleanup, r=acrichtobors-7/+9
This PR makes `std::io::FileStat` hashable, and `Path` serializable as a byte array.
2014-03-12Update io iterators to produce IoResultsPalmer Cox-46/+53
Most IO related functions return an IoResult so that the caller can handle failure in whatever way is appropriate. However, the `lines`, `bytes`, and `chars` iterators all supress errors. This means that code that needs to handle errors can't use any of these iterators. All three of these iterators were updated to produce IoResults. Fixes #12368
2014-03-12auto merge of #12756 : pongad/rust/remove_owned_str_pat, r=alexcrichtonbors-4/+4
match-drop-strs-issue-4541.rs deleted as it's the same with issue-4541.rs
2014-03-12std: allow io::File* structs to be hashableErick Tryzelaar-7/+9
2014-03-12rustc: Remove matching on ~str from the languageMichael Darakananda-4/+4
The `~str` type is not long for this world as it will be superseded by the soon-to-come DST changes for the language. The new type will be `~Str`, and matching over the allocation will no longer be supported. Matching on `&str` will continue to work, in both a pre and post DST world.
2014-03-12Remove remaining nolink usages.(fixes #12810)lpy-28/+0
2014-03-12Use generic impls for `Hash`Erick Tryzelaar-12/+15
2014-03-12doc: discuss try! in std::ioPeter Marheine-0/+34
2014-03-12std: Relax an assertion in oneshot selectionAlex Crichton-7/+64
The assertion was erroneously ensuring that there was no data on the port when the port had selection aborted on it. This assertion was written in error because it's possible for data to be waiting on a port, even after it was disconnected. When aborting selection, if we see that there's data on the port, then we return true that data is available on the port. Closes #12802
2014-03-12Vec: remove the drop flag to make it no larger than (*T, uint, uint).Eduard Burtescu-0/+50
2014-03-12Add shift and remove methods for VecKiet Tran-0/+29
2014-03-12auto merge of #12797 : pczarn/rust/str_safety, r=huonwbors-51/+75
Along the lines of `shift_ref` and `pop_ref`.
2014-03-12Port partition method from ~[T] to Vec<T>, for use early-late lifetime code.Felix S. Klock II-0/+20
2014-03-12rand: deprecate `rng`.Huon Wilson-1/+1
This should be called far less than it is because it does expensive OS interactions and seeding of the internal RNG, `task_rng` amortises this cost. The main problem is the name is so short and suggestive. The direct equivalent is `StdRng::new`, which does precisely the same thing. The deprecation will make migrating away from the function easier.
2014-03-12Remove the dependence of std::io::test on rand.Huon Wilson-4/+11
This replaces it with a manual "task rng" using XorShift and a crappy seeding mechanism. Theoretically good enough for the purposes though (unique for tests).
2014-03-12std: Move rand to librand.Huon Wilson-3888/+2
This functionality is not super-core and so doesn't need to be included in std. It's possible that std may need rand (it does a little bit now, for io::test) in which case the functionality required could be moved to a secret hidden module and reexposed by librand. Unfortunately, using #[deprecated] here is hard: there's too much to mock to make it feasible, since we have to ensure that programs still typecheck to reach the linting phase.
2014-03-11auto merge of #12556 : alexcrichton/rust/weak-linkage, r=brsonbors-40/+28
It is often convenient to have forms of weak linkage or other various types of linkage. Sadly, just using these flavors of linkage are not compatible with Rust's typesystem and how it considers some pointers to be non-null. As a compromise, this commit adds support for weak linkage to external symbols, but it requires that this is only placed on extern statics of type `*T`. Codegen-wise, we get translations like: ```rust // rust code extern { #[linkage = "extern_weak"] static foo: *i32; } // generated IR @foo = extern_weak global i32 @_some_internal_symbol = internal global *i32 @foo ``` All references to the rust value of `foo` then reference `_some_internal_symbol` instead of the symbol `_foo` itself. This allows us to guarantee that the address of `foo` will never be null while the value may sometimes be null. An example was implemented in `std::rt::thread` to determine if `__pthread_get_minstack()` is available at runtime, and a test is checked in to use it for a static value as well. Function pointers a little odd because you still need to transmute the pointer value to a function pointer, but it's thankfully better than not having this capability at all. Thanks to @bnoordhuis for the original patch, most of this work is still his!
2014-03-11rustc: Support various flavors of linkagesAlex Crichton-40/+28
It is often convenient to have forms of weak linkage or other various types of linkage. Sadly, just using these flavors of linkage are not compatible with Rust's typesystem and how it considers some pointers to be non-null. As a compromise, this commit adds support for weak linkage to external symbols, but it requires that this is only placed on extern statics of type `*T`. Codegen-wise, we get translations like: // rust code extern { #[linkage = "extern_weak"] static foo: *i32; } // generated IR @foo = extern_weak global i32 @_some_internal_symbol = internal global *i32 @foo All references to the rust value of `foo` then reference `_some_internal_symbol` instead of the symbol `_foo` itself. This allows us to guarantee that the address of `foo` will never be null while the value may sometimes be null. An example was implemented in `std::rt::thread` to determine if `__pthread_get_minstack()` is available at runtime, and a test is checked in to use it for a static value as well. Function pointers a little odd because you still need to transmute the pointer value to a function pointer, but it's thankfully better than not having this capability at all.
2014-03-11Add an ItemModifier syntax extension typeSteven Fackler-0/+15
Where ItemDecorator creates new items given a single item, ItemModifier alters the tagged item in place. The expansion rules for this are a bit weird, but I think are the most reasonable option available. When an item is expanded, all ItemModifier attributes are stripped from it and the item is folded through all ItemModifiers. At that point, the process repeats until there are no ItemModifiers in the new item.
2014-03-10fs: units tests for mkdir_recusive and rmdir_recursiveLaurent Bonnans-0/+26
The rmdir test is blocked by #12795 on windows.
2014-03-10fs: use an iterative algorithm for 'rmdir_recursive'Laurent Bonnans-8/+41
For now, the windows version uses stat, just as before. We should switch back to lstat as soon as #12795 is closed.
2014-03-10fs: use an iterative algorithm for 'mkdir_recursive'Laurent Bonnans-3/+18
as requested in #6109
2014-03-10libstd: Update docs for `slice_shift_char` and {shift,pop}_{char,byte}Piotr Czarnecki-17/+10
2014-03-10libstd: Add unit tests for `slice_shift_char`Piotr Czarnecki-0/+12
2014-03-10libstd: Change `slice_shift_char`, `shift_char`, `pop_char`, `shift_byte` ↵Piotr Czarnecki-34/+53
and `pop_byte` to return an Option instead of failing
2014-03-08auto merge of #12706 : pongad/rust/issue_12698, r=brsonbors-209/+20
Fixes #12698
2014-03-08auto merge of #12759 : lucab/rust/char-doc, r=alexcrichtonbors-29/+60
This is mostly a reaction to #12730. If we are going to keep calling them `char`, at least make it clear that they aren't characters but codepoint/scalar.
2014-03-08Incorporated review feedback atop pcwalton's original patches.Felix S. Klock II-11/+9
(Original PR was #12716; feedback was provided by thestinger and me.)
2014-03-08Removed DeepClone. Issue #12698.Michael Darakananda-209/+20
2014-03-08libstd: Add some more functionality to Vec<T>Patrick Walton-0/+131
2014-03-08doc: add two missing char methods doc-stringsLuca Bruno-2/+12
XID_* property are defined in UAX #31, just reference it here. Signed-off-by: Luca Bruno <lucab@debian.org>
2014-03-08doc: uniform std::char doc-stringsLuca Bruno-23/+30
Uniform and beautify doc-string for current rustdoc output. Signed-off-by: Luca Bruno <lucab@debian.org>
2014-03-08doc: don't refer to 'char' as charactersLuca Bruno-18/+32
This seems to be causing some confusion among users. Rust's char are not 8bit characters, but 32bit UCS-4 codepoint without surrogates (Unicode Scalar Values as per Unicode glossary). Make the doc more explicit about it. Signed-off-by: Luca Bruno <lucab@debian.org>
2014-03-07create a sensible comparison trait hierarchyDaniel Micay-18/+33
* `Ord` inherits from `Eq` * `TotalOrd` inherits from `TotalEq` * `TotalOrd` inherits from `Ord` * `TotalEq` inherits from `Eq` This is a partial implementation of #12517.
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