Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #69118

Merged
merged 27 commits into from
Feb 13, 2020
Merged

Rollup of 9 pull requests #69118

merged 27 commits into from
Feb 13, 2020

Conversation

Dylan-DPC-zz
Copy link

Successful merges:

Failed merges:

r? @ghost

Mark-Simulacrum and others added 27 commits December 26, 2019 13:55
No functional changes are made, and all APIs are moved to strictly less
restrictive bounds.

These APIs changed from the old bound listed to no trait bounds:

K: Hash + Eq
* new
* with_capacity

K: Eq + Hash, S: BuildHasher
* with_hasher
* with_capacity_and_hasher
* hasher

K: Eq + Hash + Debug -> K: Debug
S: BuildHasher -> S
<HashMap as Debug>

K: Eq + Hash -> K
S: BuildHasher + Default -> S: Default
<HashMap as Default>
No functional changes are made, and all APIs are moved to strictly less
restrictive bounds.

These APIs changed from the old bound listed to the new bound:

T: Hash + Eq -> T
* new
* with_capacity

T: Eq + Hash, S: BuildHasher -> T
* with_hasher
* with_capacity_and_hasher
* hasher

T: Eq + Hash + Debug -> T: Debug
S: BuildHasher -> S
<HashSet as Debug>

T: Eq + Hash -> T
S: BuildHasher + Default -> S: Default
<HashSet as Default>
Currently, every iteration of the main loop in `generic_extension`
instantiates a `Parser`, which is expensive because `Parser` is a large
type. Many of those instantiations are only used immutably, particularly
for simple-but-repetitive macros of the sort seen in `html5ever` and PR
68836.

This commit initializes a single "base" parser outside the loop, and
then uses `Cow` to avoid cloning it except for the mutating iterations.
This speeds up `html5ever` runs by up to 15%.
The previous commit wrapped `Parser` within a `Cow` for the hot macro
parsing path. As a result, there's no need for the `Cow` within
`Directory`, because it lies within `Parser`.
This is a small win, because `Failure` is much more common than
`Success`.
Fixes rust-lang#67844

Previously, opaque types would only get parent generics if they
a return-position-impl-trait (e.g. `fn foo<A>() -> impl MyTrait<A>`).

However, it's possible for opaque types to be nested inside one another:

```rust
trait WithAssoc { type AssocType; }

trait WithParam<A> {}

type Return<A> = impl WithAssoc<AssocType = impl WithParam<A>>;
```

When this occurs, we need to ensure that the nested opaque types
properly inherit generic parameters from their parent opaque type.

This commit fixes the `generics_of` query to take the parent item
into account when determining the generics for an opaque type.
*Total -- 10.65kb -> 8.44kb (20.82%)

/src/etc/installer/gfx/rust-logo.png -- 5.71kb -> 3.82kb (33.11%)
/src/librustdoc/html/static/down-arrow.svg -- 0.63kb -> 0.50kb (20.44%)
/src/librustdoc/html/static/wheel.svg -- 3.86kb -> 3.68kb (4.66%)
/src/librustdoc/html/static/brush.svg -- 0.47kb -> 0.44kb (4.61%)

Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com>
This commit makes the following writing improvements:
- Removes the unnecessary `write_to_vec` function.
- Reduces the number of conditions per loop from 2 to 1.
- Avoids a mask and a shift on the final byte.

And the following reading improvements:
- Removes an unnecessary type annotation.
- Fixes a dangerous unchecked slice access. Imagine a slice `[0x80]` --
  the current code will read past the end of the slice some number of
  bytes. The bounds check at the end will subsequently trigger, unless
  something bad (like a crash) happens first. The cost of doing bounds
  check in the loop body is negligible.
- Avoids a mask on the final byte.

And the following improvements for both reading and writing:
- Changes `for` to `loop` for the loops, avoiding an unnecessary
  condition on each iteration. This also removes the need for
  `leb128_size`.

All of these changes give significant perf wins, up to 5%.
When encountering E0212, detect whether this is a representable case or
not, i.e. if it's happening on an `fn` or on an ADT. If the former,
provide a structured suggestion, otherwise note that this can't be
represented in Rust.
…nieu

Relax bounds on HashMap/HashSet

These APIs changed from the old bound listed to the new bound (possibly empty):

K: Hash + Eq -> K
* new
* with_capacity

K: Eq + Hash, S: BuildHasher -> K, S
* with_hasher
* with_capacity_and_hasher
* hasher

K: Eq + Hash + Debug -> K: Debug
S: BuildHasher -> S
HashMap as Debug

K: Eq + Hash -> K
S: BuildHasher + Default -> S: Default
HashMap as Default

Resolves rust-lang#44777.
…atthewjasper

Properly use parent generics for opaque types

Fixes rust-lang#67844

Previously, opaque types would only get parent generics if they
a return-position-impl-trait (e.g. `fn foo<A>() -> impl MyTrait<A>`).

However, it's possible for opaque types to be nested inside one another:

```rust
trait WithAssoc { type AssocType; }

trait WithParam<A> {}

type Return<A> = impl WithAssoc<AssocType = impl WithParam<A>>;
```

When this occurs, we need to ensure that the nested opaque types
properly inherit generic parameters from their parent opaque type.

This commit fixes the `generics_of` query to take the parent item
into account when determining the generics for an opaque type.
Suggestion when encountering assoc types from hrtb

When encountering E0212, detect whether this is a representable case or
not, i.e. if it's happening on an `fn` or on an ADT. If the former,
provide a structured suggestion, otherwise note that this can't be
represented in Rust.

Fix rust-lang#69000.
…r=GuillaumeGomez

Optimize image sizes

This was done by [ImgBot](https://imgbot.net/) on my own fork, which I then immediately merged and turned into this manual pull request. Below is reproduced [ImgBot's own message](pthariensflame#3 (comment)) on the content of this PR.

r? @steveklabnik since this is a documentation PR, I guess.

---

> ## Beep boop. Your images are optimized!
>
> Your image file size has been reduced by **21%** 🎉
>
> <details>
> <summary>
> Details
> </summary>
>
> | File | Before | After | Percent reduction |
> |:--|:--|:--|:--|
> | /src/etc/installer/gfx/rust-logo.png | 5.71kb | 3.82kb | 33.11% |
> | /src/librustdoc/html/static/down-arrow.svg | 0.63kb | 0.50kb | 20.44% |
> | /src/librustdoc/html/static/wheel.svg | 3.86kb | 3.68kb | 4.66% |
> | /src/librustdoc/html/static/brush.svg | 0.47kb | 0.44kb | 4.61% |
> | | | | |
> | **Total :** | **10.65kb** | **8.44kb** | **20.82%** |
> </details>
>
> ---
>
> [📝docs](https://imgbot.net/docs) | [:octocat: repo](https://github.com/dabutvin/ImgBot) | [🙋issues](https://github.com/dabutvin/ImgBot/issues) | [🏅swag](https://goo.gl/forms/1GX7wlhGEX8nkhGO2) | [🏪marketplace](https://github.com/marketplace/imgbot)
…r=michaelwoerister

Micro-optimize the heck out of LEB128 reading and writing.

This commit makes the following writing improvements:
- Removes the unnecessary `write_to_vec` function.
- Reduces the number of conditions per loop from 2 to 1.
- Avoids a mask and a shift on the final byte.

And the following reading improvements:
- Removes an unnecessary type annotation.
- Fixes a dangerous unchecked slice access. Imagine a slice `[0x80]` --
  the current code will read past the end of the slice some number of
  bytes. The bounds check at the end will subsequently trigger, unless
  something bad (like a crash) happens first. The cost of doing bounds
  check in the loop body is negligible.
- Avoids a mask on the final byte.

And the following improvements for both reading and writing:
- Changes `for` to `loop` for the loops, avoiding an unnecessary
  condition on each iteration. This also removes the need for
  `leb128_size`.

All of these changes give significant perf wins, up to 5%.

r? @michaelwoerister
…jethrogb,nagisa

Make the SGX arg cleanup implementation a NOP

fixes rust-lang#64304

cc @jethrogb
When expecting `BoxFuture` and using `async {}`, suggest `Box::pin`

Fix rust-lang#68197, cc rust-lang#69083.
…ulacrum

bootstrap: Configure cmake when building sanitizer runtimes

Configure cmake before building sanitizer runtimes in similar way it is already
configured elsewhere, to ensure that they are built with expected compiler
flags.

Previously this step has been intentionally omitted since sanitizer runtimes
are built as universal binaries on Darwin targets, which in turn are
unsupported by sccache which is also configured there. To avoid the issue
everything but the compiler launcher is configured.

Helps with rust-lang#68863.
@Dylan-DPC-zz
Copy link
Author

@bors r+ rollup=never p=9

@bors
Copy link
Contributor

bors commented Feb 13, 2020

📌 Commit 1ddf250 has been approved by Dylan-DPC

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Feb 13, 2020
@Dylan-DPC-zz Dylan-DPC-zz added the rollup A PR which is a rollup label Feb 13, 2020
@bors
Copy link
Contributor

bors commented Feb 13, 2020

⌛ Testing commit 1ddf250 with merge 2e6eace...

bors added a commit that referenced this pull request Feb 13, 2020
Rollup of 9 pull requests

Successful merges:

 - #67642 (Relax bounds on HashMap/HashSet)
 - #68848 (Hasten macro parsing)
 - #69008 (Properly use parent generics for opaque types)
 - #69048 (Suggestion when encountering assoc types from hrtb)
 - #69049 (Optimize image sizes)
 - #69050 (Micro-optimize the heck out of LEB128 reading and writing.)
 - #69068 (Make the SGX arg cleanup implementation a NOP)
 - #69082 (When expecting `BoxFuture` and using `async {}`, suggest `Box::pin`)
 - #69104 (bootstrap: Configure cmake when building sanitizer runtimes)

Failed merges:

r? @ghost
@bors
Copy link
Contributor

bors commented Feb 13, 2020

☀️ Test successful - checks-azure
Approved by: Dylan-DPC
Pushing 2e6eace to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 13, 2020
@bors bors merged commit 1ddf250 into rust-lang:master Feb 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. rollup A PR which is a rollup S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants