about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2018-02-16Add a warning to File about mutability.Alexis Hunt-0/+15
Fixes #47708.
2018-02-15Fix condvar exampleGuillaume Gomez-2/+4
2018-02-15Remove "empty buffer" doc in read_untilRoss Light-2/+0
This appears copied from fill_buf, but the above paragraph already indicates that a lack of delimiter at the end is EOF.
2018-02-14Rollup merge of #48035 - technicalguy:Early-exit-empty-hashmap-38880, ↵kennytm-26/+38
r=arthurprs Early exit for empty HashMap (issue #38880) Addresses issue #38880 by checking if the HashMap is empty before computing the value of the hash. Before (integer keys) ``` running 4 tests test empty_once ... bench: 13 ns/iter (+/- 0) test empty_100 ... bench: 1,367 ns/iter (+/- 35) test exist_once ... bench: 14 ns/iter (+/- 0) test exist_100 ... bench: 1,518 ns/iter (+/- 40) ``` After ``` running 4 tests test empty_once ... bench: 2 ns/iter (+/- 0) test empty_100 ... bench: 221 ns/iter (+/- 0) test exist_once ... bench: 15 ns/iter (+/- 0) test exist_100 ... bench: 1,515 ns/iter (+/- 92) ``` When the HashMap is not empty, the performance remains the same, and when it is empty the performance is significantly improved.
2018-02-14Rollup merge of #48133 - matthiaskrgr:endianess_to_endianness, r=oli-obkkennytm-2/+2
typo: correct endianess to endianness (this also changes function names!)
2018-02-14Rollup merge of #48130 - ollie27:stab, r=Mark-Simulacrumkennytm-2/+2
Correct a few stability attributes * `core_float_bits`, `duration_core`, `path_component_asref`, and `repr_align` were stabalized in 1.25.0 not 1.24.0. * Impls for `NonNull` involving unstable things should remain unstable. * `Duration` should remain stable since 1.3.0 so it appears correctly in the `std` docs. * `cursor_mut_vec` is an impl on only stable things so should be marked stable.
2018-02-14Rollup merge of #48005 - panicbit:env_unimpl_send_sync, r=alexcrichtonkennytm-0/+12
Unimplement Send/Sync for ::env::{Args,ArgsOs,Vars,VarsOs} Fixes #48004
2018-02-1338880 remove unnecessary self.table.size checkShaun Steenkamp-4/+0
2018-02-13Misc fixesVitali Lovich-4/+4
Switch feature guards to unstable Add missing semicolon Remove mut that's no longer necessary
2018-02-1338880 fix incorrect negationShaun Steenkamp-1/+1
2018-02-1338880 hashmap check size=0, not just capacity=0Shaun Steenkamp-30/+24
2018-02-1338880 restore original entry(key) methodShaun Steenkamp-1/+3
2018-02-12Fix wait_timeout valueVitali Lovich-1/+1
2018-02-12changed termination_trait's bound from Error to Debug; added compiletest ↵Brad Gibson-12/+3
header command and appropriate tests
2018-02-12Stabilize 'entry_and_modify' feature for HashMaphedgehog1024-2/+1
2018-02-1238880 fixup add missing mutShaun Steenkamp-1/+1
2018-02-1238880 remove redundant extra functionShaun Steenkamp-14/+6
2018-02-11Make primitive types docs relevantGuillaume Gomez-48/+0
2018-02-11Add an unstable FileTypeExt extension trait for WindowsPeter Atashian-0/+21
2018-02-11typo: correct endianess to endianness (this also changes function names!)Matthias Krüger-2/+2
2018-02-10Correct a few stability attributesOliver Middleton-2/+2
2018-02-07update the builtin macro doc stubsMichael Lamparski-5/+20
2018-02-07Rollup merge of #47631 - SimonSapin:nonnull, r=alexcrichtonManish Goregaokar-1/+1
Add some APIs to ptr::NonNull and fix `since` attributes This is a follow-up to its stabilization in https://github.com/rust-lang/rust/pull/46952. Tracking issue: https://github.com/rust-lang/rust/issues/27730. * These trait impls are insta-stable: `Hash`, `PartialEq`, `Eq`, `PartialOrd` and `Ord`. * The new `cast<U>() -> NonNull<U>` method is `#[unstable]`. It was proposed in https://github.com/rust-lang/rust/pull/46952#issuecomment-359220010.
2018-02-07libcore/libstd: fix commas in macro_rules! macrosMichael Lamparski-0/+3
BREAKING CHANGE: (or perhaps, *bugfix*) In #![no_std] applications, the following calls to `panic!` used to behave differently; they now behave the same. Old behavior: panic!("{{"); // panics with "{{" panic!("{{",); // panics with "{" New behavior: panic!("{{"); // panics with "{{" panic!("{{",); // panics with "{{" This only affects calls to `panic!` (and by proxy `assert` and `debug_assert`) with a single string literal followed by a trailing comma, and only in `#![no_std]` applications.
2018-02-07Rollup merge of #46962 - clarcharr:os_raw_docs, r=QuietMisdreavuskennytm-5/+124
Document std::os::raw. This adds a brief explanation to each type and its definition according to C. This also helps clarify that the definitions of the types, as described by rustdoc, are not necessarily the same from platform to platform.
2018-02-0638880 use search_mut function rather than search_hashedShaun Steenkamp-3/+1
2018-02-0638880 don't compute hash when searching an empty HashMapShaun Steenkamp-5/+35
This addresses issue #38880
2018-02-06fix docs linkQuietMisdreavus-1/+1
2018-02-05Simplify wait_timeout_until & fix condition typoVitali Lovich-8/+7
2018-02-06Rollup merge of #47807 - tbu-:pr_doc_constanttime_cstr, r=steveklabnikkennytm-9/+9
Make wording around 0-cost casts more precise
2018-02-05Unimplement Send/Sync for ::env::{Args,ArgsOs,Vars,VarsOs}panicbit-0/+12
2018-02-05Rollup merge of #47999 - jaystrictor:master, r=Mark-Simulacrumkennytm-1/+1
Remove 'the this' in doc comments.
2018-02-04Rollup merge of #47958 - frewsxcv:frewsxcv-try-clone, r=aidanhskennytm-7/+29
Clarify shared file handler behavior of File::try_clone. Fixes https://github.com/rust-lang/rust/issues/46578.
2018-02-04Rollup merge of #47912 - cuviper:glibc-stack-guard, r=alexcrichtonkennytm-64/+89
Use a range to identify SIGSEGV in stack guards Previously, the `guard::init()` and `guard::current()` functions were returning a `usize` address representing the top of the stack guard, respectively for the main thread and for spawned threads. The `SIGSEGV` handler on `unix` targets checked if a fault was within one page below that address, if so reporting it as a stack overflow. Now `unix` targets report a `Range<usize>` representing the guard memory, so it can cover arbitrary guard sizes. Non-`unix` targets which always return `None` for guards now do so with `Option<!>`, so they don't pay any overhead. For `linux-gnu` in particular, the previous guard upper-bound was `stackaddr + guardsize`, as the protected memory was *inside* the stack. This was a glibc bug, and starting from 2.27 they are moving the guard *past* the end of the stack. However, there's no simple way for us to know where the guard page actually lies, so now we declare it as the whole range of `stackaddr ± guardsize`, and any fault therein will be called a stack overflow. This fixes #47863.
2018-02-04Remove 'the this' in doc comments.Jay Strict-1/+1
2018-02-03Clarify shared file handler behavior of File::try_clone.Corey Farwell-7/+29
Fixes https://github.com/rust-lang/rust/issues/46578.
2018-02-03Somehow this function got flipped aroundPeter Atashian-3/+3
Unflip it
2018-02-03Go back to files directories and symlinks being mutually exclusivePeter Atashian-13/+17
Be smarter about what a symlink is however
2018-02-02Review responseVitali Lovich-8/+10
Make condition closure accept mut T&. Clarify spurious wakeup documentation. Cleanup doc example code.
2018-02-02Fix typoVitali Lovich-1/+1
2018-02-02Add Condvar APIs not susceptible to spurious wakeVitali Lovich-2/+205
Provide wait_until and wait_timeout_until helper wrappers that aren't susceptible to spurious wake.
2018-02-02Rollup merge of #47919 - varkor:to_degrees-precision, r=rkruppe Use constant ↵kennytm-0/+1
for 180/π in to_degrees The current `f32|f64.to_degrees` implementation uses a division to calculate `180/π`, which causes a loss of precision. Using a constant is still not perfect (implementing a maximally-precise algorithm would come with a high performance cost), but improves precision with a minimal change. As per the discussion in #29944, this fixes #29944 (the costs of improving the precision further would not outweigh the gains).
2018-02-01This internal only method is no longer needed.Peter Atashian-3/+0
2018-02-01Rewrite remove_dir_all to be correctPeter Atashian-3/+5
The fact that this had to be rewritten does not bode well
2018-02-01This is what FileType on Windows should ideally be.Peter Atashian-20/+19
2018-02-02Auto merge of #47102 - Diggsey:wasm-syscall, r=alexcrichtonbors-129/+260
Implement extensible syscall interface for wasm Currently it's possible to run tests with the native wasm target, but it's not possible to tell whether they pass or to capture the output, because libstd throws away stdout, stderr and the exit code. While advanced libstd features should probably require more specific targets (eg. wasm-unknown-web) I think even the unknown target should at least support basic I/O. Any solution is constrained by these factors: - It must not be javascript specific - There must not be too strong coupling between libstd and the host environment (because it's an "unknown" target) - WebAssembly does not allow "optional" imports - all imports *must* be resolved. - WebAssembly does not support calling the host environment through any channel *other* than imports. The best solution I could find to these constraints was to give libstd a single required import, and implement a syscall-style interface through that import. Each syscall is designed such that a no-op implementation gives the most reasonable fallback behaviour. This means that the following import table would be perfectly valid: ```javascript imports.env = { rust_wasm_syscall: function(index, data) {} } ``` Currently I have implemented these system calls: - Read from stdin - Write to stdout/stderr - Set the exit code - Get command line arguments - Get environment variable - Set environment variable - Get time It need not be extended beyond this set if being able to run tests for this target is the only goal. edit: As part of this PR I had to make a further change. Previously, the rust entry point would be automatically called when the webassembly module was instantiated. This was problematic because from the javascript side it was impossible to call exported functions, access program memory or get a reference to the instance. To solve this, ~I changed the default behaviour to not automatically call the entry point, and added a crate-level attribute to regain the old behaviour. (`#![wasm_auto_run]`)~ I disabled this behaviour when building tests.
2018-02-01Use constant for 180/π in to_degreesvarkor-0/+1
The current `f32|f64.to_degrees` implementation uses a division to calculate 180/π, which causes a loss of precision. Using a constant is still not perfect (implementing a maximally-precise algorithm would come with a high performance cost), but improves precision with a minimal change.
2018-01-31Use a range to identify SIGSEGV in stack guardsJosh Stone-64/+89
Previously, the `guard::init()` and `guard::current()` functions were returning a `usize` address representing the top of the stack guard, respectively for the main thread and for spawned threads. The `SIGSEGV` handler on `unix` targets checked if a fault was within one page below that address, if so reporting it as a stack overflow. Now `unix` targets report a `Range<usize>` representing the guard memory, so it can cover arbitrary guard sizes. Non-`unix` targets which always return `None` for guards now do so with `Option<!>`, so they don't pay any overhead. For `linux-gnu` in particular, the previous guard upper-bound was `stackaddr + guardsize`, as the protected memory was *inside* the stack. This was a glibc bug, and starting from 2.27 they are moving the guard *past* the end of the stack. However, there's no simple way for us to know where the guard page actually lies, so now we declare it as the whole range of `stackaddr ± guardsize`, and any fault therein will be called a stack overflow. This fixes #47863.
2018-01-31Rollup merge of #47874 - jcowgill:mips-from_raw_os_error, r=dtolnaykennytm-4/+4
std: use more portable error number in from_raw_os_error docs On MIPS, error number 98 is not `EADDRINUSE` (it is `EPROTOTYPE`). To fix the resulting test failure this causes, use a more portable error number in the example documentation. `EINVAL` shold be more reliable because it was defined in the original Unix as 22 so hopefully most derivatives have defined it the same way.
2018-01-31Auto merge of #46666 - clarcharr:duration_core, r=alexcrichtonbors-593/+1
Move Duration to libcore Fixes #46520; should be merged after #46508.