about summary refs log tree commit diff
path: root/src/libcore/fmt
AgeCommit message (Collapse)AuthorLines
2015-04-21rollup merge of #24636: alexcrichton/remove-deprecatedAlex Crichton-44/+66
Conflicts: src/libcore/result.rs
2015-04-21std: Remove deprecated/unstable num functionalityAlex Crichton-44/+66
This commit removes all the old casting/generic traits from `std::num` that are no longer in use by the standard library. This additionally removes the old `strconv` module which has not seen much use in quite a long time. All generic functionality has been supplanted with traits in the `num` crate and the `strconv` module is supplanted with the [rust-strconv crate][rust-strconv]. [rust-strconv]: https://github.com/lifthrasiir/rust-strconv This is a breaking change due to the removal of these deprecated crates, and the alternative crates are listed above. [breaking-change]
2015-04-21Pick a feature name for write_charSimon Sapin-1/+1
2015-04-21write_char is unlikely to make it for 1.0, it’ll be 1.1Simon Sapin-1/+1
2015-04-21Add a `write_char` method to `std::fmt::Write`Simon Sapin-0/+17
as accepted in [RFC 526](https://github.com/rust-lang/rfcs/blob/master/text/0526-fmt-text-writer.md).
2015-04-14rollup merge of #24379: rkruppe/fmt-negative-zeroAlex Crichton-114/+52
Fixes #20596 by making `Debug` render negative zero with a `-` without affecting the behavior of `Display`. While I was at it, I also removed some dead code from `float_to_str_bytes_common` (the one from `libcore/fmt/float.rs`, not the function of the same name in `libstd/num/strconv.rs`). It had support for different bases, and for negative numbers, but the function is internal to core and the couple places that call it (all in `libcore/fmt/mod.rs`) never use those features: They pass in `num.abs()` and base 10.
2015-04-12Destabilize format_args! internals.Ryan Prichard-29/+36
Arguments, Formatters, and the various format traits remain stable. The format_args! macro uses #[allow_internal_unstable] to allow it access to the unstable things in core::fmt. Destabilized things include a "v1" in their name: * core::fmt::rt * core::fmt::rt::v1 (the module and all contents) * core::fmt::ArgumentV1 * core::fmt::ArgumentV1::new * core::fmt::ArgumentV1::from_usize * core::fmt::Arguments::new_v1 * core::fmt::Arguments::new_v1_formatted The unstable message was copied from that of std::io::_print.
2015-04-12Make Debug include the - in -0.0Robin Kruppe-114/+52
2015-04-11Auto merge of #24269 - benashford:formatting-fix, r=alexcrichtonbors-1/+1
This fixes the bug described in issue #23150. This affected formatting any floating point number into a string in a formatting pattern that: a) required rounding up, and b) required an extra digit on the front. So `format!("{:.0}", 9.9)` would fail, but `format!("{:.0}", 8.9)` would succeed. This was due to a negative integer being cast to a `usize` resulting in an 'arithmetic operation overflowed' panic. The fix was to change the order of operations so that the number is zero before casting.
2015-04-10Fix for #23150Ben Ashford-1/+1
2015-04-09fmt: Assume that we'll only ever see 32 or 64 bit pointersRicho Healey-2/+1
2015-04-09fmt: {:p#} formats pointers padded to native widthRicho Healey-1/+25
2015-04-01rollup merge of #23860: nikomatsakis/copy-requires-cloneAlex Crichton-9/+16
Conflicts: src/test/compile-fail/coherence-impls-copy.rs
2015-04-01Fallout in public-facing and semi-public-facing libsNiko Matsakis-9/+16
2015-04-01Fallout in libstd: remove impls now considered to conflict.Niko Matsakis-6/+0
2015-03-31Auto merge of #23549 - aturon:stab-num, r=alexcrichtonbors-0/+1
This commit stabilizes the `std::num` module: * The `Int` and `Float` traits are deprecated in favor of (1) the newly-added inherent methods and (2) the generic traits available in rust-lang/num. * The `Zero` and `One` traits are reintroduced in `std::num`, which together with various other traits allow you to recover the most common forms of generic programming. * The `FromStrRadix` trait, and associated free function, is deprecated in favor of inherent implementations. * A wide range of methods and constants for both integers and floating point numbers are now `#[stable]`, having been adjusted for integer guidelines. * `is_positive` and `is_negative` are renamed to `is_sign_positive` and `is_sign_negative`, in order to address #22985 * The `Wrapping` type is moved to `std::num` and stabilized; `WrappingOps` is deprecated in favor of inherent methods on the integer types, and direct implementation of operations on `Wrapping<X>` for each concrete integer type `X`. Closes #22985 Closes #21069 [breaking-change] r? @alexcrichton
2015-03-31Stabilize std::numAaron Turon-0/+1
This commit stabilizes the `std::num` module: * The `Int` and `Float` traits are deprecated in favor of (1) the newly-added inherent methods and (2) the generic traits available in rust-lang/num. * The `Zero` and `One` traits are reintroduced in `std::num`, which together with various other traits allow you to recover the most common forms of generic programming. * The `FromStrRadix` trait, and associated free function, is deprecated in favor of inherent implementations. * A wide range of methods and constants for both integers and floating point numbers are now `#[stable]`, having been adjusted for integer guidelines. * `is_positive` and `is_negative` are renamed to `is_sign_positive` and `is_sign_negative`, in order to address #22985 * The `Wrapping` type is moved to `std::num` and stabilized; `WrappingOps` is deprecated in favor of inherent methods on the integer types, and direct implementation of operations on `Wrapping<X>` for each concrete integer type `X`. Closes #22985 Closes #21069 [breaking-change]
2015-03-30std: Standardize (input, output) param orderingsAlex Crichton-2/+2
This functions swaps the order of arguments to a few functions that previously took (output, input) parameters, but now take (input, output) parameters (in that order). The affected functions are: * ptr::copy * ptr::copy_nonoverlapping * slice::bytes::copy_memory * intrinsics::copy * intrinsics::copy_nonoverlapping Closes #22890 [breaking-change]
2015-03-29Auto merge of #23810 - sfackler:debug-collections, r=alexcrichtonbors-90/+125
The collections debug helpers no longer prefix output with the collection name, in line with the current conventions for Debug implementations. Implementations that want to preserve the current behavior can simply add a `try!(write!(fmt, "TypeName "));` at the beginning of the `fmt` method. [breaking-change]
2015-03-28Oops fix output examplesSteven Fackler-4/+4
2015-03-28Fold in debug builder doc examplesSteven Fackler-15/+3
2015-03-28Remove IteratorExtSteven Fackler-3/+3
All methods are inlined into Iterator with `Self: Sized` bounds to make sure Iterator is still object safe. [breaking-change]
2015-03-28Fold collections debug implsSteven Fackler-16/+1
Also convert [T]'s Debug impl. The behavior of the alternate flag here's changing.
2015-03-28Update debug helpers and add list builderSteven Fackler-64/+126
The collections debug helpers no longer prefix output with the collection name, in line with the current conventions for Debug implementations. Implementations that want to preserve the current behavior can simply add a `try!(write!(fmt, "TypeName "));` at the beginning of the `fmt` method. [breaking-change]
2015-03-27rollup merge of #23741: alexcrichton/remove-int-uintAlex Crichton-2/+2
Conflicts: src/librustc/middle/ty.rs src/librustc_trans/trans/adt.rs src/librustc_typeck/check/mod.rs src/libserialize/json.rs src/test/run-pass/spawn-fn.rs
2015-03-27Change the trivial cast lints to allow by defaultNick Cameron-1/+0
2015-03-26Mass rename uint/int to usize/isizeAlex Crichton-2/+2
Now that support has been removed, all lingering use cases are renamed.
2015-03-25Change lint names to pluralsNick Cameron-4/+4
2015-03-25Add trivial cast lints.Nick Cameron-0/+7
This permits all coercions to be performed in casts, but adds lints to warn in those cases. Part of this patch moves cast checking to a later stage of type checking. We acquire obligations to check casts as part of type checking where we previously checked them. Once we have type checked a function or module, then we check any cast obligations which have been acquired. That means we have more type information available to check casts (this was crucial to making coercions work properly in place of some casts), but it means that casts cannot feed input into type inference. [breaking change] * Adds two new lints for trivial casts and trivial numeric casts, these are warn by default, but can cause errors if you build with warnings as errors. Previously, trivial numeric casts and casts to trait objects were allowed. * The unused casts lint has gone. * Interactions between casting and type inference have changed in subtle ways. Two ways this might manifest are: - You may need to 'direct' casts more with extra type information, for example, in some cases where `foo as _ as T` succeeded, you may now need to specify the type for `_` - Casts do not influence inference of integer types. E.g., the following used to type check: ``` let x = 42; let y = &x as *const u32; ``` Because the cast would inform inference that `x` must have type `u32`. This no longer applies and the compiler will fallback to `i32` for `x` and thus there will be a type error in the cast. The solution is to add more type information: ``` let x: u32 = 42; let y = &x as *const u32; ```
2015-03-23Add #![feature] attributes to doctestsBrian Anderson-0/+5
2015-03-12Auto merge of #23162 - sfackler:debug-builders, r=alexcrichtonbors-1/+422
I've made some minor changes from the implementation attached to the RFC to try to minimize codegen. The methods now take `&Debug` trait objects rather than being parameterized and there are inlined stub methods that call to non-inlined methods to do the work. r? @alexcrichton cc @huonw for the `derive(Debug)` changes.
2015-03-11Example -> ExamplesSteve Klabnik-1/+1
This brings comments in line with https://github.com/rust-lang/rfcs/blob/master/text/0505-api-comment-conventions.md#using-markdown
2015-03-11Switch to a specific featureSteven Fackler-10/+10
2015-03-10Remove inline silliness from debug buildersSteven Fackler-60/+11
Turns out it's basically a wash, codegen wise.
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-05Remove integer suffixes where the types in compiled code are identical.Eduard Burtescu-6/+6
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 #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-02core: Audit num module for int/uintBrian Anderson-2/+2
* 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-02Use `const`s instead of `static`s where appropriateFlorian Zeitz-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-02-28Cleanup in the fmt::num moduleRyan Prichard-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-02-28Fix assuming 32-bit pointersJohn Hodge-1/+1
2015-02-27register snapshot 880fb89Flavio Percoco-19/+0
2015-02-24Rollup merge of #22700 - nick29581:ints_hash, r=alexcrichtonManish Goregaokar-36/+55
fmt and hash are pretty straightforward I think. sync is a bit more complex. I thought one or two of the `isize`s ought to be `i32`s, but that would require a bunch of casting (the root cause being the lack of atomics other than isize/usize). r? @alexcrichton
2015-02-23int audit - libcore::fmtNick Cameron-36/+55
2015-02-21Kill fmt::Show and fmt::String with fire!Simonas Kazlauskas-32/+0
Toss the tomatoes!
2015-02-18Introduce the new phantomdata/phantomfn markers and integrate themNiko Matsakis-1/+6
into variance inference; fix various bugs in variance inference so that it considers the correct set of constraints; modify infer to consider the results of variance inference for type arguments.
2015-02-17Rollup merge of #22311 - lfairy:consistent-fmt, r=alexcrichtonManish Goregaokar-10/+10
This brings it in line with its namesake in `std::io`. [breaking-change] r? @aturon