about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2015-03-04Auto merge of #22920 - tshepang:remove-some-warnings, r=huonwbors-8/+6
2015-03-03Switched to Box::new in many places.Felix S. Klock II-8/+11
Many of the modifications putting in `Box::new` calls also include a pointer to Issue 22405, which tracks going back to `box <expr>` if possible in the future. (Still tried to use `Box<_>` where it sufficed; thus some tests still have `box_syntax` enabled, as they use a mix of `box` and `Box::new`.) Precursor for overloaded-`box` and placement-`in`; see Issue 22181.
2015-03-03Add `: Box<_>` or `::Box<_>` type annotations to various places.Felix S. Klock II-13/+13
This is the kind of change that one is expected to need to make to accommodate overloaded-`box`. ---- Note that this is not *all* of the changes necessary to accommodate Issue 22181. It is merely the subset of those cases where there was already a let-binding in place that made it easy to add the necesasry type ascription. (For unnamed intermediate `Box` values, one must go down a different route; `Box::new` is the option that maximizes portability, but has potential inefficiency depending on whether the call is inlined.) ---- There is one place worth note, `run-pass/coerce-match.rs`, where I used an ugly form of `Box<_>` type ascription where I would have preferred to use `Box::new` to accommodate overloaded-`box`. I deliberately did not use `Box::new` here, because that is already done in coerce-match-calls.rs. ---- Precursor for overloaded-`box` and placement-`in`; see Issue 22181.
2015-03-03Auto merge of #22532 - pnkfelix:arith-overflow, r=pnkfelix,eddybbors-40/+75
Rebase and follow-through on work done by @cmr and @aatch. Implements most of rust-lang/rfcs#560. Errors encountered from the checks during building were fixed. The checks for division, remainder and bit-shifting have not been implemented yet. See also PR #20795 cc @Aatch ; cc @nikomatsakis
2015-03-03sidestep potential over- and underflow in estimated stack bounds.Felix S. Klock II-1/+15
See buildlog here for evidence of such occurring: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/3910/steps/test/logs/stdio
2015-03-03Revert incorrect `usize` -> `u32` replacements from #22510Tobias Bucher-6/+6
Conflicts: src/libstd/thread.rs
2015-03-03Rollup merge of #22974 - nagisa:reintuint-std, r=alexcrichtonManish Goregaokar-0/+1
Reverts a small part of c74d49c804c3 because compilation pukes with warnings now.
2015-03-03Rollup merge of #22956 - ejjeong:aarch64-linux-android, r=alexcrichtonManish Goregaokar-1/+1
aarch64-linux-android build has been broken since #22839. Aarch64 android has _Unwind_GetIPInfo, so re-define this only for arm32 android. r? @alexcrichton
2015-03-03Rollup merge of #22876 - Florob:const, r=nikomatsakisManish Goregaokar-24/+23
This changes the type of some public constants/statics in libunicode. Notably some `&'static &'static [(char, char)]` have changed to `&'static [(char, char)]`. The regexp crate seems to be the sole user of these, yet this is technically a [breaking-change]
2015-03-03Rollup merge of #22943 - ipetkov:lint-recursion, r=alexcrichtonManish Goregaokar-14/+16
* The lint visitor's visit_ty method did not recurse, and had a reference to the now closed #10894 * The newly enabled recursion has only affected the `deprectated` lint which now detects uses of deprecated items in trait impls and function return types * Renamed some references to `CowString` and `CowVec` to `Cow<str>` and `Cow<[T]>`, respectively, which appear outside of the crate which defines them * Replaced a few instances of `InvariantType<T>` with `PhantomData<Cell<T>>` * Disabled the `deprecated` lint in several places that reference/implement traits on deprecated items which will get cleaned up in the future * Unfortunately, this means that if a library declares `#![deny(deprecated)]` and marks anything as deprecated, it will have to disable the lint for any uses of said item, e.g. any impl the now deprecated item For any library that denies deprecated items but has deprecated items of its own, this is a [breaking-change] I had originally intended for the lint to ignore uses of deprecated items that are declared in the same crate, but this goes against some previous test cases that expect the lint to capture *all* uses of deprecated items, so I maintained the previous approach to avoid changing the expected behavior of the lint. Tested locally on OS X, so hopefully there aren't any deprecated item uses behind a `cfg` that I may have missed.
2015-03-03Fix backtrace tests for LinuxManish Goregaokar-1/+1
2015-03-03Accommodate arith-overflow in `rand` and `std::rand`.Felix S. Klock II-2/+2
Regarding the `rand` changes: It is unfortunate that Wrapping(T) does not support the `+=` operator. We may want to try to fix that before 1.0 to make porting code like this palatable. Regarding `std::rand`, just arith-overflow in first example from `std::rand::random()` doc.
2015-03-03Accommodate arith-overflow in `core::num`, `std::num`, `coretest::num`.Felix S. Klock II-12/+13
* `core::num`: adjust `UnsignedInt::is_power_of_two`, `UnsignedInt::next_power_of_two`, `Int::pow`. In particular for `Int::pow`: (1.) do not panic when `base` overflows if `acc` never observes the overflowed `base`, and (2.) if `acc` does observe the overflowed `base`, make sure we only panic if we would have otherwise (e.g. during a computation of `base * base`). * also in `core::num`: avoid underflow during computation of `uint::MAX`. * `std::num`: adjust tests `uint::test_uint_from_str_overflow`, `uint::test_uint_to_str_overflow`, `strconv` * `coretest::num`: adjust `test::test_int_from_str_overflow`.
2015-03-03Fixes to collections to accommodate arith-overflow changes.Felix S. Klock II-24/+30
* `collections::btree::node`: accommodate (transient) underflow. * `collections::btree::map`: avoid underflow during `fn next` for `BTreeMap::range` methods. * `collections::slice`: note that pnkfelix deliberately used `new_pos_wrapping` only once; the other cases of arithmetic do not over- nor underflow, which is a useful property to leave implicitly checked/documented via the remaining calls to `fn new_pos(..)`. * `collections::vec_deque` applied wrapping ops (somewhat blindly) to two implementation methods, and many tests. * `std::collections::hash::table` : Use `OverflowingOps` trait to track overflow during `calculate_offsets` and `calculate_allocation` functions.
2015-03-03Add `core::num::wrapping` and fix overflow errors.James Miller-1/+15
Many of the core rust libraries have places that rely on integer wrapping behaviour. These places have been altered to use the wrapping_* methods: * core::hash::sip - A number of macros * core::str - The `maximal_suffix` method in `TwoWaySearcher` * rustc::util::nodemap - Implementation of FnvHash * rustc_back::sha2 - A number of macros and other places * rand::isaac - Isaac64Rng, changed to use the Wrapping helper type Some places had "benign" underflow. This is when underflow or overflow occurs, but the unspecified value is not used due to other conditions. * collections::bit::Bitv - underflow when `self.nbits` is zero. * collections::hash::{map,table} - Underflow when searching an empty table. Did cause undefined behaviour in this case due to an out-of-bounds ptr::offset based on the underflowed index. However the resulting pointers would never be read from. * syntax::ext::deriving::encodable - Underflow when calculating the index of the last field in a variant with no fields. These cases were altered to avoid the underflow, often by moving the underflowing operation to a place where underflow could not happen. There was one case that relied on the fact that unsigned arithmetic and two's complement arithmetic are identical with wrapping semantics. This was changed to use the wrapping_* methods. Finally, the calculation of variant discriminants could overflow if the preceeding discriminant was `U64_MAX`. The logic in `rustc::middle::ty` for this was altered to avoid the overflow completely, while the remaining places were changed to use wrapping methods. This is because `rustc::middle::ty::enum_variants` now throws an error when the calculated discriminant value overflows a `u64`. This behaviour can be triggered by the following code: ``` enum Foo { A = U64_MAX, B } ``` This commit also implements the remaining integer operators for Wrapped<T>.
2015-03-03Auto merge of #22600 - brson:num, r=Gankrobors-12/+12
* count_ones/zeros, trailing_ones/zeros return u32, not usize * rotate_left/right take u32, not usize * RADIX, MANTISSA_DIGITS, DIGITS, BITS, BYTES are u32, not usize Doesn't touch pow because there's another PR for it. cc https://github.com/rust-lang/rust/issues/22240 r? @Gankro
2015-03-02core: Audit num module for int/uintBrian Anderson-12/+12
* count_ones/zeros, trailing_ones/zeros return u32, not usize * rotate_left/right take u32, not usize * RADIX, MANTISSA_DIGITS, DIGITS, BITS, BYTES are u32, not usize Doesn't touch pow because there's another PR for it. [breaking-change]
2015-03-02Enable recursion for visit_ty in lint visitorIvan Petkov-14/+16
* The lint visitor's visit_ty method did not recurse, and had a reference to the now closed #10894 * The newly enabled recursion has only affected the `deprectated` lint which now detects uses of deprecated items in trait impls and function return types * Renamed some references to `CowString` and `CowVec` to `Cow<str>` and `Cow<[T]>`, respectively, which appear outside of the crate which defines them * Replaced a few instances of `InvariantType<T>` with `PhantomData<Cell<T>>` * Disabled the `deprecated` lint in several places that reference/implement traits on deprecated items which will get cleaned up in the future * Disabled the `exceeding_bitshifts` lint for compile-fail/huge-array-simple test so it doesn't shadow the expected error on 32bit systems * Unfortunately, this means that if a library declares `#![deny(deprecated)]` and marks anything as deprecated, it will have to disable the lint for any uses of said item, e.g. any impl the now deprecated item For any library that denies deprecated items but has deprecated items of its own, this is a [breaking-change]
2015-03-02Auto merge of #22882 - alexcrichton:stabilize-process, r=aturonbors-15/+57
This commits blanket marks the API of the `std::process` module as `#[stable]`. The module's API is very similar to the old `std::old_io::process` API and has generally had quite a bit of time to bake both before and after the new module landed.
2015-03-02Readd int_uint feature to libstdSimonas Kazlauskas-0/+1
Reverts a small part of c74d49c804c3 because compilation pukes with warnings now.
2015-03-03Rollup merge of #22689 - tshepang:thread-doc-improvements, r=steveklabnikManish Goregaokar-22/+16
2015-03-02Use `const`s instead of `static`s where appropriateFlorian Zeitz-24/+23
This changes the type of some public constants/statics in libunicode. Notably some `&'static &'static [(char, char)]` have changed to `&'static [(char, char)]`. The regexp crate seems to be the sole user of these, yet this is technically a [breaking-change]
2015-03-02Auto merge of #22510 - GuillaumeGomez:audit-integer-libstd-thread, ↵bors-10/+10
r=alexcrichton Part of #22240.
2015-03-02Auto merge of #22797 - alexcrichton:io-stdio, r=aturonbors-6/+617
This is an implementation of RFC 899 and adds stdio functionality to the new `std::io` module. Details of the API can be found on the RFC, but from a high level: * `io::{stdin, stdout, stderr}` constructors are now available. There are also `*_raw` variants for unbuffered and unlocked access. * All handles are globally shared (excluding raw variants). * The stderr handle is no longer buffered. * All handles can be explicitly locked (excluding the raw variants). The `print!` and `println!` machinery has not yet been hooked up to these streams just yet. The `std::fmt::output` module has also not yet been implemented as part of this commit.
2015-03-02Fix broken aarch64 buildEunji Jeong-1/+1
2015-03-01std: Stabilize the `process` moduleAlex Crichton-15/+57
This commits blanket marks the API of the `std::process` module as `#[stable]`. The module's API is very similar to the old `std::old_io::process` API and has generally had quite a bit of time to bake both before and after the new module landed. The one modification made to the API is that `Stdio::capture` is now named `stdio::piped`. [breaking-change]
2015-03-01Replace int/uint by isize/usizeGuillaumeGomez-10/+10
2015-03-02Rollup merge of #22504 - GuillaumeGomez:audit-integer-libcore, r=ManishearthManish Goregaokar-3/+1
Part of #22240.
2015-03-01Auto merge of #22880 - alexcrichton:deprecate-io-extensions, r=huonwbors-0/+4
The `u64_from_be_bytes` and `u64_to_be_bytes` functions are being deprecated with no replacement for now. [breaking-change]
2015-03-01Remove int/uint from libstd/lib.rsGuillaume Gomez-2/+0
2015-03-01Auto merge of #22087 - GuillaumeGomez:int-pow, r=alexcrichtonbors-1/+1
Fixes issue #22016
2015-03-01remove some compiler warningsTshepang Lekhonkhobe-8/+6
2015-02-28std: Implement stdio for `std::io`Alex Crichton-6/+617
This is an implementation of RFC 899 and adds stdio functionality to the new `std::io` module. Details of the API can be found on the RFC, but from a high level: * `io::{stdin, stdout, stderr}` constructors are now available. There are also `*_raw` variants for unbuffered and unlocked access. * All handles are globally shared (excluding raw variants). * The stderr handle is no longer buffered. * All handles can be explicitly locked (excluding the raw variants). The `print!` and `println!` machinery has not yet been hooked up to these streams just yet. The `std::fmt::output` module has also not yet been implemented as part of this commit.
2015-03-01Fix errors, remove unused filesGuillaumeGomez-1/+1
2015-03-01Make Int::pow() take exp as u32 instead usizeGuillaume Gomez-1/+1
2015-02-28openbsd: adjust page guard addressSébastien Marie-1/+1
some commits in OpenBSD base have corrected a problem of stack position. Now, we can adjust more accurately the page guard in rust.
2015-02-28Rollup merge of #22884 - japaric:obsolete, r=alexcrichtonManish Goregaokar-2/+2
This is leftover from #21843 If you still have `|&:| {}` closures in your code, simply remove the `&:` part. [breaking-change]
2015-02-28Rollup merge of #22869 - alexcrichton:stabilize-env, r=aturonManish Goregaokar-183/+84
Now that the `std::env` module has had some time to bake this commit marks most of its APIs as `#[stable]`. Some notable APIs that are **not** stable (and still use the same `env` feature gate) are: * `{set,get}_exit_status` - there are still questions about whether this is the right interface for setting/getting the exit status of a process. * `page_size` - this may change location in the future or perhaps name as well. This also effectively closes #22122 as the variants of `VarError` are `#[stable]` now. (this is done intentionally)
2015-02-28Auto merge of #22839 - lifthrasiir:better-backtrace, r=alexcrichtonbors-10/+107
Fixes #20978 for supported platforms (i.e. non-Android POSIX). This uses `backtrace_pcinfo` to inspect the DWARF debug info and list the file and line pairs for given stack frame. Such pair is not unique due to the presence of inlined functions and the updated routine correctly handles this case. The code is modelled after libbacktrace's `backtrace_full` routine. There is one known issue with this approach. Macros, when invoked, take over the current frame and shadows the file and line pair which has invoked a macro. In particular, this makes many panicking macros a bit harder to inspect. This really is a debuginfo problem, and the backtrace routine should print them correctly with a correct debuginfo. Some example trace: ``` thread '<main>' panicked at 'explicit panic', /home/arachneng/Works/git/rust/src/test/run-pass/backtrace-debuginfo.rs:74 stack backtrace: 1: 0xd964702f - sys::backtrace::write::h32d93fffb64131b2yxC 2: 0xd9670202 - panicking::on_panic::h3a4fcb37b873aefeooM 3: 0xd95b396a - rt::unwind::begin_unwind_inner::h576b3df5f626902dJ2L 4: 0xd9eb88df - rt::unwind::begin_unwind::h16852273847167740350 5: 0xd9eb8afb - aux::callback::h15056955655605709172 at /home/arachneng/Works/git/rust/<std macros>:3 at src/test/run-pass/backtrace-debuginfo-aux.rs:15 6: 0xd9eb8caa - outer::h2cf96412459fceb6ema at src/test/run-pass/backtrace-debuginfo.rs:73 at src/test/run-pass/backtrace-debuginfo.rs:88 7: 0xd9ebab24 - main::h3f701287441442edasa at src/test/run-pass/backtrace-debuginfo.rs:134 8: 0xd96daba8 - rust_try_inner 9: 0xd96dab95 - rust_try 10: 0xd9671af4 - rt::lang_start::h7da0de9529b4c394liM 11: 0xd8f3aec4 - __libc_start_main 12: 0xd9eb8148 - <unknown> 13: 0xffffffff - <unknown> ```
2015-02-27remove leftover annotationsJorge Aparicio-2/+2
2015-02-27std: Deprecated the `old_io::extensions` moduleAlex Crichton-0/+4
The `u64_from_be_bytes` and `u64_to_be_bytes` functions are being deprecated with no replacement for now. [breaking-change]
2015-02-27std: Stabilize the `env` moduleAlex Crichton-183/+84
Now that the `std::env` module has had some time to bake this commit marks most of its APIs as `#[stable]`. Some notable APIs that are **not** stable (and still use the same `env` feature gate) are: * `{set,get}_exit_status` - there are still questions about whether this is the right interface for setting/getting the exit status of a process. * `page_size` - this may change location in the future or perhaps name as well. This also effectively closes #22122 as the variants of `VarError` are `#[stable]` now. (this is done intentionally)
2015-02-28std: Fixed backtrace warnings and tests for non-Linux platforms.Kang Seonghoon-1/+2
- Fixed a couple of dead code warnings in std::sys::backtrace. - Made `backtrace-debuginfo` test a no-op on non-Linux platforms. - `backtrace-debuginfo` is no longer tested on pretty-rpass.
2015-02-27Rollup merge of #22835 - tshepang:remove-some-warnings, r=jakub-Manish Goregaokar-6/+6
2015-02-27Rollup merge of #22788 - vadimcn:fix-precise_time_ns, r=pnkfelixManish Goregaokar-2/+25
which starts happening after ~2 hours of machine uptime. Closes #17845
2015-02-27Rollup merge of #22846 - dhuseby:bitrig-cleanup, r=alexcrichtonManish Goregaokar-15/+1
This patch contains a couple time fixes to make Rust compile on Bitrig again. This does not affect OpenBSD.
2015-02-27Rollup merge of #22803 - huonw:field-stability, r=alexcrichtonManish Goregaokar-1/+4
We were recording stability attributes applied to fields in the compiler, and even annotating it in the libs, but the compiler didn't actually do the checks to give errors/warnings in user crates. Details in the commit messages.
2015-02-27Auto merge of #22573 - nwin:impl-debug-rwlock-weak, r=Manishearthbors-0/+28
Implements `Debug` for `RwLock` and `arc::Weak` in the same way it is implemented for `rc::Weak` (basically copy & paste). The lack of this implementation prevents the automatic implementation of `Debug` for structs containing members of these types.
2015-02-26std: Draw from the same port pool during testsAlex Crichton-2/+2
Instead of allocating the same ports for ipv4 and ipv6 tests, instead draw all ports from the same pool. Some tests connect to just "localhost" on a particular port which may accidentally be interacting with other tests as the ipv-what-ness isn't specified with the string "localhost" Relevant logs: * [Deadlock of the `net::tcp::tests::listen_localhost` test][mac] * [Failure of the `fast_rebind` test][win1] * [Failure of `multiple_connect_interleaved_lazy_schedule_ip4`][win2] [mac]: https://gist.github.com/alexcrichton/349c7ce7c620c1adb2f2 [win1]: https://gist.github.com/alexcrichton/7e3611faae2e1edaee6f [win2]: https://gist.github.com/alexcrichton/4f5f87749af3ad0f9851
2015-02-27Add some missing stability attributes on struct fields.Huon Wilson-1/+3