Currently, `Symbol::Debug` and `Symbol::Display` produce the same
output; neither wraps the symbol in double quotes.
This commit changes `Symbol::Debug` so it wraps the symbol in quotes.
This change brings `Symbol`'s behaviour in line with `String` and
`InternedString`. The change requires a couple of trivial test output
adjustments.
Likewise for `NestedMetaItem::tokens()`. Also, add
`MetaItemKind::token_trees_and_joints()`, which `MetaItemKind::tokens()`
now calls.
This avoids some unnecessary `TokenTree` to `TokenStream` conversions,
and removes the need for the clumsy
`TokenStream::append_to_tree_and_joint_vec()`.
The current code has this impl:
```
impl<T: Into<TokenStream>> iter::FromIterator<T> for TokenStream
```
If given an `IntoIterator<Item = TokenTree>`, it will convert each individual
`TokenTree` to a `TokenStream` (at the cost of two allocations: a `Vec`
and an `Lrc`). It will then merge those `TokenStream`s into a single
`TokenStream`. This is inefficient.
This commit changes the impl to this less general one:
```
impl iter::FromIterator<TokenTree> for TokenStream
```
It collects the `TokenTree`s into a single `Vec` first and then converts that
to a `TokenStream` by wrapping it in a single `Lrc`. The previous generality
was unnecessary; no other code needs changing.
This change speeds up several benchmarks by up to 4%.
Add a target setting to allow targets to specify whether the generated
`main` function should be passed `argc` and `argv` arguments. Set it
to false on wasm32-wasi, since WASI's `args::args()` calls into the
WASI APIs itself. This will allow the WASI toolchain to avoid linking
and running command-line argument initialization code when the arguments
aren't actually needed.
Rollup of 8 pull requests
Successful merges:
- #65237 (Move debug_map assertions after check for err)
- #65316 (make File::try_clone produce non-inheritable handles on Windows)
- #65319 (InterpCx: make memory field public)
- #65461 (Don't recommend ONCE_INIT in std::sync::Once)
- #65465 (Move syntax::ext to a syntax_expand and refactor some attribute logic)
- #65475 (add example for type_name)
- #65478 (fmt::Write is about string slices, not byte slices)
- #65486 (doc: fix typo in OsStrExt and OsStringExt)
Failed merges:
r? @ghost
Optimize dropck
This does two things: caches the `trivial_dropck` check by making it a query, and shifts around the implementation of the primary dropck itself to avoid allocating many small vectors.
Building Servo with a recent Nightly produces:
```rust
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/issues/29597
--> components/script/lib.rs:14:1
|
14 | #![plugin(script_plugins)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
|
= note: `#[warn(deprecated)]` on by default
```
First, linking to https://github.com/rust-lang/rust/issues/29597 is not ideal
since there is pretty much no discussion there of the deprecation
and what can be used instead.
This PR changes the link to the deprecation PR which does have more discussion.
Second, the “remove this attribute” suggestion is rather unhelpful.
Just because a feature is deprecated doesn’t mean that simply removing its use
without a replacement is acceptable.
In the case of custom lint, there is no replacement available.
Prefixing a message with “help:” when telling users that they’re screwed
honestly feels disrespectful.
This PR also changes the message to be more factual.
Don't recommend ONCE_INIT in std::sync::Once
ONCE_INIT is deprecated, and so suggesting it as not only being on par with, but before `Once::new` is a bad idea.
InterpCx: make memory field public
I made this field private forever ago because I thought sealing things might be nice. But with the `memory_mut` getter it doesn't actually seal anything, and it's not like we need to invalidate caches on writes to memory or so. And moreover, having to use the getters leads to some annoying borrow checking interactions.
So, let's just make it public (again).
r? @oli-obk
make File::try_clone produce non-inheritable handles on Windows
~**NOT READY FOR REVIEW.** This PR is currently mainly to trigger CI so that I can see what happens. (Is there a better way to trigger CI?) I don't know whether this change makes sense yet.~ (Edit: @Mark-Simulacrum clarified that CI doesn't currently run on Windows.)
---
File handles shouldn't be inheritable in general.
`std::process::Command` takes care of making them inheritable when child
processes are spawned, and the `CREATE_PROCESS_LOCK` protects against
races in that section on Windows. But `File::try_clone` has been
creating inheritable file descriptors outside of that lock, which could
be leaking into other child processes unintentionally.
See also https://github.com/rust-lang/rust/pull/31069#discussion_r334117665.
Move debug_map assertions after check for err
Fixes#65231
We have some assertions in `DebugMap` to catch broken implementations of `Debug` that produce malformed entries. These checks don't make sense if formatting fails partway through. This PR moves those assertions to within the `and_then` closures along with the other formatting logic, so they're only checked if the map hasn't failed to format an entry already.
rustc_metadata: replace Entry table with one table for each of its fields (AoS -> SoA).
In https://github.com/rust-lang/rust/pull/59789#issuecomment-481958212 I noticed that for many cross-crate queries (e.g. `predicates_of(def_id)`), we were deserializing the `rustc_metadata::schema::Entry` for `def_id` *only* to read one field (i.e. `predicates`).
But there are several such queries, and `Entry` is not particularly small (in terms of number of fields, the encoding itself is quite compact), so there is a large (and unnecessary) constant factor.
This PR replaces the (random-access) array¹ of `Entry` structures ("AoS"), with many separate arrays¹, one for each field that used to be in `Entry` ("SoA"), resulting in the ability to read individual fields separately, with negligible time overhead (in thoery), and some size overhead (as these arrays are not sparse).
In a way, the new approach is closer to incremental on-disk caches, which store each query's cached results separately, but it would take significantly more work to unify the two.
For stage1 `libcore`'s metadata blob, the size overhead is `8.44%`, and I have another commit (~~not initially included because I want to do perf runs with both~~ **EDIT**: added it now) that brings it down to `5.88%`.
¹(in the source, these arrays are called "tables", but perhaps they could use a better name)
Upgrade Emscripten targets to use upstream LLVM backend
- Compatible with Emscripten 1.38.46-upstream or later upstream.
- Refactors the Emscripten target spec to share code with other wasm
targets.
- Replaces the old incorrect wasm32 C call ABI with the correct one,
preserving the old one as wasm32_bindgen_compat for wasm-bindgen
compatibility.
- Updates the varargs ABI used by Emscripten and deletes the old one.
- Removes the obsolete wasm32-experimental-emscripten target.
- Uses EMCC_CFLAGS on CI to avoid the timeout problems with #63649.
r? @alexcrichton