about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2018-09-25Auto merge of #54317 - Centril:feature/dbg_macro, r=SimonSapinbors-0/+120
Implement the dbg!(..) macro Implements the `dbg!(..)` macro due to #54306. cc https://github.com/rust-lang/rfcs/pull/2361 r? @alexcrichton
2018-09-24std: Start implementing wasm32 atomicsAlex Crichton-4/+500
This commit is an initial start at implementing the standard library for wasm32-unknown-unknown with the experimental `atomics` feature enabled. None of these changes will be visible to users of the wasm32-unknown-unknown target because they all require recompiling the standard library. The hope with this is that we can get this support into the standard library and start iterating on it in-tree to enable experimentation. Currently there's a few components in this PR: * Atomic fences are disabled on wasm as there's no corresponding atomic op and it's not clear yet what the convention should be, but this will change in the future! * Implementations of `Mutex`, `Condvar`, and `RwLock` were all added based on the atomic intrinsics that wasm has. * The `ReentrantMutex` and thread-local-storage implementations panic currently as there's no great way to get a handle on the current thread's "id" yet. Right now the wasm32 target with atomics is unfortunately pretty unusable, requiring a lot of manual things here and there to actually get it operational. This will likely continue to evolve as the story for atomics and wasm unfolds, but we also need more LLVM support for some operations like custom `global` directives for this to work best.
2018-09-24Add keyword docs for `loop`.iirelu-0/+45
2018-09-23Fixed three small typos.gardrek-3/+3
2018-09-23Auto merge of #54339 - cramertj:no-cx, r=aturonbors-36/+31
Remove spawning from task::Context r? @aturon cc https://github.com/rust-lang-nursery/wg-net/issues/56
2018-09-20dbg_macro: notes about VCS and log::debug!(..)Mazdak Farrokhzad-3/+5
2018-09-20dbg!(expr) implementation.Mazdak Farrokhzad-0/+118
2018-09-20Rollup merge of #54257 - alexcrichton:wasm-math-symbols, r=TimNNkennytm-28/+1
Switch wasm math symbols to their original names The names `Math_*` were given to help undefined symbol messages indicate how to implement them, but these are all implemented in compiler-rt now so there's no need to rename them! This change should make it so wasm binaries by default, no matter the math symbols used, will not have unresolved symbols.
2018-09-19Remove spawning from task::ContextTaylor Cramer-36/+31
2018-09-19Auto merge of #54174 - parched:park, r=alexcrichtonbors-18/+26
Fix `thread` `park`/`unpark` synchronization Previously the code below would not be guaranteed to exit when the second unpark took the `return, // already unparked` path because there was no write to synchronize with a read in `park`. EDIT: doesn't actually require third thread ``` use std::sync::atomic::{AtomicBool, Ordering}; use std::thread::{current, spawn, park}; static FLAG: AtomicBool = AtomicBool::new(false); fn main() { let thread_0 = current(); spawn(move || { thread_0.unpark(); FLAG.store(true, Ordering::Relaxed); thread_0.unpark(); }); while !FLAG.load(Ordering::Relaxed) { park(); } } ``` I have some other ideas on how to improve the performance of `park` and `unpark` using fences, avoiding any atomic RMW when the state is already `NOTIFIED`, and also how to avoid calling `notify_one` without the mutex locked. But I need to write some micro benchmarks first, so I'll submit those changes at a later date if they prove to be faster. Fixes https://github.com/rust-lang/rust/issues/53366 I hope.
2018-09-19Rework `let` keyword docsiirelu-14/+48
It didn't strictly need to be reworked and I'm not sure my version is better, but oh well, I'm doing it for consistency.
2018-09-19Document impl keywordiirelu-5/+71
This commit also splits out linky-line-thingies into two lines, which judging from the source code for tidy, should be enough to make it shut up and accept me for who I am, dammit.
2018-09-19Auto merge of #53877 - withoutboats:compositional-pin, r=aturonbors-11/+11
Update to a new pinning API. ~~Blocked on #53843 because of method resolution problems with new pin type.~~ @r? @cramertj cc @RalfJung @pythonesque anyone interested in #49150
2018-09-18Expand synchronization comments in `park`/`unpark`James Duley-8/+13
2018-09-18Rollup merge of #54313 - cgwalters:osstr-ref-cstr, r=joshtriplettGuillaume Gomez-1/+4
OsStr: Document that it's not NUL terminated I somehow got confused into thinking this was the case, but it's definitely not. Let's help the common case of people who have an `OsStr` and need to call e.g. Unix APIs.
2018-09-18Rollup merge of #53522 - phungleson:fix-impl-from-for-addr, r=TimNNGuillaume Gomez-0/+8
Add doc for impl From for Addr As part of issue #51430 (cc @skade). The impl is very simple, let me know if we need to go into any details. Additionally, I added `#[inline]` for the conversion method, let me know if it is un-necessary or might break something.
2018-09-17OsStr: Document that it's not NUL terminatedColin Walters-1/+4
I somehow got confused into thinking this was the case, but it's definitely not. Let's help the common case of people who have an `OsStr` and need to call e.g. Unix APIs.
2018-09-17Auto merge of #54247 - ↵bors-2/+3
Munksgaard:better-error-message-in-no_lookup_host_duplicates, r=alexcrichton Improve output if no_lookup_host_duplicates test fails If the test fails, output the offending addresses and a helpful error message. Also slightly improve legibility of the preceding line that puts the addresses into a HashMap.
2018-09-16Auto merge of #53910 - IsaacWoods:unify_cvoid, r=SimonSapinbors-35/+5
Move std::os::raw::c_void into libcore and re-export in libstd Implements the first part of [RFC 2521](https://github.com/rust-lang/rfcs/pull/2521). cc #53856
2018-09-16Auto merge of #53804 - RalfJung:ptr-invalid, r=nagisabors-1/+3
fix some uses of pointer intrinsics with invalid pointers [Found by miri](https://github.com/solson/miri/pull/446): * `Vec::into_iter` calls `ptr::read` (and the underlying `copy_nonoverlapping`) with an unaligned pointer to a ZST. [According to LLVM devs](https://bugs.llvm.org/show_bug.cgi?id=38583), this is UB because it contradicts the metadata we are attaching to that pointer. * `HashMap` creation calls `ptr:.write_bytes` on a NULL pointer with a count of 0. This is likely not currently UB *currently*, but it violates the rules we are setting in https://github.com/rust-lang/rust/pull/53783, and we might want to exploit those rules later (e.g. with more `nonnull` attributes for LLVM). Probably what `HashMap` really should do is use `NonNull::dangling()` instead of 0 for the empty case, but that would require a more careful analysis of the code. It seems like ideally, we should do a review of usage of such intrinsics all over libstd to ensure that they use valid pointers even when the size is 0. Is it worth opening an issue for that?
2018-09-15Switch wasm math symbols to their original namesAlex Crichton-28/+1
The names `Math_*` were given to help undefined symbol messages indicate how to implement them, but these are all implemented in compiler-rt now so there's no need to rename them! This change should make it so wasm binaries by default, no matter the math symbols used, will not have unresolved symbols.
2018-09-15Improve output if no_lookup_host_duplicates failsPhilip Munksgaard-2/+3
If the test fails, output the offending addresses and a helpful error message. Also slightly improve legibility of the preceding line that puts the addresses into a HashMap.
2018-09-14Add comments and assertion to `park`/`unpark`James Duley-2/+12
regarding the synchronization.
2018-09-14Move std::os::raw::c_void into libcore and re-export in libstdIsaac Woods-35/+5
2018-09-14Incorporate keyword doc PR critiqueiirelu-31/+36
2018-09-14Rollup merge of #54207 - QuietMisdreavus:never-docs-stab, r=kennytmkennytm-0/+1
re-mark the never docs as unstable Fixes https://github.com/rust-lang/rust/issues/54198 This stability attribute was removed in https://github.com/rust-lang/rust/pull/47630, but not replaced with a `#[stable]` attribute, and when https://github.com/rust-lang/rust/pull/50121 reverted that stabilization, it didn't set the docs back to unstable. I'm concerned as to why it was allowed to not have the stability attribute at all, but at least this can put it back. I'm nominating this for beta backport because it's a really small change, and right now our docs are in an awkward position where the `!` type is technically unstable to use, but the docs don't say so the same way any other library feature would. (And this is also the case *on stable* now, but i'm not suggesting a stable backport for a docs fix.)
2018-09-14Rollup merge of #54203 - cuviper:stable-os_str_str_ref_eq, r=estebankkennytm-2/+2
Fix the stable release of os_str_str_ref_eq This was added and stabilized in commit 02503029b83a, but while that claimed to be for 1.28.0, it didn't actually make it until 1.29.0. Fixes #54195.
2018-09-14Rollup merge of #54194 - fintelia:patch-3, r=cramertjkennytm-2/+1
Remove println!() statement from HashMap unit test
2018-09-13Entry is an enum not a structJonathan Behrens-1/+1
2018-09-13Fix links in docsJonathan Behrens-2/+7
2018-09-13Auto merge of #54168 - kennytm:rollup, r=kennytmbors-30/+38
Rollup of 11 pull requests Successful merges: - #53371 (Do not emit E0277 on incorrect tuple destructured binding) - #53829 (Add rustc SHA to released DWARF debuginfo) - #53950 (Allow for opting out of ThinLTO and clean up LTO related cli flag handling.) - #53976 (Replace unwrap calls in example by expect) - #54070 (Add Error::description soft-deprecation to RELEASES) - #54076 (miri loop detector hashing) - #54119 (Add some unit tests for find_best_match_for_name) - #54147 (Add a test that tries to modify static memory at compile-time) - #54150 (Updated 1.29 release notes with --document-private-items flag) - #54163 (Update stage 0 to latest beta) - #54170 (COMPILER_TESTS.md has been moved)
2018-09-13re-mark the never docs as unstableQuietMisdreavus-0/+1
2018-09-13Fix the stable release of os_str_str_ref_eqJosh Stone-2/+2
This was added and stabilized in commit 02503029b83a, but while that claimed to be for 1.28.0, it didn't actually make it until 1.29.0.
2018-09-13Eliminate unused variable warningJonathan Behrens-1/+1
2018-09-13Fix tests and update issue numberJonathan Behrens-138/+156
2018-09-13Remove println!() statement from HashMap unit testJonathan Behrens-1/+0
2018-09-14Rollup merge of #53829 - alexcrichton:release-debuginfo, r=michaelwoeristerkennytm-0/+4
Add rustc SHA to released DWARF debuginfo This commit updates the debuginfo that is encoded in all of our released artifacts by default. Currently it has paths like `/checkout/src/...` but these are a little inconsistent and have changed over time. This commit instead attempts to actually define the file paths in our debuginfo to be consistent between releases. All debuginfo paths are now intended to be `/rustc/$sha` where `$sha` is the git sha of the released compiler. Sub-paths are all paths into the git repo at that `$sha`.
2018-09-14Rollup merge of #53976 - GuillaumeGomez:expect-world, r=steveklabnikkennytm-30/+34
Replace unwrap calls in example by expect Part of #51668. r? @steveklabnik
2018-09-13Auto merge of #53621 - jordanrh1:windows-arm, r=alexcrichtonbors-1/+63
Add target thumbv7a-pc-windows-msvc This is an early draft of support for Windows/ARM. To test it, 1. Install Visual Studio 2017 and Windows SDK version 17134. 1. Obtain alexcrichton/xz2-rs#35, rust-lang-nursery/compiler-builtins#256, and the fix for [LLVM Bug 38620](https://bugs.llvm.org/show_bug.cgi?id=38620). 2. Open a command prompt and run ``` set CC_thumbv7a-pc-windows-msvc=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\bin\HostX64\arm\CL.exe set CFLAGS_thumbv7a-pc-windows-msvc=/D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1 /nologo c:\python27\python.exe x.py build --host x86_64-pc-windows-msvc --build x86_64-pc-windows-msvc --target thumbv7a-pc-windows-msvc ``` It will build the stage 2 compiler, but fail building stage 2 test. To build an executable targeting windows/arm, 1. Copy `build\x86_64-pc-windows-msvc\stage0\bin\cargo.exe` to `build\x86_64-pc-windows-msvc\stage2\bin` 2. Open a command prompt and run ``` "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars64.bat" set PATH=build\x86_64-pc-windows-msvc\stage2\bin;%PATH% cargo new hello cd hello cargo build --target thumbv7a-pc-windows-msvc –release ``` Copy target\thumbv7a-pc-windows-msvc\release\hello.exe to your platform and run. There are a number of open issues that I'm hoping to get help with: - Error when compiling the `test` crate: `error: cannot link together two panic runtimes: panic_abort and panic_unwind` - Warnings when building the compiler_builtins crate: `warning: cl : Command line warning D9002 : ignoring unknown option '-fvisibility=hidden'`. It looks like the build system is passing GCC-style flags to MSVC. - How to specify the LIBPATH entries for ARM. Right now they are hardcoded as absolute paths in the target spec. This pull request depends on - alexcrichton/xz2-rs#35 - update vcxproj to Visual Studio 2017 - rust-lang-nursery/compiler-builtins#256 - fix compile errors when building for windows/arm - [Bug 38620 - ARM: Incorrect COFF relocation type for thumb bl instruction](https://bugs.llvm.org/show_bug.cgi?id=38620) This PR updates #52659
2018-09-12Fix formattingJonathan Behrens-1/+2
2018-09-12Fix `thread` `park`/`unpark` synchronizationJames Duley-18/+11
Previously the code below would not be guaranteed to exit when the first spawned thread took the `return, // already unparked` path because there was no write to synchronize with a read in `park`. ``` use std::sync::atomic::{AtomicBool, Ordering}; use std::thread::{current, spawn, park}; static FLAG: AtomicBool = AtomicBool::new(false); fn main() { let thread_0 = current(); spawn(move || { FLAG.store(true, Ordering::Relaxed); thread_0.unpark(); }); let thread_0 = current(); spawn(move || { thread_0.unpark(); }); while !FLAG.load(Ordering::Relaxed) { park(); } } ```
2018-09-12Document `if` keyword.iirelu-0/+78
2018-09-12Auto merge of #53793 - toidiu:ak-stabalize, r=nikomatsakisbors-1/+0
stabilize outlives requirements https://github.com/rust-lang/rust/issues/44493 r? @nikomatsakis
2018-09-12Rollup merge of #54107 - thevaleriemack:master, r=Mark-Simulacrumkennytm-4/+4
Fix typos in libstd hash map modified growth algo description to read "the first table overflows into the second, and the second into the first." plus smaller typos
2018-09-12Rollup merge of #54064 - nagisa:tiny-typo, r=sfacklerkennytm-2/+3
`&CStr`, not `CStr`, is the counterpart of `&str`
2018-09-12Rollup merge of #54046 - snaedis:issue-48022, r=steveklabnikkennytm-1/+2
Update documentation for fill_buf in std::io::BufRead Brings the documentation in line with the BufReader implementation. Fixes #48022. This is my first PR, and I think the `E-easy` label is very cool, as so is the practice of describing the fix but leaving it for someone else; it really makes it a lot less intimidating to get started with something!
2018-09-11stabalize infer outlives requirements (RFC 2093).toidiu-1/+0
Co-authored-by: nikomatsakis
2018-09-10Document `for` keywordiirelu-0/+71
2018-09-10Add rustc SHA to released DWARF debuginfoAlex Crichton-0/+4
This commit updates the debuginfo that is encoded in all of our released artifacts by default. Currently it has paths like `/checkout/src/...` but these are a little inconsistent and have changed over time. This commit instead attempts to actually define the file paths in our debuginfo to be consistent between releases. All debuginfo paths are now intended to be `/rustc/$sha` where `$sha` is the git sha of the released compiler. Sub-paths are all paths into the git repo at that `$sha`.
2018-09-10fix typos in growth algo descriptionVal-4/+4
modified to read "the first table overflows into the second, and the second into the first." plus smaller typos