rust/src
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
..
bootstrap Auto merge of #79074 - Mark-Simulacrum:fix-ci-llvm, r=jyn514 2020-11-16 00:40:04 +00:00
build_helper Fix even more URLs 2020-11-05 20:11:29 +01:00
ci explicitly add llvm-9-dev in dockerfile 2020-11-12 14:39:47 +01:00
doc Rollup merge of #78714 - m-ou-se:simplify-local-streams, r=KodrAus 2020-11-16 17:26:27 +01:00
etc lldb_batchmode: show more error information 2020-11-03 12:01:46 +01:00
librustdoc Rollup merge of #78678 - Nemo157:doc-cfg-w-traits, r=jyn514,GuillaumeGomez 2020-11-16 17:26:25 +01:00
llvm-project@ee16174578 Bump LLVM for DeadArgElim fix 2020-10-22 18:37:03 -04:00
test Rollup merge of #78714 - m-ou-se:simplify-local-streams, r=KodrAus 2020-11-16 17:26:27 +01:00
tools Auto merge of #79064 - ehuss:rustbook-logs, r=Mark-Simulacrum 2020-11-15 15:39:58 +00:00
README.md Update README.md 2020-08-30 13:40:11 -05:00
stage0.txt Rollup merge of #77877 - scottmcm:fewer-try-trait-method-references, r=shepmaster 2020-10-19 18:20:20 +02:00
version bump version to 1.50.0 2020-11-13 09:47:16 +01:00

This directory contains the source code of the rust project, including:

  • The test suite
  • The bootstrapping build system
  • Various submodules for tools, like rustdoc, rls, etc.

For more information on how various parts of the compiler work, see the rustc dev guide.