Matthias Krüger [Thu, 9 Feb 2023 10:21:59 +0000 (11:21 +0100)]
Rollup merge of #107834 - zephaniahong:issue-107547-fix, r=albertlarsan68
create symlink for legacy rustfmt path
Fixes #107547 .
Main change is in the `download.rs` file. Created a symlink for the legacy rustfmt path to the new rustfmt path. Other file changes are simply as a result of porting over the symlink_file function from the Build struct to the config Struct
tl;dr: This PR adds an explicit dlltool temporary filename prefix. The prefix resolves a race condition by ensuring dlltool temporary files are siloed in an appropriate/unique Rust temporary directory.
---
GNU dlltool, as part of its import library generation logic, uses a bunch of temporary files on disk. In the interest of deterministic build runs, dlltool supports deterministic temporary filenames. The temporary filename prefix is automatically generated internally or can be explicitly specified via a `--temp-prefix` argument.
GNU dlltool **2.38** (that ships with `x86_64-12.2.0-release-posix-seh-rt_v10-rev0` [installed during CI](https://github.com/rust-lang/rust/blob/master/src/ci/scripts/install-mingw.sh)) generates a prefix based on the target library name ([source](https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=binutils/dlltool.c;h=d95bf3f5470b999fa3b30bc887791859f48d81d1;hb=20756b0fbe065a84710aa38f2457563b57546440#l3992)). The tool writes to files such as `target_dll_h.s` and `target_dll_s00203.o` in the current working directory.
This presents a problem when multiple instances of rustc_codegen_llvm are running to generate an import library (as part of the raw_dylib feature) for the same target library (e.g. kernel32) ([source](https://github.com/rust-lang/rust/blob/master/compiler/rustc_codegen_llvm/src/back/archive.rs#L185-L196)). That is, dlltool instances race and may overwrite or delete files belonging to each other.
GNU dlltool **2.39**+ (not used in Rust CI) generates a prefix based on the output library path ([source](https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=binutils/dlltool.c;h=e2af20847009945b4c61a6fef08268fbb4429715;hb=b51c2fec1da205ea3e7354cbb3e253018d64873c#l3992)). The tool, when invoked as part of rustc_codegen_llvm, writes to files at paths such as `C_Users_Foo_AppData_Local_Temp_rustcOFqhXZ_target_lib_h.s`. (The output library path is normalized and non-alphanumeric characters are replaced with underscores.)
bors [Thu, 9 Feb 2023 04:03:20 +0000 (04:03 +0000)]
Auto merge of #107828 - compiler-errors:rollup-gyj6dgj, r=compiler-errors
Rollup of 9 pull requests
Successful merges:
- #107317 (Implement `AsFd` and `AsRawFd` for `Rc`)
- #107429 (Stabilize feature `cstr_from_bytes_until_nul`)
- #107713 (Extend `BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE`.)
- #107761 (Replace a command line flag with an env var to allow tools to initialize the tracing loggers at their own discretion)
- #107790 ( x.py fails all downloads that use a tempdir with snap curl #107722)
- #107799 (correctly update goals in the cache)
- #107813 (Do not eagerly recover for bad `impl Trait` types in macros)
- #107817 (rustdoc: use svgo to shrink `wheel.svg`)
- #107819 (Set `rust-analyzer.check.invocationLocation` to `root`)
Michael Goulet [Thu, 9 Feb 2023 04:01:28 +0000 (20:01 -0800)]
Rollup merge of #107819 - clubby789:x-py-root, r=jyn514
Set `rust-analyzer.check.invocationLocation` to `root`
Add
```json
"rust-analyzer.check.invocationLocation": "root",
"rust-analyzer.check.invocationStrategy": "once",
```
to the bundled VS code config. This prevents an error with r-a invoking `python3 x.py` in `src/bootstrap` where `x.py` does not exist.
Michael Goulet [Thu, 9 Feb 2023 04:01:26 +0000 (20:01 -0800)]
Rollup merge of #107813 - compiler-errors:bad-impl-trait-in-macro-is-ok, r=estebank
Do not eagerly recover for bad `impl Trait` types in macros
Fixes #107796
cc #106712, ```@estebank``` and ```@Ezrashaw``` please make sure to use [`Parser::may_recover`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/parser/struct.Parser.html#method.may_recover) for all eager-token-consuming parser recoveries.
This also fixes a separate regression from #99915, that was introduced before we added `may_recover` though.
Michael Goulet [Thu, 9 Feb 2023 04:01:26 +0000 (20:01 -0800)]
Rollup merge of #107799 - lcnr:update-provisional-result, r=oli-obk
correctly update goals in the cache
we may want to actually write the response for our goal into the provisional or global cache instead of simply using the result from the last iteration '^^
Michael Goulet [Thu, 9 Feb 2023 04:01:25 +0000 (20:01 -0800)]
Rollup merge of #107790 - tharunsuresh-code:snap_curl, r=jyn514
x.py fails all downloads that use a tempdir with snap curl #107722
Have used the open() library from python to capture the binary output of the curl command and write it to a file using stdout of the subprocess. Added a single-line comment mentioning the redirect operator.
Michael Goulet [Thu, 9 Feb 2023 04:01:24 +0000 (20:01 -0800)]
Rollup merge of #107429 - tgross35:from-bytes-until-null-stabilization, r=dtolnay
Stabilize feature `cstr_from_bytes_until_nul`
This PR seeks to stabilize `cstr_from_bytes_until_nul`.
Partially addresses #95027
This function has only been on nightly for about 10 months, but I think it is simple enough that there isn't harm discussing stabilization. It has also had at least a handful of mentions on both the user forum and the discord, so it seems like it's already in use or at least known.
This needs FCP still.
Comment on potential discussion points:
- eventual conversion of `CStr` to be a single thin pointer: this function will still be useful to provide a safe way to create a `CStr` after this change.
- should this return a length too, to address concerns about the `CStr` change? I don't see it as being particularly useful, and it seems less ergonomic (i.e. returning `Result<(&CStr, usize), FromBytesUntilNulError>`). I think users that also need this length without the additional `strlen` call are likely better off using a combination of other methods, but this is up for discussion
- `CString::from_vec_until_nul`: this is also useful, but it doesn't even have a nightly implementation merged yet. I propose feature gating that separately, as opposed to blocking this `CStr` implementation on that
Possible alternatives:
A user can use `from_bytes_with_nul` on a slice up to `my_slice[..my_slice.iter().find(|c| c == 0).unwrap()]`. However; that is significantly less ergonomic, and is a bit more work for the compiler to optimize compared the direct `memchr` call that this wraps.
bors [Wed, 8 Feb 2023 20:11:35 +0000 (20:11 +0000)]
Auto merge of #107811 - matthiaskrgr:rollup-rpjzshk, r=matthiaskrgr
Rollup of 8 pull requests
Successful merges:
- #105641 (Implement cursors for BTreeMap)
- #107271 (Treat Drop as a rmw operation)
- #107710 (Update strip-ansi-escapes and vte)
- #107758 (Change `arena_cache` to not alter the declared query result)
- #107777 (Make `derive_const` derive properly const-if-const impls)
- #107780 (Rename `replace_bound_vars_with_*` to `instantiate_binder_with_*`)
- #107793 (Add missing tracking issue for `RawOsError`)
- #107807 (Fix small debug typo)
Matthias Krüger [Wed, 8 Feb 2023 17:32:43 +0000 (18:32 +0100)]
Rollup merge of #107758 - Zoxc:arena-enref, r=cjgillot
Change `arena_cache` to not alter the declared query result
This makes the return types a bit clearer, limiting `arena_cache`'s effect to just the computation side. It also makes it easier to potentially remove `arena_cache`.
Matthias Krüger [Wed, 8 Feb 2023 17:32:42 +0000 (18:32 +0100)]
Rollup merge of #107710 - ehuss:update-strip-ansi-escapes, r=Mark-Simulacrum
Update strip-ansi-escapes and vte
This updates strip-ansi-escapes from 0.1.0 to 0.1.1 (and consequently vte).
Changes: https://github.com/luser/strip-ansi-escapes/compare/0.1.0...0.1.1
The only change really is updating vte which fixes some parsing issues (and drops the vendored source size by several megabytes).
Matthias Krüger [Wed, 8 Feb 2023 17:32:41 +0000 (18:32 +0100)]
Rollup merge of #107271 - Zeegomo:drop-rmw, r=oli-obk
Treat Drop as a rmw operation
Previously, a Drop terminator was considered a move in MIR. This commit changes the behavior to only treat Drop as a mutable access to the dropped place.
In order for this change to be correct, we need to guarantee that
1. A dropped value won't be used again
2. Places that appear in a drop won't be used again before a
subsequent initialization.
We can ensure this to be correct at MIR construction because Drop will only be emitted when a variable goes out of scope, thus having:
* (1) as there is no way of reaching the old value. drop-elaboration
will also remove any uninitialized drop.
* (2) as the place can't be named following the end of the scope.
However, the initialization status, previously tracked by moves, should also be tied to the execution of a Drop, hence the additional logic in the dataflow analyses.
From discussion in [this thread](https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/.60DROP.60.20to.20.60DROP_IF.60.20compiler-team.23558), originating from https://github.com/rust-lang/compiler-team/issues/558.
See also https://github.com/rust-lang/rust/pull/104488#discussion_r1085556010
Matthias Krüger [Wed, 8 Feb 2023 17:32:41 +0000 (18:32 +0100)]
Rollup merge of #105641 - Amanieu:btree_cursor, r=m-ou-se
Implement cursors for BTreeMap
See the ACP for an overview of the API: https://github.com/rust-lang/libs-team/issues/141
The implementation is split into 2 commits:
- The first changes the internal insertion functions to return a handle to the newly inserted element. The lifetimes involved are a bit hairy since we need a mutable handle to both the `BTreeMap` itself (which holds the root) and the nodes allocated in memory. I have tested that this passes the standard library testsuite under miri.
- The second commit implements the cursor API itself. This is more straightforward to follow but still involves some unsafe code to deal with simultaneous mutable borrows of the tree root and the node that is currently being iterated.
bors [Wed, 8 Feb 2023 07:43:37 +0000 (07:43 +0000)]
Auto merge of #107788 - matthiaskrgr:rollup-mw10sli, r=matthiaskrgr
Rollup of 8 pull requests
Successful merges:
- #107656 (Bump rust-installer)
- #107757 (Allow automatically creating vscode `settings.json` with `x setup`)
- #107769 (Rename `PointerSized` to `PointerLike`)
- #107770 (rustdoc: use a newline instead of `<br>` to format code headers)
- #107771 (Tweak ICE message)
- #107773 (Clearly signal purpose of the yaml template)
- #107776 (Docs: Fix format of headings in String::reserve)
- #107779 (Remove astconv usage in diagnostic)
Matthias Krüger [Wed, 8 Feb 2023 06:13:29 +0000 (07:13 +0100)]
Rollup merge of #107779 - compiler-errors:issue-107775, r=jackh726
Remove astconv usage in diagnostic
Fixes #107775
Location of the test sucks, I know, but I needed to put it somewhere :sweat:
The issue here is that the root cause of the issue has nothing to do with what's being tested, so I couldn't really give it a better name. Oh well.
Matthias Krüger [Wed, 8 Feb 2023 06:13:27 +0000 (07:13 +0100)]
Rollup merge of #107770 - notriddle:notriddle/br2nl, r=GuillaumeGomez
rustdoc: use a newline instead of `<br>` to format code headers
Since these elements now use `white-space: pre-wrap` since #107615, it's fine to use newlines for formatting, which is smaller and a bit less complicated.
Matthias Krüger [Wed, 8 Feb 2023 06:13:26 +0000 (07:13 +0100)]
Rollup merge of #107769 - compiler-errors:pointer-like, r=eholk
Rename `PointerSized` to `PointerLike`
The old name was unnecessarily vague. This PR renames a nightly language feature that I added, so I don't think it needs any additional approval, though anyone can feel free to speak up if you dislike the rename.
It's still unsatisfying that we don't the user which of {size, alignment} is wrong, but this trait really is just a stepping stone for a more generalized mechanism to create `dyn*`, just meant for nightly testing, so I don't think it really deserves additional diagnostic machinery for now.
- util toml targets: Do not infer directory as a file (rust-lang/cargo#11678)
- Add more guidance on how to implement unstable features (rust-lang/cargo#11675)
- Fix unstable chapter layout for codegen-backend (rust-lang/cargo#11676)
- refactor: mod.rs over "name".rs for consistency (rust-lang/cargo#11673)
- Verify source before recompile (rust-lang/cargo#11672)
- doc: more doc comments and intra-doc links (rust-lang/cargo#11669)
- Turn off debuginfo for build dependencies v2 (rust-lang/cargo#11252)
- config: Deny CARGO_HOME in [env] table (fixes rust-lang/cargo#11590) (rust-lang/cargo#11644)
- Fix the wrong comment (rust-lang/cargo#11651)
- Add partial support for SSH known hosts markers (rust-lang/cargo#11635)
- Replace `winapi` with `windows-sys` crate. (rust-lang/cargo#11656)
- Handle .cargo-ok being truncated (rust-lang/cargo#11665)
- util toml targets: Do not infer directory as a file (rust-lang/cargo#11678)
- Add more guidance on how to implement unstable features (rust-lang/cargo#11675)
- Fix unstable chapter layout for codegen-backend (rust-lang/cargo#11676)
- refactor: mod.rs over "name".rs for consistency (rust-lang/cargo#11673)
- Verify source before recompile (rust-lang/cargo#11672)
- doc: more doc comments and intra-doc links (rust-lang/cargo#11669)
- Turn off debuginfo for build dependencies v2 (rust-lang/cargo#11252)
- config: Deny CARGO_HOME in [env] table (fixes rust-lang/cargo#11590) (rust-lang/cargo#11644)
- Fix the wrong comment (rust-lang/cargo#11651)
- Add partial support for SSH known hosts markers (rust-lang/cargo#11635)
- Replace `winapi` with `windows-sys` crate. (rust-lang/cargo#11656)
- Handle .cargo-ok being truncated (rust-lang/cargo#11665)
bors [Tue, 7 Feb 2023 20:58:20 +0000 (20:58 +0000)]
Auto merge of #107768 - matthiaskrgr:rollup-9u4cal4, r=matthiaskrgr
Rollup of 8 pull requests
Successful merges:
- #107719 (Remove `arena_cache` modifier from `upstream_monomorphizations_for`)
- #107740 (Avoid locking the global context across the `after_expansion` callback)
- #107746 (Split fn_ctxt/adjust_fulfillment_errors from fn_ctxt/checks)
- #107749 (allow quick-edit convenience)
- #107750 (make more readable)
- #107755 (remove binder from query constraints)
- #107756 (miri: fix ICE when running out of address space)
- #107764 (llvm-16: Use Triple.h from new header location.)
Michael Howell [Tue, 7 Feb 2023 18:23:25 +0000 (11:23 -0700)]
rustdoc: use a newline instead of `<br>` to format code headers
Since these elements now use `white-space: pre-wrap` since 784665d4ce59c5239791f1f96fa2137e47ca1817, it's fine to use newlines
for formatting, which is smaller and a bit less complicated.
bors [Tue, 7 Feb 2023 17:19:47 +0000 (17:19 +0000)]
Auto merge of #107767 - matthiaskrgr:rollup-9m1qfso, r=matthiaskrgr
Rollup of 8 pull requests
Successful merges:
- #100599 (Add compiler error E0523 long description and test)
- #107471 (rustdoc: do not include empty default-settings tag in HTML)
- #107555 (Modify existing bounds if they exist)
- #107662 (Turn projections into copies in CopyProp.)
- #107695 (Add test for Future inflating arg size to 3x )
- #107700 (Run the tools builder on all PRs)
- #107706 (Mark 'atomic_mut_ptr' methods const)
- #107709 (Fix problem noticed in PR106859 with char -> u8 suggestion)
Matthias Krüger [Tue, 7 Feb 2023 16:57:18 +0000 (17:57 +0100)]
Rollup merge of #107764 - maurer:llvm-16, r=cuviper
llvm-16: Use Triple.h from new header location.
LLVM 16 has moved Triple.h from ADT and into TargetParser.
LLVM [landed a commit](https://github.com/llvm/llvm-project/commit/62c7f035b4392c1933550eead6ddab35122720bc) this morning moving the header. This change should make rustc continue to build against LLVM main.
I didn't add a test since that requires https://github.com/oli-obk/ui_test/issues/38 (host must be 64bit and target 32bit). Also the test takes ~30s, so I am not sure if we want to have it in the test suite?
Matthias Krüger [Tue, 7 Feb 2023 16:57:17 +0000 (17:57 +0100)]
Rollup merge of #107709 - tialaramex:master, r=compiler-errors
Fix problem noticed in PR106859 with char -> u8 suggestion
HN reader `@ayosec` noticed that my #106859 a few weeks back, malfunctions if you have a Unicode escape, the code suggested b'\u{0}' if you tried to use '\u{0}' where a byte should be, when of course b'\u{0}' is not a byte literal, regardless of the codepoint you can't write Unicode escapes in a byte literal at all.
My proposed fix here just checks that the "character" you wrote is fewer than 5 bytes, thus allowing \x7F and similar escapes but conveniently forbidding even the smallest Unicode escape \u{0} before offering the suggestion as before.
I have provided an updated test which includes examples which do and don't work because of this additional rule.
Matthias Krüger [Tue, 7 Feb 2023 16:57:16 +0000 (17:57 +0100)]
Rollup merge of #107706 - tgross35:atomic-as-mut-ptr, r=m-ou-se
Mark 'atomic_mut_ptr' methods const
There's nothing that would block these methods from being const (just an UnsafeCell get), and it would be helpful for FFI interfaces in static contexts
Matthias Krüger [Tue, 7 Feb 2023 16:57:16 +0000 (17:57 +0100)]
Rollup merge of #107700 - jyn514:tools-builder, r=Mark-Simulacrum
Run the tools builder on all PRs
Previously, it would only run on changes to subtrees, submodules, or select directories. That made it so that changes to the compiler that broke tools would only be detected on a full bors merge. This makes it so the tools builder runs by default, making it easier to catch breaking changes to clippy (which was the most affected).
r? ``@Mark-Simulacrum`` cc ``@pietroalbini`` ``@flip1995`` ``@m-ou-se``
Matthias Krüger [Tue, 7 Feb 2023 16:57:16 +0000 (17:57 +0100)]
Rollup merge of #107746 - Nathan-Fenner:nathanf/clean-up-adjust_fulfillment_errors, r=compiler-errors
Split fn_ctxt/adjust_fulfillment_errors from fn_ctxt/checks
This is a follow-up from #106477, addressing a small number of the `FIXME`s that were added, by moving some functions into the new(er) `adjust_fulfillment_errors` module.
More cleanup is possible for this file (and I'll hopefully get around to doing some of that soon) but the very first thing is to just move these functions out.
There should be no "real" changes in this PR, besides minor adjustments to imports and the functions being transferred.
Matthias Krüger [Tue, 7 Feb 2023 16:57:15 +0000 (17:57 +0100)]
Rollup merge of #107695 - Swatinem:futcallx3, r=compiler-errors
Add test for Future inflating arg size to 3x
This adds one more test that should track improvements to generator
layout, like https://github.com/rust-lang/rust/issues/62958 and https://github.com/rust-lang/rust/issues/62575.
In particular, this test highlights suboptimal layout, as the storage
for the argument future is not being reused across its usage as `upvar`,
`local` and `awaitee` (being polled to completion).
This is on top of https://github.com/rust-lang/rust/pull/107692 (as those would conflict with each other)
It is a minimal repro for code mentioned in https://github.com/moka-rs/moka/issues/212#issuecomment-1416914616 (CC `@tatsuya6502)`
Matthias Krüger [Tue, 7 Feb 2023 16:57:14 +0000 (17:57 +0100)]
Rollup merge of #107555 - edward-shen:edward-shen/dup-trait-suggestion, r=compiler-errors
Modify existing bounds if they exist
Fixes #107335.
This implementation is kinda gross but I don't really see a better way to do it.
This primarily does two things: Modifies `suggest_constraining_type_param` to accept a new parameter that indicates a span to be replaced instead of added, if presented, and limit the additive suggestions to either suggest a new bound on an existing bound (see newly added unit test) or add the generics argument if a generics argument wasn't found.
The former change is required to retain the capability to add an entirely new bounds if it was entirely omitted.
bors [Tue, 7 Feb 2023 09:58:58 +0000 (09:58 +0000)]
Auto merge of #107704 - jyn514:tidy-ci, r=Mark-Simulacrum
Run `expand-yaml-anchors` in `x test tidy`
Previously, the pre-commit hook which runs `x test tidy` could pass only to have CI fail within the first 30 seconds. This adds about 30 seconds to `test tidy` (for an initial run, much less after the tool is built the first time) in exchange for catching errors in `.github/workflows/ci.yml` before they're pushed.
Arpad Borsos [Sun, 5 Feb 2023 16:32:52 +0000 (17:32 +0100)]
Add test for Future inflating arg size to 3x
This adds one more test that should track improvements to generator
layout, like #62958 and #62575.
In particular, this test highlights suboptimal layout, as the storage
for the argument future is not being reused across its usage as `upvar`,
`local` and `awaitee` (being polled to completion).
bors [Tue, 7 Feb 2023 03:35:10 +0000 (03:35 +0000)]
Auto merge of #106180 - RalfJung:dereferenceable-generators, r=nbdd0121
make &mut !Unpin not dereferenceable, and Box<!Unpin> not noalias
See https://github.com/rust-lang/unsafe-code-guidelines/issues/381 and [this LLVM discussion](https://discourse.llvm.org/t/interaction-of-noalias-and-dereferenceable/66979). The exact semantics of how `noalias` and `dereferenceable` interact are unclear, and `@comex` found a case of LLVM actually exploiting that ambiguity for optimizations. I think for now we should treat LLVM `dereferenceable` as implying a "fake read" to happen immediately at the top of the function (standing in for the spurious reads that LLVM might introduce), and that fake read is subject to all the usual `noalias` restrictions. This means we cannot put `dereferenceable` on `&mut !Unpin` references as those references can alias with other references that are being read and written inside the function (e.g. for self-referential generators), meaning the fake read introduces aliasing conflicts with those other accesses.
For `&` this is already not a problem due to https://github.com/rust-lang/rust/pull/98017 which removed the `dereferenceable` attribute for other reasons.
Regular `&mut Unpin` references are unaffected, so I hope the impact of this is going to be tiny.
The first commit does some refactoring of the `PointerKind` enum since I found the old code very confusing each time I had to touch it. It doesn't change behavior.
EDIT: Turns out our `Box<!Unpin>` treatment was incorrect, too, so the PR also fixes that now (in codegen and Miri): we do not put `noalias` on these boxes any more.
bors [Tue, 7 Feb 2023 00:03:02 +0000 (00:03 +0000)]
Auto merge of #107693 - petrochenkov:metable, r=oli-obk
rustc_metadata: Encode/decode some `LazyArrays` without an `Option`
and a couple of related changes, see individual commits.
Addresses comments in https://github.com/rust-lang/rust/pull/107166#discussion_r1083417124 and https://github.com/rust-lang/rust/pull/107166#discussion_r1083768417, cc `@cjgillot` `@oli-obk.`