about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2015-03-10std: Stabilize more of the `char` moduleAlex Crichton-221/+4
This commit performs another pass over the `std::char` module for stabilization. Some minor cleanup is performed such as migrating documentation from libcore to libunicode (where the `std`-facing trait resides) as well as a slight reorganiation in libunicode itself. Otherwise, the stability modifications made are: * `char::from_digit` is now stable * `CharExt::is_digit` is now stable * `CharExt::to_digit` is now stable * `CharExt::to_{lower,upper}case` are now stable after being modified to return an iterator over characters. While the implementation today has not changed this should allow us to implement the full set of case conversions in unicode where some characters can map to multiple when doing an upper or lower case mapping. * `StrExt::to_{lower,upper}case` was added as unstable for a convenience of not having to worry about characters expanding to more characters when you just want the whole string to get into upper or lower case. This is a breaking change due to the change in the signatures of the `CharExt::to_{upper,lower}case` methods. Code can be updated to use functions like `flat_map` or `collect` to handle the difference. [breaking-change]
2015-03-10std: Stabilize slice::from_raw_partsAlex Crichton-2/+2
These new APIs have had some time to bake now, and no pressing issues have come up so they should be ok for stabilizing. Specifically, these two APIs were stabilized: * `slice::from_raw_parts` * `slice::from_raw_parts_mut`
2015-03-10Auto merge of #23249 - tbu-:pr_rm_core_str_macros, r=alexcrichtonbors-41/+40
2015-03-10Remove unneeded `saturating_add`Tobias Bucher-1/+4
2015-03-10Remove unneeded macro witcheryTobias Bucher-41/+40
2015-03-10Purge `isize` from `core::iter`Tobias Bucher-3/+3
2015-03-09Switch derive(Debug) to use the debug buildersSteven Fackler-1/+23
2015-03-09Restructure debug builders to minimize codegenSteven Fackler-18/+58
Switching from generic bounds to trait objects and having un-inlined inner methods should cut down on the size of Debug impls, since we care about the speed of a Debug implementation way less than binary bloat.
2015-03-09Implement RFC 640Steven Fackler-1/+409
2015-03-09Auto merge of #22561 - richo:as_slice-as_str, r=Manishearthbors-6/+6
This may not be quite ready to go out, I fixed some docs but suspect I missed a bunch. I also wound up fixing a bunch of redundant `[]` suffixes, but on closer inspection I don't believe that can land until after a snapshot.
2015-03-09Auto merge of #23219 - Manishearth:rollup, r=Manishearthbors-12/+4
2015-03-09doc: Fix extraneous as_slice()'s in docstringsRicho Healey-6/+6
2015-03-09Rollup merge of #23183 - steveklabnik:gh22572, r=ManishearthManish Goregaokar-11/+3
They're opt-in now. Fixes #22572
2015-03-09Auto merge of #23153 - Manishearth:snap, r=alexcrichtonbors-26/+0
Needed so that #21824 can land
2015-03-08Clean up references to opt-out traitsSteve Klabnik-11/+3
They're opt-in now. Fixes #22572
2015-03-08Add description of fold function arguments.Ɓukasz Niemier-1/+1
2015-03-08Adds an example for PhantomData<T>.Pyry Kontio-1/+39
2015-03-08Register new snapshots (270a677)Manish Goregaokar-26/+0
2015-03-07indicate from_str_radix is codeFuGangqiang-1/+1
2015-03-06Rollup merge of #23100 - wesleywiser:fix_23059, r=brsonManish Goregaokar-2/+1
Fixes #23059
2015-03-06Rollup merge of #23056 - awlnx:master, r=nrcManish Goregaokar-0/+2
2015-03-06Rollup merge of #23025 - huonw:better-iter-infer, r=GankroManish Goregaokar-46/+48
This concretely improves type inference of some cases (see included test). I assume the compiler struggles to reason about multiple layers of generic type parameters (even with associated-type equalities) but *can* understand pure associated types, since they are always directly computable from the input types. Thanks to @shepmaster for noticing the issue with `Cloned` (I took that example as a test case).
2015-03-06Rollup merge of #22980 - alexcrichton:debug-assertions, r=pnkfelixManish Goregaokar-10/+14
This commit is an implementation of [RFC 563][rfc] which adds a new `cfg(debug_assertions)` directive which is specially recognized and calculated by the compiler. The flag is turned off at any optimization level greater than 1 and may also be explicitly controlled through the `-C debug-assertions` flag. [rfc]: https://github.com/rust-lang/rfcs/pull/563 The `debug_assert!` and `debug_assert_eq!` macros now respect this instead of the `ndebug` variable and `ndebug` no longer holds any meaning to the standard library. Code which was previously relying on `not(ndebug)` to gate expensive code should be updated to rely on `debug_assertions` instead. Closes #22492 [breaking-change]
2015-03-06Rollup merge of #22899 - huonw:macro-stability, r=alexcrichtonManish Goregaokar-0/+2
Unstable items used in a macro expansion will now always trigger stability warnings, *unless* the unstable items are directly inside a macro marked with `#[allow_internal_unstable]`. IOW, the compiler warns unless the span of the unstable item is a subspan of the definition of a macro marked with that attribute. E.g. #[allow_internal_unstable] macro_rules! foo { ($e: expr) => {{ $e; unstable(); // no warning only_called_by_foo!(); }} } macro_rules! only_called_by_foo { () => { unstable() } // warning } foo!(unstable()) // warning The unstable inside `foo` is fine, due to the attribute. But the `unstable` inside `only_called_by_foo` is not, since that macro doesn't have the attribute, and the `unstable` passed into `foo` is also not fine since it isn't contained in the macro itself (that is, even though it is only used directly in the macro). In the process this makes the stability tracking much more precise, e.g. previously `println!(\"{}\", unstable())` got no warning, but now it does. As such, this is a bug fix that may cause [breaking-change]s. The attribute is definitely feature gated, since it explicitly allows side-stepping the feature gating system. --- This updates `thread_local!` macro to use the attribute, since it uses unstable features internally (initialising a struct with unstable fields).
2015-03-05Fix reference to 'librlibc' in libcore docsWesley Wiser-2/+1
Fixes #23059
2015-03-05rustc: Add a debug_assertions #[cfg] directiveAlex Crichton-10/+14
This commit is an implementation of [RFC 563][rfc] which adds a new `cfg(debug_assertions)` directive which is specially recognized and calculated by the compiler. The flag is turned off at any optimization level greater than 1 and may also be explicitly controlled through the `-C debug-assertions` flag. [rfc]: https://github.com/rust-lang/rfcs/pull/563 The `debug_assert!` and `debug_assert_eq!` macros now respect this instead of the `ndebug` variable and `ndebug` no longer holds any meaning to the standard library. Code which was previously relying on `not(ndebug)` to gate expensive code should be updated to rely on `debug_assertions` instead. Closes #22492 [breaking-change]
2015-03-05fix for new attributes failing. issue #22964awlnx-0/+2
2015-03-06Add #[allow_internal_unstable] to track stability for macros better.Huon Wilson-0/+2
Unstable items used in a macro expansion will now always trigger stability warnings, *unless* the unstable items are directly inside a macro marked with `#[allow_internal_unstable]`. IOW, the compiler warns unless the span of the unstable item is a subspan of the definition of a macro marked with that attribute. E.g. #[allow_internal_unstable] macro_rules! foo { ($e: expr) => {{ $e; unstable(); // no warning only_called_by_foo!(); }} } macro_rules! only_called_by_foo { () => { unstable() } // warning } foo!(unstable()) // warning The unstable inside `foo` is fine, due to the attribute. But the `unstable` inside `only_called_by_foo` is not, since that macro doesn't have the attribute, and the `unstable` passed into `foo` is also not fine since it isn't contained in the macro itself (that is, even though it is only used directly in the macro). In the process this makes the stability tracking much more precise, e.g. previously `println!("{}", unstable())` got no warning, but now it does. As such, this is a bug fix that may cause [breaking-change]s. The attribute is definitely feature gated, since it explicitly allows side-stepping the feature gating system.
2015-03-05Use more associated types in core::iter.Huon Wilson-46/+48
This concretely improves type inference of some cases (see included test). I assume the compiler struggles to reason about multiple layers of generic type parameters (even with associated-type equalities) but *can* understand pure associated types, since they are always directly computable from the input types.
2015-03-05Rollup merge of #22994 - eddyb:unsuffix-ints-good, r=alexcrichtonManish Goregaokar-36/+36
Automatic has-same-types testing methodology can be found in #22501. Because most of them don't work with `--pretty=typed`, compile-fail tests were manually audited. r? @aturon
2015-03-05Remove integer suffixes where the types in compiled code are identical.Eduard Burtescu-36/+36
2015-03-05Rollup merge of #23001 - alexcrichton:index-output-stable, r=nikomatsakisManish Goregaokar-0/+1
This stability attribute was left out by accident and the stability pass has since picked up the ability to check for this. As a result, crates are currently getting warnings for implementations of `Index`.
2015-03-04Auto merge of #22958 - laijs:option_map_for_iter_map, r=alexcrichtonbors-16/+3
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
2015-03-03std: Mark `Index::Output` as a stable associated typeAlex Crichton-0/+1
This stability attribute was left out by accident and the stability pass has since picked up the ability to check for this. As a result, crates are currently getting warnings for implementations of `Index`.
2015-03-03Auto merge of #22532 - pnkfelix:arith-overflow, r=pnkfelix,eddybbors-19/+356
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-03Rollup merge of #22988 - dcrewi:slice-swap-inline, r=alexcrichtonManish Goregaokar-0/+1
2015-03-03Rollup merge of #22952 - huonw:missing-stable, r=alexcrichtonManish Goregaokar-0/+2
Unstable is the conservative choice. cc #22950.
2015-03-03Rollup merge of #22951 - huonw:weak-chuck-slice, r=alexcrichtonManish Goregaokar-2/+22
`#[derive(Clone)]` unnecessarily requires the element type to also be `Clone`.
2015-03-03Rollup merge of #22876 - Florob:const, r=nikomatsakisManish Goregaokar-1/+1
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 #22989 - laijs:fix_FromStr_bool_comment, r=alexcrichtonManish Goregaokar-2/+13
Fix the return type in the comments. An old commit 082bfde41217 (\"Fallout of std::str stabilization\") removed the example of FromStr::from_str(), this commit adds it back. But the example of StrExt::parse() is still kept with an additinal note. Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
2015-03-03Rollup merge of #22943 - ipetkov:lint-recursion, r=alexcrichtonManish Goregaokar-0/+5
* 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-03Rollup merge of #22916 - rprichard:fmt-num-cleanup, r=alexcrichtonManish Goregaokar-12/+9
* Make num::UpperHex private. I was unable to determine why this struct is public. The num module itself is not public, and the UpperHex struct is not referenced anywhere in the core::fmt module. (Only the UpperHex trait is reference.) num::LowerHex is not public. * Remove the suffix parameters from the macros that generate integral display traits. The code to print the Debug::fmt suffixes was removed when Show was renamed to Debug. It was an intentional change. From RFC 0565: * Focus on the *runtime* aspects of a type; repeating information such as suffixes for integer literals is not generally useful since that data is readily available from the type definition. * Because Show was renamed to Debug, rename show! to debug!.
2015-03-03`core::iter`: fix bug uncovered by arith-overflow.Felix S. Klock II-1/+5
(The bug was in `impl RandomAccessIterator for Rev`; it may or may not have been innocuous, depending on what guarantees one has about the behavior of `idx` for the underlying iterator.)
2015-03-03Accommodate arith-overflow in `core::num`, `std::num`, `coretest::num`.Felix S. Klock II-6/+22
* `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-03fix Iter::rposition for new arith-overflow checking.Felix S. Klock II-2/+3
2015-03-03Added `OverflowingOps` trait to core::num::wrapping.Felix S. Klock II-0/+148
These return the result of the operation *plus* an overflow/underflow bit. This can make it easier to write operations where you want to chain some arithmetic together, but also want to return a flag signalling if overflow every occurred.
2015-03-03Add `core::num::wrapping` and fix overflow errors.James Miller-10/+167
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-03rustc: implement arithmetic overflow checkingCorey Richardson-0/+11
Adds overflow checking to integer addition, multiplication, and subtraction when `-Z force-overflow-checks` is true, or if `--cfg ndebug` is not passed to the compiler. On overflow, it panics with `arithmetic operation overflowed`. Also adds `overflowing_add`, `overflowing_sub`, and `overflowing_mul` intrinsics for doing unchecked arithmetic. [breaking-change]
2015-03-03str: fix comments for FromStr for boolLai Jiangshan-2/+13
Fix the return type in the comments. An old commit 082bfde41217 ("Fallout of std::str stabilization") removed the example of FromStr::from_str(), this commit adds it back. But the example of StrExt::parse() is still kept with an additinal note. Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
2015-03-02Slice::swap should be inlineableDavid Creswick-0/+1