about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2015-08-28Auto merge of #28047 - steveklabnik:doc_print, r=alexcrichtonbors-0/+20
2015-08-28Add issue number to read_exact unstable declarationsCesar Eduardo Barros-2/+2
2015-08-28Auto merge of #28054 - zaeleus:ios-imports, r=alexcrichtonbors-4/+1
This fixes building for ios targets caused by 7925c79.
2015-08-28Auto merge of #28038 - durka:grep-unstable-issue-refs, r=alexcrichtonbors-1/+1
After submitting #28031, I ran a [script](https://gist.github.com/durka/a5243440697c780f669b) on the rest of src/ and found some anomalies. In this PR are the fixes that I thought were obvious (but I might be wrong!). The others I've submitted in issue #28037.
2015-08-27std: Fix backtrace imports for ios targetsMichael Macias-4/+1
This fixes building for ios targets caused by 7925c79.
2015-08-27Auto merge of #28052 - Manishearth:rollup, r=Manishearthbors-2/+5
- Successful merges: #28010, #28013, #28022, #28029, #28033, #28039, #28045, #28048 - Failed merges:
2015-08-27Add some examples for the print! macroSteve Klabnik-0/+20
2015-08-28Rollup merge of #28029 - tshepang:unusual, r=steveklabnikManish Goregaokar-2/+5
2015-08-27Auto merge of #27930 - barosl:path_max, r=alexcrichtonbors-20/+37
This PR rewrites the code that previously relied on `PATH_MAX`. On my tests, even though the user gives the buffer length explicitly, both Linux's glibc and OS X's libc seems to obey the hard limit of `PATH_MAX` internally. So, to truly remove the limitation of `PATH_MAX`, the related system calls should be rewritten from scratch in Rust, which this PR does not try to do. However, eliminating the need of `PATH_MAX` is still a good idea for various reasons, such as: (1) they might change the implementation in the future, and (2) some platforms don't have a hard-coded `PATH_MAX`, such as GNU Hurd. More details are in the commit messages. Fixes #27454. r? @alexcrichton
2015-08-28Use a different buffer doubling logic for `std::sys::os::getcwd`Barosl Lee-5/+7
Make `std::sys::os::getcwd` call `Vec::reserve(1)` followed by `Vec::set_len` to double the buffer. This is to align with other similar functions, such as: - `std::sys_common::io::read_to_end_uninitialized` - `std::sys::fs::readlink` Also, reduce the initial buffer size from 2048 to 512. The previous size was introduced with 4bc26ce in 2013, but it seems a bit excessive. This is probably because buffer doubling was not implemented back then.
2015-08-28Reduce the reliance on `PATH_MAX`Barosl Lee-15/+30
- Rewrite `std::sys::fs::readlink` not to rely on `PATH_MAX` It currently has the following problems: 1. It uses `_PC_NAME_MAX` to query the maximum length of a file path in the underlying system. However, the meaning of the constant is the maximum length of *a path component*, not a full path. The correct constant should be `_PC_PATH_MAX`. 2. `pathconf` *may* fail if the referred file does not exist. This can be problematic if the file which the symbolic link points to does not exist, but the link itself does exist. In this case, the current implementation resorts to the hard-coded value of `1024`, which is not ideal. 3. There may exist a platform where there is no limit on file path lengths in general. That's the reaon why GNU Hurd doesn't define `PATH_MAX` at all, in addition to having `pathconf` always returning `-1`. In these platforms, the content of the symbolic link can be silently truncated if the length exceeds the hard-coded limit mentioned above. 4. The value obtained by `pathconf` may be outdated at the point of actually calling `readlink`. This is inherently racy. This commit introduces a loop that gradually increases the length of the buffer passed to `readlink`, eliminating the need of `pathconf`. - Remove the arbitrary memory limit of `std::sys::fs::realpath` As per POSIX 2013, `realpath` will return a malloc'ed buffer if the second argument is a null pointer.[1] [1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html - Comment on functions that are still using `PATH_MAX` There are some functions that only work in terms of `PATH_MAX`, such as `F_GETPATH` in OS X. Comments on them for posterity.
2015-08-27Auto merge of #28030 - tshepang:improve-example, r=alexcrichtonbors-2/+4
2015-08-27fix some more unstable issue annotationsAlex Burka-1/+1
2015-08-27Auto merge of #27975 - sfackler:iter-order-methods, r=aturonbors-8/+8
This does cause some breakage due to deficiencies in resolve - `path::Components` is both an `Iterator` and implements `Eq`, `Ord`, etc. If one calls e.g. `partial_cmp` on a `Components` and passes a `&Components` intending to target the `PartialOrd` impl, the compiler will select the `partial_cmp` from `Iterator` and then error out. I doubt anyone will run into breakage from `Components` specifically, but we should see if there are third party types that will run into issues. `iter::order::equals` wasn't moved to `Iterator` since it's exactly the same as `iter::order::eq` but with an `Eq` instead of `PartialEq` bound, which doensn't seem very useful. I also updated `le`, `gt`, etc to use `partial_cmp` which lets us drop the extra `PartialEq` bound. cc #27737 r? @alexcrichton
2015-08-26Make iter::order functions into methods on IteratorSteven Fackler-8/+8
This does cause some breakage due to deficiencies in resolve - `path::Components` is both an `Iterator` and implements `Eq`, `Ord`, etc. If one calls e.g. `partial_cmp` on a `Components` and passes a `&Components` intending to target the `PartialOrd` impl, the compiler will select the `partial_cmp` from `Iterator` and then error out. I doubt anyone will run into breakage from `Components` specifically, but we should see if there are third party types that will run into issues. `iter::order::equals` wasn't moved to `Iterator` since it's exactly the same as `iter::order::eq` but with an `Eq` instead of `PartialEq` bound, which doensn't seem very useful. I also updated `le`, `gt`, etc to use `partial_cmp` which lets us drop the extra `PartialEq` bound. cc #27737
2015-08-27Auto merge of #27808 - SimonSapin:utf16decoder, r=alexcrichtonbors-6/+6
* Rename `Utf16Items` to `Utf16Decoder`. "Items" is meaningless. * Generalize it to any `u16` iterator, not just `[u16].iter()` * Make it yield `Result` instead of a custom `Utf16Item` enum that was isomorphic to `Result`. This enable using the `FromIterator for Result` impl. * Replace `Utf16Item::to_char_lossy` with a `Utf16Decoder::lossy` iterator adaptor. This is a [breaking change], but only for users of the unstable `rustc_unicode` crate. I’d like this functionality to be stabilized and re-exported in `std` eventually, as the "low-level equivalent" of `String::from_utf16` and `String::from_utf16_lossy` like #27784 is the low-level equivalent of #27714. CC @aturon, @alexcrichton
2015-08-26doc: improve as_path exampleTshepang Lekhonkhobe-2/+4
2015-08-26path: the if-else block looked unusualTshepang Lekhonkhobe-2/+5
2015-08-26Auto merge of #27998 - birkenfeld:patch-1, r=alexcrichtonbors-28/+6
These have been removed and should not be documented here. Should the replacement crates on crates.io be linked to, or is that not wanted in the core docs?
2015-08-25Auto merge of #27995 - nagisa:windows-error-message, r=alexcrichtonbors-3/+2
According to https://msdn.microsoft.com/en-us/library/windows/desktop/ms679351(v=vs.85).aspx: > If the function succeeds, the return value is the number of TCHARs stored in the output buffer, > excluding the terminating null character. _**Completely untested**_… since I have no Windows machine or anything of a sort to test this on. r? @aturon
2015-08-25collections doc: remove mention of BitVec, BitSet, VecMapGeorg Brandl-28/+6
These have been removed and should not be documented here.
2015-08-25Do not recalculate string length in error_stringSimonas Kazlauskas-3/+2
According to https://msdn.microsoft.com/en-us/library/windows/desktop/ms679351(v=vs.85).aspx: > If the function succeeds, the return value is the number of TCHARs stored in the output buffer, > excluding the terminating null character.
2015-08-25Auto merge of #27971 - tbu-:pr_cloexec, r=alexcrichtonbors-1/+4
On Linux the flag is just ignored if it is not supported: https://lwn.net/Articles/588444/ Still needs the values of O_CLOEXEC on the BSDs. Touches #24237.
2015-08-25Auto merge of #27966 - GuillaumeGomez:iterator, r=alexcrichtonbors-0/+3
Part of #22709. cc @Veedrac r? @bluss I don't have added tests yet, I'll see how to do it tomorrow.
2015-08-25Auto merge of #27957 - overminder:aug23-i686-android, r=alexcrichtonbors-1/+2
- All the libstd tests are passing in the optimized build against a Zenfone2 and the x86 Android emulator. I haven't tested the other libraries though.
2015-08-24Implement read_exact for the Read traitCesar Eduardo Barros-0/+140
This implements the proposed "read_exact" RFC (https://github.com/rust-lang/rfcs/pull/980).
2015-08-24Atomically open files with O_CLOEXEC where possibleTobias Bucher-1/+4
On Linux the flag is just ignored if it is not supported: https://lwn.net/Articles/588444/ Touches #24237.
2015-08-24Add stability markers for new implsSteven Fackler-0/+2
2015-08-23Implement Error for AddrParseErrorSteven Fackler-1/+15
Closes #27973
2015-08-23Add Send/Sync traits on LookupHost structGuillaume Gomez-0/+3
2015-08-23Auto merge of #27948 - wthrowe:f64-sqrt, r=alexcrichtonbors-1/+5
This fixes a reappearance of bug #9987 introduced in 1ddee8070d3cb83609b1f71c29e3deda3d30fd51, which caused f64::tests::test_sqrt_domain to fail (at least on some systems).
2015-08-23New cross target: i686-linux-androidTim JIANG-1/+2
- All the libstd tests are now passing in the optimized build against a Zenfone2 and the x86 Android simulator.
2015-08-23Auto merge of #27912 - DiamondLovesYou:backtrace-refactor, r=alexcrichtonbors-586/+688
2015-08-22Fix undefined behavior in f64::sqrtWilliam Throwe-1/+5
This fixes a reappearance of bug #9987 introduced in 1ddee8070d3cb83609b1f71c29e3deda3d30fd51, which caused f64::tests::test_sqrt_domain to fail (at least on some systems).
2015-08-23Refactor low-level UTF-16 decoding.Simon Sapin-6/+6
* Rename `utf16_items` to `decode_utf16`. "Items" is meaningless. * Move it to `rustc_unicode::char`, exposed in `std::char`. * Generalize it to any `u16` iterable, not just `&[u16]`. * Make it yield `Result` instead of a custom `Utf16Item` enum that was isomorphic to `Result`. This enable using the `FromIterator for Result` impl. * Add a `REPLACEMENT_CHARACTER` constant. * Document how `result.unwrap_or(REPLACEMENT_CHARACTER)` replaces `Utf16Item::to_char_lossy`.
2015-08-22Fix the Mac build, again.Richard Diamond-0/+1
2015-08-22Auto merge of #27896 - alexcrichton:into-raw-os-prelude, r=brsonbors-2/+2
These traits were mistakenly left out of the OS-specific prelude modules when they were added.
2015-08-22Add missing imports to `dladdr.rs` for Mac.Richard Diamond-0/+6
2015-08-22Auto merge of #27871 - alexcrichton:stabilize-libcore, r=aturonbors-304/+26
These commits move libcore into a state so that it's ready for stabilization, performing some minor cleanup: * The primitive modules for integers in the standard library were all removed from the source tree as they were just straight reexports of the libcore variants. * The `core::atomic` module now lives in `core::sync::atomic`. The `core::sync` module is otherwise empty, but ripe for expansion! * The `core::prelude::v1` module was stabilized after auditing that it is a subset of the standard library's prelude plus some primitive extension traits (char, str, and slice) * Some unstable-hacks for float parsing errors were shifted around to not use the same unstable hacks (e.g. the `flt2dec` module is now used for "privacy"). After this commit, the remaining large unstable functionality specific to libcore is: * `raw`, `intrinsics`, `nonzero`, `array`, `panicking`, `simd` -- these modules are all unstable or not reexported in the standard library, so they're just remaining in the same status quo as before * `num::Float` - this extension trait for floats needs to be audited for functionality (much of that is happening in #27823) and may also want to be renamed to `FloatExt` or `F32Ext`/`F64Ext`. * Should the extension traits for primitives be stabilized in libcore? I believe other unstable pieces are not isolated to just libcore but also affect the standard library. cc #27701
2015-08-22Auto merge of #27860 - m4rw3r:rustdoc_unstable_feature_issue, r=alexcrichtonbors-0/+1
Implemented #27759 Example: ![screen shot 2015-08-16 at 21 45 17](https://cloud.githubusercontent.com/assets/108100/9295040/1fb24d50-4460-11e5-8ab8-81ac5330974a.png)
2015-08-22Auto merge of #27826 - sfackler:wait-timeout-enum, r=alexcrichtonbors-21/+42
Returning a primitive bool results in a somewhat confusing API - does `true` indicate success - i.e. no timeout, or that a timeout has occurred? An explicitly named enum makes it clearer. [breaking-change] r? @alexcrichton
2015-08-20Refactor unix backtracing. NFC.Richard Diamond-586/+681
2015-08-19Add issue numbersSteven Fackler-1/+2
2015-08-19Turn TimedOut into a BarrierWaitResult style opaque typeSteven Fackler-38/+25
2015-08-19Add `TimedOut::timed_out`Steven Fackler-1/+8
2015-08-19Make Condvar::wait_timeout return an enum instead of a boolSteven Fackler-19/+45
Returning a primitive bool results in a somewhat confusing API - does `true` indicate success - i.e. no timeout, or that a timeout has occurred? An explicitly named enum makes it clearer. [breaking-change]
2015-08-19Auto merge of #27885 - steveklabnik:gh27637, r=alexcrichtonbors-0/+3
Hopefully make this distinction a little more clear. Fixes #27637 r? @alexcrichton /cc @havvy
2015-08-19Improve std::io::ErrorKindSteve Klabnik-0/+3
Hopefully make this distinction a little more clear. Fixes #27637
2015-08-18std: Add into_raw_os traits to the OS preludesAlex Crichton-2/+2
These traits were mistakenly left out of the OS-specific prelude modules when they were added.
2015-08-18Auto merge of #27836 - alexcrichton:rename-cstring-raw, r=blussbors-5/+28
This commit renames the `CString::{into_ptr, from_ptr}` methods to `into_raw` and `from_raw` to mirror the corresponding methods on `Box` and the naming of "raw" for `from_raw_parts` on slices and vectors. cc #27769