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 5 pull requests #71031

Merged
merged 14 commits into from
Apr 12, 2020
Merged

Rollup of 5 pull requests #71031

merged 14 commits into from
Apr 12, 2020

Conversation

Dylan-DPC-zz
Copy link

Successful merges:

Failed merges:

r? @ghost

nnethercote and others added 14 commits April 1, 2020 17:11
The condition checks if `sess.opts.output_types` doesn't contain
`OutputType::Assembly` within a match arm that is only reached if
`sess.opts.output_types` contains `OutputType::Assembly`.
There are three `ModuleConfigs`, one for each `ModuleKind`. The code to
initialized them is spaghetti imperative code that sets each field to a
default value and then modifies many fields in complicated ways. This
makes it very hard to tell what value ends up in each field in each
config.

For example, the `modules_config.emit_pre_lto_bc` field is set twice,
which means it can be set to true and then incorrectly set back to
false. (This probably hasn't been noticed because it happens in a very
obscure case.)

This commit changes the code to a declarative style in which
`ModuleConfig::new` initializes all fields and then they are never
changed again. This is slightly more concise and much easier to read.
(And it fixes the abovementioned `emit_pre_lto_bc` error as well.)
That way it matches `ModuleKind::Regular`.
Going along with or_insert_with, or_insert_with_key provides the
Entry's key to the lambda, avoiding the need to either clone the
key or the need to reimplement this body of this method from
scratch each time.

This is useful when the initial value for a map entry is derived
from the key. For example, the introductory Rust book has an
example Cacher struct that takes an expensive-to-compute lambda and
then can, given an argument to the lambda, produce either the
cached result or execute the lambda.
Remove the UnicodeVersion struct containing
major, minor and update fields and replace it with
a 3-tuple containing the version number.
As the value of each field is limited to 255
use u8 to store them.
…nit, r=Mark-Simulacrum

Clean up `ModuleConfig` initialization

Because it's currently a mess.

r? @Mark-Simulacrum
…etrochenkov

Fix staticlib name for *-pc-windows-gnu targets

Fix rust-lang#69904

Guess this will need FCP but opened PR anyway to bring the attention.

In short Rust has been using wrong `foo.lib` format for static libraries when building for `*-pc-windows-gnu` since version [1.8.0](rust-lang@34b4e66).
[LD](https://github.com/bminor/binutils-gdb/blob/f4a220077b03af3a1f905b7dc6dc84c0a06d582f/ld/emultempl/pe.em#L2224-L2227) and [LLD](https://github.com/llvm/llvm-project/blob/0605f5fbe755326e3dbc8daa4fc34453b8c5ac0e/lld/MinGW/Driver.cpp#L140-L141) agree in that regard and only accept static libraries with `libfoo.a` format. So the only thing to break here is when somebody added a hack to rename created library to proper format (like [here](https://gitlab.gnome.org/GNOME/librsvg/-/commit/ad86ab8580c8779fc3eb2bee2422bb116919844e#d5b4de16d947214ec306bd57bed1bd23a939b5f9_197_194)).
Add or_insert_with_key to Entry of HashMap/BTreeMap

Going along with `or_insert_with`, `or_insert_with_key` provides the `Entry`'s key to the lambda, avoiding the need to either clone the key or the need to reimplement this body of this method from scratch each time.

This is useful when the initial value for a map entry is derived from the key. For example, the introductory Rust book has an example Cacher struct that takes an expensive-to-compute lambda and then can, given an argument to the lambda, produce either the cached result or execute the lambda.

---

I'm fairly new to Rust, so any optimizations, corrections to types, better names, better documentation, or whatever else would be appreciated. I'd like to thank Arnavion on freenode for helping me to implement a very similar method when I found that `or_insert_with_key` was unavailable.

As a somewhat-related note, this implements rust-lang/rfcs#1202 from 2015, so if this pull request is accepted, that should be closed.
Store UNICODE_VERSION as a tuple

Remove the UnicodeVersion struct containing
major, minor and update fields and replace it with
a 3-tuple containing the version number.
As the value of each field is limited to 255
use u8 to store them.
… r=jonas-schievink

Use write!-style syntax for MIR assert terminator

Fixes rust-lang#71000.

r? @jonas-schievink
@Dylan-DPC-zz
Copy link
Author

@bors r+ p=5 rollup=never

@bors
Copy link
Contributor

bors commented Apr 11, 2020

📌 Commit d8dcdec 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 Apr 11, 2020
@bors
Copy link
Contributor

bors commented Apr 11, 2020

⌛ Testing commit d8dcdec with merge 1e7419326785fad853134ded9a0240d0a7d0a908...

@bors
Copy link
Contributor

bors commented Apr 11, 2020

💔 Test failed - checks-azure

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 11, 2020
@Dylan-DPC-zz
Copy link
Author

@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 11, 2020
@bors
Copy link
Contributor

bors commented Apr 11, 2020

⌛ Testing commit d8dcdec with merge 378901d...

@bors
Copy link
Contributor

bors commented Apr 12, 2020

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 12, 2020
@bors bors merged commit 378901d into rust-lang:master Apr 12, 2020
@bors bors mentioned this pull request Apr 12, 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. 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.

8 participants