rust/src/doc
Mara Bos 11ce918c75
Rollup merge of #78714 - m-ou-se:simplify-local-streams, r=KodrAus
Simplify output capturing

This is a sequence of incremental improvements to the unstable/internal `set_panic` and `set_print` mechanism used by the `test` crate:

1. Remove the `LocalOutput` trait and use `Arc<Mutex<dyn Write>>` instead of `Box<dyn LocalOutput>`. In practice, all implementations of `LocalOutput` were just `Arc<Mutex<..>>`. This simplifies some logic and removes all custom `Sink` implementations such as `library/test/src/helpers/sink.rs`. Also removes a layer of indirection, as the outermost `Box` is now gone. It also means that locking now happens per `write_fmt`, not per individual `write` within. (So `"{} {}\n"` now results in one `lock()`, not four or more.)

2. Since in all cases the `dyn Write`s were just `Vec<u8>`s, replace the type with `Arc<Mutex<Vec<u8>>>`. This simplifies things more, as error handling and flushing can be removed now. This also removes the hack needed in the default panic handler to make this work with `::realstd`, as (unlike `Write`) `Vec<u8>` is from `alloc`, not `std`.

3. Replace the `RefCell`s by regular `Cell`s. The `RefCell`s were mostly used as `mem::replace(&mut *cell.borrow_mut(), something)`, which is just `Cell::replace`. This removes an unecessary bookkeeping and makes the code a bit easier to read.

4. Merge `set_panic` and `set_print` into a single `set_output_capture`. Neither the test crate nor rustc (the only users of this feature) have a use for using these separately. Merging them simplifies things even more. This uses a new function name and feature name, to make it clearer this is internal and not supposed to be used by other crates.

Might be easier to review per commit.
2020-11-16 17:26:27 +01:00
..
book@13e1c05420 Update books 2020-10-28 10:53:15 -07:00
edition-guide@b91a9a881e Update books 2020-11-11 19:35:50 -08:00
embedded-book@ca8169e69b Update submodules for link fixes 2020-10-15 20:30:25 -04:00
man Rollup merge of #59685 - lzutao:patch-1, r=GuillaumeGomez 2019-04-04 15:09:07 +02:00
nomicon@23c49f1d5c Update books 2020-11-11 19:35:50 -08:00
reference@a7de763c21 Update books 2020-11-11 19:35:50 -08:00
rust-by-example@1886fda698 Update books 2020-11-11 19:35:50 -08:00
rustc Rollup merge of #78746 - pietroalbini:i686-freebsd, r=Mark-Simulacrum 2020-11-09 19:06:57 +01:00
rustc-dev-guide@7adfab42ba update rusct-dev-guide 2020-04-08 12:53:12 -05:00
rustdoc Auto merge of #75778 - AndyGauge:75521-rustdoc-book-improvements, r=jyn514 2020-11-06 19:01:10 +00:00
unstable-book Merge set_panic and set_print into set_output_capture. 2020-11-10 21:58:13 +01:00
complement-design-faq.md Remove the FAQs in favor of the website 2015-12-23 14:03:45 -08:00
complement-lang-faq.md Remove the FAQs in favor of the website 2015-12-23 14:03:45 -08:00
complement-project-faq.md Remove the FAQs in favor of the website 2015-12-23 14:03:45 -08:00
favicon.inc Use https URLs to refer to rust-lang.org where appropriate. 2015-08-09 14:28:46 -07:00
footer.inc rustdoc: Improve playground run buttons 2016-10-15 18:32:03 +01:00
full-toc.inc doc: add webfonts and tweak the styles accordingly 2014-04-19 21:25:35 +09:00
grammar.md Remove legacy grammar 2019-09-30 07:46:10 +02:00
guide-crates.md Grammar tweak to old guide stub documents. 2015-01-16 22:25:22 -05:00
guide-error-handling.md Convert old doc links to current edition 2019-02-13 14:39:25 +00:00
guide-ffi.md Grammar tweak to old guide stub documents. 2015-01-16 22:25:22 -05:00
guide-macros.md Grammar tweak to old guide stub documents. 2015-01-16 22:25:22 -05:00
guide-ownership.md Convert old doc links to current edition 2019-02-13 14:39:25 +00:00
guide-plugins.md Add top level sections to the Unstable Book. 2017-04-18 21:26:09 -04:00
guide-pointers.md Convert old doc links to current edition 2019-02-13 14:39:25 +00:00
guide-strings.md Grammar tweak to old guide stub documents. 2015-01-16 22:25:22 -05:00
guide-tasks.md Fix broken link in old rust guide 2015-03-04 23:18:24 +00:00
guide-testing.md Convert old doc links to current edition 2019-02-13 14:39:25 +00:00
guide-unsafe.md Grammar tweak to old guide stub documents. 2015-01-16 22:25:22 -05:00
guide.md Grammar tweak to old guide stub documents. 2015-01-16 22:25:22 -05:00
index.md Add link to rust website 2020-11-04 11:06:42 +01:00
intro.md Remove the 30 minute intro 2015-04-18 17:55:31 -04:00
not_found.md dro -> duckduckgo 2018-10-05 08:52:44 -07:00
redirect.inc Exclude old book redirect stubs from search engines 2019-03-14 22:56:38 +00:00
reference.md Redirect to the new reference 2017-02-21 14:03:13 -05:00
robots.txt Block version-specific docs from search engines 2020-03-14 02:29:35 +00:00
rust.css doc: use correct body font URLs 2019-03-24 22:06:34 -04:00
rust.md Avoid linking to a moved page in rust.html 2017-03-29 15:38:47 +02:00
rustdoc.md Move rustdoc.md into the book 2015-01-21 14:59:25 -05:00
tutorial.md Update tutorial.md 2018-05-17 12:25:24 -07:00
version_info.html.template Add alt tags for logos 2016-01-20 11:53:20 -05:00