about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2017-05-15Add links to the `thread::LocalKey` doc.Felix Raimundo-15/+30
Part of #29378 .
2017-05-12Rollup merge of #41896 - tshepang:too-long, r=steveklabnikMark Simulacrum-2/+2
doc: break into 2 sentences
2017-05-12Rollup merge of #41860 - mbrubeck:docs, r=nagisaMark Simulacrum-6/+4
Remove wrong or outdated info from CString docs. None
2017-05-11Auto merge of #41684 - jethrogb:feature/ntstatus, r=alexcrichtonbors-3/+38
Windows io::Error: also format NTSTATUS error codes `NTSTATUS` errors may be encoded as `HRESULT`, see [[MS-ERREF]](https://msdn.microsoft.com/en-us/library/cc231198.aspx). These error codes can still be formatted using `FormatMessageW` but require some different parameters to be passed in. I wasn't sure if this needed a test and if so, how to test it. Presumably we wouldn't want to make our tests dependent on localization-dependent strings returned from `FormatMessageW`. Users that get an `err: NTSTATUS` will need to do `io::Error::from_raw_os_error(err|0x1000_0000)` (the equivalent of [`HRESULT_FROM_NT`](https://msdn.microsoft.com/en-us/library/ms693780(VS.85).aspx))
2017-05-11Add testJethro Beekman-0/+14
2017-05-11doc: break into 2 sentencesTshepang Lekhonkhobe-2/+2
2017-05-11Rollup merge of #41192 - zackw:eprintln, r=alexcrichtonCorey Farwell-24/+86
Add `eprint!` and `eprintln!` macros to the prelude. These are exactly the same as `print!` and `println!` except that they write to stderr instead of stdout. Issues #39228 and #40528; previous PR #39229; accepted RFC rust-lang/rfcs#1869; proposed revision to The Book rust-lang/book#615. I have _not_ revised this any since the original submission; I will do that later this week. I wanted to get this PR in place since it's been quite a while since the RFC was merged. Known outstanding review comments: * [x] @steveklabnik requested a new chapter for the unstable version of The Book -- please see if the proposed revisions to the second edition cover it. * [x] @nodakai asked if it were possible to merge the internal methods `_print` and `_eprint` - not completely, since they both refer to different internal globals which we don't want to expose, but I will see if some duplication can be factored out. Please let me know if I missed anything.
2017-05-10Rollup merge of #41854 - gamazeps:thread-spawn-doc, r=steveklabnikSteve Klabnik-6/+56
[Doc] Improve `thread::spawn` documentation Part of #29378 - Add two examples to `thread::spawn` doumentation that show common uses of threads. - Add a link to `thread::Builder` in the `thread::spawn` documentation for configuring threads. - Add a link to `thread::spawn` in `thread::Builder` in order to avoid documentation duplication. r? @steveklabnik
2017-05-10Rollup merge of #41809 - gamazeps:thread-docs, r=steveklabnikSteve Klabnik-61/+91
[DOC] Improve the thread::park and thread::unpark documentation Part of #29378 . Takes care of the documentation for `park`, `park_duration` and also improves the `unpark` example. - `park should` have its module documentation inlined here, and cleaned up. - `park_timeout` could use links to `park`.
2017-05-10Rollup merge of #41531 - steveklabnik:gh40159, r=nagisaSteve Klabnik-1/+35
Add more ways to create a PathBuf to docs The best way to do this wasn't in the documentation, and the ways that were there needed some extra text to elaborate. Fixes #40159 /cc @nagisa
2017-05-10Fix up stability annotations per feedback.Zack Weinberg-7/+7
2017-05-10Revise the eprint(ln)! feature.Zack Weinberg-58/+37
* Factor out the nigh-identical bodies of `_print` and `_eprint` to a helper function `print_to` (I was sorely tempted to call it `_doprnt`). * Update the issue number for the unstable `eprint` feature. * Add entries to the "unstable book" for `eprint` and `eprint_internal`. * Style corrections to the documentation.
2017-05-10Add `eprint!` and `eprintln!` macros to the prelude.Zack Weinberg-0/+83
These are exactly the same as `print!` and `println!` except that they write to stderr instead of stdout. Issue #39228.
2017-05-10Auto merge of #41815 - Yamakaky:improve-backtrace-bottom, r=alexcrichtonbors-8/+47
Improve cleaning of the bottom of the backtrace Following https://github.com/rust-lang/rust/pull/40264. It only cleans the bottom of the trace (after the main). It handles correctly the normal main, tests, benchmarks and threads. I kept `skipped_before` since it will be used later for the cleaning of the top.
2017-05-10Fix typos in docFelix Raimundo-1/+1
2017-05-09Remove wrong or outdated info from CString docs.Matt Brubeck-6/+4
2017-05-09Don't show the std frames before user code on unwinding.Yamakaky-8/+47
When `RUST_BACKTRACE=1`, remove all frames after `__rust_maybe_catch_panic`. Tested on `main`, threads, tests and benches. Cleaning of the top of the stacktrace is let to a future PR. Fixes #40201 See #41815
2017-05-09Fix warnings in examplesFelix Raimundo-4/+4
2017-05-09Fix linkFelix Raimundo-5/+5
2017-05-09Add more ways to create a PathBuf to docssteveklabnik-1/+35
The best way to do this wasn't in the documentation, and the ways that were there needed some extra text to elaborate. Fixes #40159
2017-05-09Auto merge of #41814 - gamazeps:thread-struct-doc, r=steveklabnikbors-23/+20
[Doc] improve `thread::Thread` and `thread::Builder` documentations Part of #29378 - Adds information about the stack_size when using `Builder`. This might be considered too low level, but I assume that if someone wants to create their own builder instead of using `thread::spawn` they may be interested in that info. - Updates the `thread::Thread` structure doc, mostly by explaining how to get one, the previous example was removed because it was not related to `thread::Thread`, but rather to `thread::Builder::name`. Not much is present there, mostly because this API is not often used (the only method that seems useful is `unpark`, which is documented in #41809).
2017-05-09Address review commentsFelix Raimundo-2/+2
2017-05-09Address review commentsFelix Raimundo-2/+4
2017-05-09Add a link to `thread::Builder` in `thread::spawn`Felix Raimundo-0/+5
2017-05-09Add more examples to `thread::spawn`Felix Raimundo-6/+51
Part of #29378
2017-05-08Remove need for &format!(...) or &&"" dances in `span_label` callsOliver Schneider-1/+1
2017-05-07Fix typos in `thread::park` documentation.Felix Raimundo-4/+6
2017-05-07Update the `thread::Thread` documentation.Felix Raimundo-24/+12
- Copied the module documentation to `Thread`. - Removed the example because it did not use any method of Thread.
2017-05-07Add stack size doc to `thread::spawn`.Felix Raimundo-0/+7
Part of #29378
2017-05-07Inline `thread::park` documentation.Felix Raimundo-52/+62
Part of #29378 - Moves the module documentation into `park`. - Add the same example as the one from `unpark` to `park`.
2017-05-07Improve `thread::panicking` documentaion.Felix Raimundo-0/+12
Part of #29378
2017-05-07fix typoFelix Raimundo-2/+2
2017-05-07Better example for `thread::unpark`.Felix Raimundo-5/+12
Part of #29378
2017-05-07Add `park` info to `unpark`.Felix Raimundo-1/+8
- Adds an explanantion of what `park` does in the `unpark` documentation. - Adds a link to the module doc.
2017-05-07Add link to the module doc in `park_timeout`.Felix Raimundo-1/+2
Part of #29378
2017-05-07Add a link to `park` in the `park_timeout` doc.Felix Raimundo-6/+9
Part of #29378
2017-05-06Fix definitions of ULONG_PTRJoshua Sheard-3/+4
2017-05-06Auto merge of #41768 - rap2hpoutre:patch-4, r=frewsxcvbors-0/+22
Add an example to std::thread::Result type This PR is a part of https://github.com/rust-lang/rust/issues/29378. I submit this PR with the help (mentoring) of @steveklabnik. I'm still not sure my request is good enough but I don't want to spoil the issue with too much questions so I continue here. r? @steveklabnik
2017-05-05Auto merge of #41773 - frewsxcv:rollup, r=frewsxcvbors-128/+128
Rollup of 9 pull requests - Successful merges: #41064, #41307, #41512, #41582, #41678, #41722, #41734, #41761, #41763 - Failed merges:
2017-05-05Rollup merge of #41582 - jonhoo:reread-nameservers-on-lookup-fail, ↵Corey Farwell-3/+21
r=alexcrichton Reload nameserver information on lookup failure As discussed in #41570, UNIX systems often cache the contents of `/etc/resolv.conf`, which can cause lookup failures to persist even after a network connection becomes available. This patch modifies lookup_host to force a reload of the nameserver entries following a lookup failure. This is in line with what many C programs already do (see #41570 for details). On systems with nscd, this should not be necessary, but not all systems run nscd. Fixes #41570. Depends on rust-lang/libc#585. r? @alexcrichton
2017-05-05Rollup merge of #41512 - alexcrichton:fix-windows-tls-deadlock, r=BurntSushiCorey Farwell-115/+93
std: Avoid locks during TLS destruction on Windows Gecko recently had a bug reported [1] with a deadlock in the Rust TLS implementation for Windows. TLS destructors are implemented in a sort of ad-hoc fashion on Windows as it doesn't natively support destructors for TLS keys. To work around this the runtime manages a list of TLS destructors and registers a hook to get run whenever a thread exits. When a thread exits it takes a look at the list and runs all destructors. Unfortunately it turns out that there's a lock which is held when our "at thread exit" callback is run. The callback then attempts to acquire a lock protecting the list of TLS destructors. Elsewhere in the codebase while we hold a lock over the TLS destructors we try to acquire the same lock held first before our special callback is run. And as a result, deadlock! This commit sidesteps the issue with a few small refactorings: * Removed support for destroying a TLS key on Windows. We don't actually ever exercise this as a public-facing API, and it's only used during `lazy_init` during racy situations. To handle that we just synchronize `lazy_init` globally on Windows so we never have to call `destroy`. * With no need to support removal the global synchronized `Vec` was tranformed to a lock-free linked list. With the removal of locks this means that iteration no long requires a lock and as such we won't run into the deadlock problem mentioned above. Note that it's still a general problem that you have to be extra super careful in TLS destructors. For example no code which runs a TLS destructor on Windows can call back into the Windows API to do a dynamic library lookup. Unfortunately I don't know of a great way around that, but this at least fixes the immediate problem that Gecko was seeing which is that with "well behaved" destructors the system would still deadlock! [1]: https://bugzilla.mozilla.org/show_bug.cgi?id=1358151
2017-05-05Rollup merge of #41064 - Gankro:ptr-redux, r=alexcrichtonCorey Farwell-10/+14
refactor NonZero, Shared, and Unique APIs Major difference is that I removed Deref impls, as apparently LLVM has trouble maintaining metadata with a `&ptr -> &ptr` API. This was cited as a blocker for ever stabilizing this API. It wasn't that ergonomic anyway. * Added `get` to NonZero to replace Deref impl * Added `ptr` getter to Shared/Unique to replace Deref impl * Added Unique's `get` and `get_mut` conveniences to Shared * Deprecated `as_mut_ptr` on Shared in favour of `ptr` Note that Shared used to primarily expose only `*const` but there isn't a good justification for that, so I made it `*mut`.
2017-05-05std: Prevent deadlocks in doctests on WindowsAlex Crichton-1/+3
Windows historically has problems with threads panicking and the main thread exiting at the same time, typically causing deadlocks. In the past (#25824) we've joined on threads but this just prevents running the test for now to avoid tampering with the example.
2017-05-05std: Avoid locks during TLS destruction on WindowsAlex Crichton-115/+93
Gecko recently had a bug reported [1] with a deadlock in the Rust TLS implementation for Windows. TLS destructors are implemented in a sort of ad-hoc fashion on Windows as it doesn't natively support destructors for TLS keys. To work around this the runtime manages a list of TLS destructors and registers a hook to get run whenever a thread exits. When a thread exits it takes a look at the list and runs all destructors. Unfortunately it turns out that there's a lock which is held when our "at thread exit" callback is run. The callback then attempts to acquire a lock protecting the list of TLS destructors. Elsewhere in the codebase while we hold a lock over the TLS destructors we try to acquire the same lock held first before our special callback is run. And as a result, deadlock! This commit sidesteps the issue with a few small refactorings: * Removed support for destroying a TLS key on Windows. We don't actually ever exercise this as a public-facing API, and it's only used during `lazy_init` during racy situations. To handle that we just synchronize `lazy_init` globally on Windows so we never have to call `destroy`. * With no need to support removal the global synchronized `Vec` was tranformed to a lock-free linked list. With the removal of locks this means that iteration no long requires a lock and as such we won't run into the deadlock problem mentioned above. Note that it's still a general problem that you have to be extra super careful in TLS destructors. For example no code which runs a TLS destructor on Windows can call back into the Windows API to do a dynamic library lookup. Unfortunately I don't know of a great way around that, but this at least fixes the immediate problem that Gecko was seeing which is that with "well behaved" destructors the system would still deadlock! [1]: https://bugzilla.mozilla.org/show_bug.cgi?id=1358151
2017-05-05Update mod.rsRaphaël Huchet-1/+1
2017-05-05Add an example to std::thread::Result typeRaphaël Huchet-0/+22
2017-05-04Reload nameserver information on lookup failureJon Gjengset-3/+21
As discussed in #41570, UNIX systems often cache the contents of /etc/resolv.conf, which can cause lookup failures to persist even after a network connection becomes available. This patch modifies lookup_host to force a reload of the nameserver entries following a lookup failure. This is in line with what many C programs already do (see #41570 for details). On systems with nscd, this should not be necessary, but not all systems run nscd. Introduces an std linkage dependency on libresolv on macOS/iOS (which also makes it necessary to update run-make/tools.mk). Fixes #41570. Depends on rust-lang/libc#585.
2017-05-04Deprecate heap::EMPTY in favour of Unique::empty or otherwise.Alexis Beingessner-1/+2
2017-05-04fallout from NonZero/Unique/Shared changesAlexis Beingessner-9/+12
2017-05-04Update mod.rsRaphaël Huchet-1/+1