bors [Fri, 30 Oct 2020 14:24:02 +0000 (14:24 +0000)]
Auto merge of #78424 - jyn514:THE-PAPERCLIP-COMETH, r=davidtwco
Fix some more clippy warnings
Found while working on https://github.com/rust-lang/rust/pull/77351. It turns out that `x.py clippy --fix` does work on that branch as long as you pass `CARGOFLAGS=--lib`.
Yuki Okushi [Fri, 30 Oct 2020 09:00:45 +0000 (18:00 +0900)]
Rollup merge of #77888 - LingMan:ast_pretty_tt_prepend_space, r=jyn514
Simplify a nested bool match
Logically this first eliminates the innermost match by merging the patterns.
Then, in a second step, turns the newly innermost match into a `matches!` call.
bors [Fri, 30 Oct 2020 07:05:57 +0000 (07:05 +0000)]
Auto merge of #78393 - SNCPlay42:match-if-guard, r=tmandry
Always record reference to binding in match if guards
When encountering a binding from a `match` pattern in its `if` guard when computing a generator's interior types, we must always record the type of a reference to the binding because of how `if` guards are lowered to MIR. This was missed in #75213 because the binding in that test case was autorefed and we recorded that adjusted type anyway.
In #75671 `clippy::temporary_cstr_as_ptr` was removed instead of being deprecated. This will trigger an error (unknown lint) for users that refer to that lint to e.g. allow it, instead of a more informative warning.
Jonas Schievink [Thu, 29 Oct 2020 16:05:28 +0000 (17:05 +0100)]
Rollup merge of #78499 - SkiFire13:fix-string-retain, r=m-ou-se
Prevent String::retain from creating non-utf8 strings when abusing panic
Fixes #78498
The idea is the same as `Vec::drain`, set the len to 0 so that nobody can observe the broken invariant if it escapes the function (in this case if `f` panics)
Jonas Schievink [Thu, 29 Oct 2020 16:05:26 +0000 (17:05 +0100)]
Rollup merge of #78493 - ehuss:update-cargo, r=ehuss
Update cargo
8 commits in dd83ae55c871d94f060524656abab62ec40b4c40..becb4c282b8f37469efb8f5beda45a5501f9d367
2020-10-20 19:31:26 +0000 to 2020-10-28 16:41:55 +0000
- List available packages if providing `--package` with an empty value (rust-lang/cargo#8808)
- Add a future-compatibility warning on allowed feature name characters. (rust-lang/cargo#8814)
- New namespaced features implementation. (rust-lang/cargo#8799)
- Remove redundant "For example, " (rust-lang/cargo#8810)
- Document platform-specific build-dependencies (rust-lang/cargo#8809)
- Remove some unused code. (rust-lang/cargo#8807)
- Some minor clippy fixes. (rust-lang/cargo#8804)
- Update TOML website links. (rust-lang/cargo#8803)
Jonas Schievink [Thu, 29 Oct 2020 16:05:23 +0000 (17:05 +0100)]
Rollup merge of #78462 - danielframpton:fixnullisa, r=nagisa
Use unwrapDIPtr because the Scope may be null.
I ran into an assertion when using debug information on Windows with LLVM assertions enabled.
It seems like we are using unwrap here (which in turn calls isa and requires the pointer to be non-null) but we expect the value to be null because that is what we are passing from rustc.
This change uses unwrapDIPtr which explicitly allows nullptr.
The FFI prototype for this method on the rust side has the `LLVMMetadataRef` parameter as `Scope: Option<&'a DIScope>`, and we always pass `None` when `msvc_like_names` is true.
Jonas Schievink [Thu, 29 Oct 2020 16:05:17 +0000 (17:05 +0100)]
Rollup merge of #78423 - tgnottingham:caching_source_map_bounds_check, r=oli-obk
rustc_span: improve bounds checks in byte_pos_to_line_and_col
The effect of this change is to consider edge-case spans that start or
end at the position one past the end of a file to be valid during span
hashing and encoding. This change means that these spans will be
preserved across incremental compilation sessions when they are part of
a serialized query result, instead of causing the dummy span to be used.
Jonas Schievink [Thu, 29 Oct 2020 16:05:11 +0000 (17:05 +0100)]
Rollup merge of #78244 - workingjubilee:dogfood-fancy-ranges, r=varkor
Dogfood {exclusive,half-open} ranges in compiler (nfc)
In particular, this allows us to write more explicit matches that
avoid the pitfalls of using a fully general fall-through case, yet
remain fairly ergonomic. Less logic is in guard cases, more is in
the actual exhaustive case analysis.
Jonas Schievink [Thu, 29 Oct 2020 16:05:00 +0000 (17:05 +0100)]
Rollup merge of #75078 - ijackson:slice-strip, r=steveklabnik
Improve documentation for slice strip_* functions
Prompted by the stabilisation tracking issue #73413 I looked at the docs for `strip_prefix` and `strip_suffix` for both `str` and `slice`, and I felt they could be slightly improved.
bors [Thu, 29 Oct 2020 12:08:16 +0000 (12:08 +0000)]
Auto merge of #78446 - RalfJung:box, r=Amanieu
fix Box::into_unique
https://github.com/rust-lang/rust/pull/77187/ broke Stacked Borrows pointer tagging around `Box::into_unique` (this is caused by `Box` being a special case in the type system, which box-internal code needs to account for). This PR fixes that.
bors [Thu, 29 Oct 2020 06:18:12 +0000 (06:18 +0000)]
Auto merge of #78486 - pietroalbini:manifest-artifacts, r=Mark-Simulacrum
Include non-rustup artifacts in the manifest
This PR fixes https://github.com/rust-lang/promote-release/issues/22 by including all the files we ship in the generated manifests, even the ones that are not installable through rustup. In practice this adds the following "artifacts":
* `source-code`: the tarball containing the full source code used to build the release (`rustc-{channel}-src.tar.xz`)
* `installer-msi`: the MSI installer for Windows systems (`rust-{channel}-{target}.msi`)
* `installer-pkg`: the PKG installer for macOS systems (`rust-{channel}-{target}.pkg`)
These files are included in a new `artifacts` table of the manifest, like so:
Each artifact can be available for multiple targets, and each target can have multiple versions of the same file (for example, a `gz`-compressed one and a `xz`-compressed one). In the future rustup might add functionality to let users retrieve the artifacts, but that's not needed to land this PR, and whether to do the implementation is up to the rustup maintainers.
Jubilee Young [Thu, 22 Oct 2020 18:42:44 +0000 (11:42 -0700)]
Dogfood {exclusive,half-open} ranges in compiler (nfc)
In particular, this allows us to write more explicit matches that
avoid the pitfalls of using a fully general fall-through case, yet
remain fairly ergonomic. Less logic is in guard cases, more is in
the actual exhaustive case analysis.
Yuki Okushi [Thu, 29 Oct 2020 03:09:01 +0000 (12:09 +0900)]
Rollup merge of #78492 - ehuss:update-books, r=ehuss
Update books
## nomicon
7 commits in 6e57e64501f61873ab80cb78a07180a22751a5d6..69333eddb1de92fd17e272ce4677cc983d3bd71d
2020-09-14 11:40:23 -0400 to 2020-10-17 15:44:12 -0700
- Tweak GHA config (rust-lang-nursery/nomicon#240)
- Fix link for `[T]` (rust-lang-nursery/nomicon#239)
- Update casts.md (rust-lang-nursery/nomicon#232)
- [WIP] Add more links (rust-lang-nursery/nomicon#180)
- Data Race definition should be more precise (rust-lang-nursery/nomicon#219)
- Update the diagnostic of `error[E0597]` in dropck.md (rust-lang-nursery/nomicon#157)
- fix typo in Lifetimes mutable reference aliasing section (rust-lang-nursery/nomicon#225)
## reference
3 commits in 1b78182e71709169dc0f1c3acdc4541b6860e1c4..10c16caebe475d0d11bec0531b95d7697856c13c
2020-10-11 13:53:47 -0700 to 2020-10-25 20:51:26 -0700
- Add `unsafe` for `mod` and `extern`. (rust-lang-nursery/reference#898)
- mention how unions interact with dropping (rust-lang-nursery/reference#897)
- Add `move_ref_pattern` docs (rust-lang-nursery/reference#881)
3 commits in 81f16863014de60b53de401d71ff904d163ee030..7bc9b7a5e800f79df62947cb7d566fd2fbaf19fe
2020-08-27 13:56:31 -0700 to 2020-10-23 18:31:23 -0500
- A few small updates. (rust-lang/edition-guide#221)
- Clarify the limitation of ? in main and tests (rust-lang/edition-guide#219)
- Update deprecated GitHub Actions commands. (rust-lang/edition-guide#220)
Yuki Okushi [Thu, 29 Oct 2020 03:08:48 +0000 (12:08 +0900)]
Rollup merge of #78428 - JulianKnodt:invalid_patterns, r=lcnr
MinConstGenerics UI test for invalid values for bool & char
This adds a test for `feature(min_const_generics)` with some invalid values for bools and chars and ensures that they do not ICE and error with understandable messages.
Even with `min_const_generics` active, now keeps resulting in future compat warnings instead of hard errors.
Const parameters, for example `[0; N + 1]`, still result in hard errors during resolve.
```rust
#![allow(dead_code)]
Yuki Okushi [Thu, 29 Oct 2020 03:08:38 +0000 (12:08 +0900)]
Rollup merge of #77213 - ijackson:wip-rustdoc-settings, r=jyn514,GuillaumeGomez
rustdoc options to set default theme (and other settings)
Hi. This is the MR I promised in #77024
It is a little more general than I envisaged there. Once I had found the settings-handling machinery it seemed foolish to add this feature just for the theme.
bors [Thu, 29 Oct 2020 01:37:49 +0000 (01:37 +0000)]
Auto merge of #78430 - Nadrieril:taking-constructors-seriously2, r=varkor
Clarify main code paths in exhaustiveness checking
This PR massively clarifies the main code paths of exhaustiveness checking, by using the `Constructor` enum to a fuller extent. I've been itching to write it for more than a year, but the complexity of matching consts had prevented me. Behold a massive simplification :D.
This in particular removes a fair amount of duplication between various parts, localizes code into methods of relevant types when applicable, makes some implicit assumptions explicit, and overall improves legibility a lot (or so I hope). Additionally, after my changes undoing #76918 turned out to be a noticeable perf gain.
As usual I tried my best to make the commits self-contained and easy to follow. I've also tried to keep the code well-commented, but I tend to forget how complex this file is; I'm happy to clarify things as needed.
My measurements show good perf improvements on the two match-heavy benchmarks (-18.0% on `unicode_normalization-check`! :D); I'd like a perf run to check the overall impact.
Ian Jackson [Tue, 13 Oct 2020 17:52:43 +0000 (18:52 +0100)]
rustdoc: Provide a general --default-setting SETTING[=VALUE] option
We just plumb through what the user tells us.
This is flagged as unstable, mostly because I don't understand the
compatibility rules that rustdoc obeys for local storage data, and how
error handling of invalid data works.
We collect() the needed HashMap from Vec of Vecs of (key, value)
pairs, so that there is a nice place to add new more-specific options.
It would have been possible to use Extend::extend but doing it this
way ensures that all the used inputs are (and will stay) right next to
each other.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Ian Jackson [Wed, 23 Sep 2020 21:44:54 +0000 (22:44 +0100)]
rustdoc: Provide a way to set the default settings from Rust code
rustdoc has various user-configurable preferences. These are recorded
in web Local Storage (where available). But we want to provide a way
to configure the default default, including for when web storage is
not available.
getSettingValue is the function responsible for looking up these
settings. Here we make it fall back some in-DOM data, which
ultimately comes from RenderOptions.default_settings.
Using HTML data atrtributes is fairly convenient here, dsspite the
need to transform between snake and kebab case to avoid the DOM
converting kebab case to camel case (!)
We cache the element and dataset lookup in a global variable, to
ensure that getSettingValue remains fast.
The DOM representation has to be in an element which precedes the
inclusion of storage.js. That means it has to be in the <head> and we
should not use an empty <div> as the container (although most browsers
will accept that). An empty <script> element provides a convenient
and harmless container object. <meta> would be another possibility
but runs a greater risk of having unwanted behaviours on weird
browsers.
We trust the RenderOptions not to contain unhelpful setting names,
which don't fit nicely into an HTML attribute. It's awkward to quote
dataset keys.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
bors [Wed, 28 Oct 2020 17:47:36 +0000 (17:47 +0000)]
Auto merge of #78414 - nox:function-sections, r=nagisa,bjorn3
Implement -Z function-sections=yes|no
This lets rustc users tweak whether all functions should be put in their own TEXT section, using whatever default value the target defines if the flag is missing.
I'm having fun experimenting with musl libc and trying to implement the start symbol in Rust, that means avoiding code that requires relocations, and AFAIK putting everything in its own section makes the toolchain generate `GOTPCREL` relocations for symbols that could use plain old PC-relative addressing (at least on `x86_64`) if they were all in the same section.
Ian Jackson [Wed, 23 Sep 2020 21:14:43 +0000 (22:14 +0100)]
rustdoc: js: Use getSettingValue for all rustdoc-* values
Currently, storage.js and main.js have many open-coded calls to
getCurrentValue for "rustdoc-" values, but these are settings and
should be handled by getSettingValue.
So make getSettingValue part of storage.js (where everyone can call
it) and use it everywhere.
No functional change yet. We are going to make getSettingValue do
something more sophisticated in a moment.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
bors [Wed, 28 Oct 2020 14:52:20 +0000 (14:52 +0000)]
Auto merge of #78409 - pietroalbini:build-manifest-checksum-cache, r=Mark-Simulacrum
Add checksums cache to build-manifest
During the release process we're currently calculating the SHA256 of each file three times:
1. In `build-manifest`, to fill the `hash = "f00"` keys of the manifests.
2. In `promote-release`, to generate the `.sha256` files.
3. In `promote-release`, to generate the `.asc` GPG signatures.
Calculations 1. and 2. could be merged into a single one if there was a way for `build-manifest` to pass the checksums it generated over to `promote-release`. Unfortunately calculation 3. can't be merged as GPG requires extra metadata to be hashed.
This PR adds support for merging 1. and 2. by creating the `BUILD_MANIFEST_CHECKSUM_CACHE` environment variable, which points to a JSON file storing a cache of all the calculated checksums. `build-manifest` will load it at startup and avoid generating existing checksums, and it will dump its internal checksums cache into it when it exits successfully.
This PR also allows to run `build-manifest` multiple times without the need to wait for checksums to be calculated in the following invocations. The speedup will allow to work torwards a fix for https://github.com/rust-lang/promote-release/issues/15 without impacting the release process duration nor our storage costs.
This PR can be reviewed commit-by-commit.
r? `@Mark-Simulacrum`