rustdoc: set panic output before starting compiler thread pool
When the compiler was updated to run on a thread pool, rustdoc's processing of compiler/doctest stderr/stdout was moved into each compiler thread. However, this caused output of the test to be lost if the test failed at *runtime* instead of compile time. This change sets up the `set_panic` call and output bomb before starting the compiler thread pool, so that the `Drop` call that writes back to the test's stdout happens after the test runs, not just after it compiles.
Fixes https://github.com/rust-lang/rust/issues/51162
doc: Clarify the lifetime returned by `Box::leak`
`Box::leak` mentions that it can return a `'static` reference, but it
wasn't immediately clear to me why it doesn't always do so. This is
because of the `T: 'a` constraint needed to form a valid reference, and
in general we want to be more flexible than requiring `T: 'static`.
This patch tries to clarify the relationship between `T` and `'a`.
Rollup of 10 pull requests
Successful merges:
- #52538 (Remove obsolete flags in the i586_musl Dockerfile)
- #52548 (Cursor: update docs to clarify Cursor only works with in-memory buffers)
- #52605 (Do not suggest using `to_owned()` on `&str += &str`)
- #52621 (Fix color detection for Windows msys terminals.)
- #52622 (Use MultiSpan in E0707 and E709)
- #52627 (Compile rustc before building tests for rustdoc)
- #52637 (Don't use NonNull::dangling as sentinel value in Rc, Arc)
- #52640 (Forget Waker when cloning LocalWaker)
- #52641 (Simplify 2 functions in rustc_mir/dataflow)
- #52642 (Replace a few expect+format combos with unwrap_or_else+panic)
Failed merges:
r? @ghost
Simplify 2 functions in rustc_mir/dataflow
- `graphviz::outgoing`: the `enumerate` only provides indices; use a range instead
- `DataflowState::interpret_set`: change a push loop to an iterator and remove the `each_bit` helper function
Forget Waker when cloning LocalWaker
Since NonNull is Copy the inner field of the cloned Waker was copied for
use in the new LocalWaker, however this left Waker to be dropped. Which
means that when cloning LocalWaker would also erroneously call drop_raw.
This change forgets the Waker, rather then dropping it, leaving the
inner field to be used by the returned LocalWaker.
Closes#52629.
Do not suggest using `to_owned()` on `&str += &str`
- Don't provide incorrect suggestion for `&str += &str` (fix#52410)
- On `&str + String` suggest `&str.to_owned() + &String` as a single suggestion
Cursor: update docs to clarify Cursor only works with in-memory buffers
Reduce misconceptions about Cursor being more general than it really is.
Fixes: #52470
rustc: Implement tokenization of nested items
Ever plagued by #43081 the compiler can return surprising spans in situations
related to procedural macros. This is exhibited by #47983 where whenever a
procedural macro is invoked in a nested item context it would fail to have
correct span information.
While #43230 provided a "hack" to cache the token stream used for each item in
the compiler it's not a full-blown solution. This commit continues to extend
this "hack" a bit more to work for nested items.
Previously in the parser the `parse_item` method would collect the tokens for an
item into a cache on the item itself. It turned out, however, that nested items
were parsed through the `parse_item_` method, so they didn't receive similar
treatment. To remedy this situation the hook for collecting tokens was moved
into `parse_item_` instead of `parse_item`.
Afterwards the token collection scheme was updated to support nested collection
of tokens. This is implemented by tracking `TokenStream` tokens instead of
`TokenTree` to allow for collecting items into streams at intermediate layers
and having them interleaved in the upper layers.
All in all, this...
Closes#47983