bors [Mon, 26 Dec 2022 12:03:47 +0000 (12:03 +0000)]
Auto merge of #103828 - cassaundra:fix-format-args-span2, r=cjgillot
Fix incorrect span when using byte-escaped rbrace
Fix #103826, a format args span issue introduced in #102214.
The current solution for tracking skipped characters made it so that certain situations were ambiguous enough that the original span couldn't be worked out later. This PR improves on the original solution by keeping track of groups of skipped characters using a map, and fixes the previous bug. See an example of this ambiguity in the [previous PR's discussion](https://github.com/rust-lang/rust/pull/102214#issuecomment-1258711015).
bors [Mon, 26 Dec 2022 09:06:51 +0000 (09:06 +0000)]
Auto merge of #105605 - inquisitivecrystal:attr-validation, r=cjgillot
Don't perform invalid checks in `codegen_attrs`
The attributes `#[track_caller]` and `#[cmse_nonsecure_entry]` are only valid on functions. When validating one of these attributes, codegen_attrs previously called `fn_sig`, [which can only be used on functions](https://github.com/rust-lang/rust/pull/105201), on the item the attribute was attached to, assuming that the item was a function without checking. This led to [ICEs in situations where the attribute was incorrectly used on non-functions](https://github.com/rust-lang/rust/issues/105594).
With this change, we skip calling `fn_sig` if the item the attribute is attached to must be a function but isn't, because `check_attr` will reject such cases without codegen_attrs's intervention.
As a side note, some of the attributes in codegen_attrs are only valid on functions, but that property isn't actually checked. I'm planning to fix that in a follow up PR since it's a behavior change that will need to be validated rather than an obvious bugfix. Thankfully, all the attributes like that I've found so far are unstable.
bors [Sun, 25 Dec 2022 20:51:37 +0000 (20:51 +0000)]
Auto merge of #105997 - RalfJung:immediate-abort, r=eholk
abort immediately on bad mem::zeroed/uninit
Now that we have non-unwinding panics, let's use them for these assertions. This re-establishes the property that `mem::uninitialized` and `mem::zeroed` will never unwind -- the earlier approach of causing panics here sometimes led to hard-to-debug segfaults when the surrounding code was not able to cope with the unexpected unwinding.
Cc `@bjorn3` I did not touch cranelift but I assume it needs a similar patch. However it has a `codegen_panic` abstraction that I did not want to touch since I didn't know how else it is used.
bors [Sat, 24 Dec 2022 17:14:26 +0000 (17:14 +0000)]
Auto merge of #104977 - RalfJung:ptr-from-ref, r=dtolnay
add ptr::from_{ref,mut}
We have methods to avoid almost all `as` casts around raw pointer handling, except for the initial cast from reference to raw pointer. These new methods close that gap.
(I also moved `null_mut` next to `null` to keep the file consistently organized.)
bors [Sat, 24 Dec 2022 10:46:43 +0000 (10:46 +0000)]
Auto merge of #106111 - matthiaskrgr:rollup-nnpoe5h, r=matthiaskrgr
Rollup of 6 pull requests
Successful merges:
- #105465 (Improve top-level docs)
- #105872 (Suggest remove last method call when type coerce with expected type)
- #106032 (std: only use LFS function on glibc)
- #106078 (Provide more context on FileCheck failures)
- #106100 (Codegen test for derived `<` on trivial newtype [TEST ONLY])
- #106109 (rustdoc: make line number CSS for doc comment and scraped the same)
This adds output to data race errors very similar to the spans we emit for Stacked Borrows errors. For example, from our test suite:
```
help: The Atomic Load on thread `<unnamed>` is here
--> tests/fail/data_race/atomic_read_na_write_race1.rs:23:13
|
23 | ... (&*c.0).load(Ordering::SeqCst) //~ ERROR: Data race detected between Atomic Load on thread `<unnamed>` and Write o...
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: The Write on thread `<unnamed>` is here
--> tests/fail/data_race/atomic_read_na_write_race1.rs:19:13
|
19 | *(c.0 as *mut usize) = 32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^```
```
Because of https://github.com/rust-lang/miri/pull/2647 this comes without a perf regression, according to our benchmarks.
Matthias Krüger [Sat, 24 Dec 2022 07:53:48 +0000 (08:53 +0100)]
Rollup merge of #106100 - scottmcm:derived-less-than-test, r=compiler-errors
Codegen test for derived `<` on trivial newtype [TEST ONLY]
I originally wrote this for #106065, but the libcore changes there aren't necessarily a win.
So I pulled out this test to be its own PR since it's important (see https://github.com/rust-lang/rust/pull/105840#discussion_r1056030324) and well-intentioned changes to core or the derive could accidentally break it without that being obvious (other than by massive unexplained perf changes).
Matthias Krüger [Sat, 24 Dec 2022 07:53:48 +0000 (08:53 +0100)]
Rollup merge of #106078 - nikic:filecheck-context, r=Mark-Simulacrum
Provide more context on FileCheck failures
FileCheck provides 5 lines of context by default. This is often insufficient to analyze failures that happen in CI. Increase the amount of context to 100 lines.
Matthias Krüger [Sat, 24 Dec 2022 07:53:46 +0000 (08:53 +0100)]
Rollup merge of #105465 - jyn514:docs, r=Mark-Simulacrum
Improve top-level docs
See a detailed explanation in the commit messages. This is a companion PR to https://github.com/rust-lang/rustc-dev-guide/pull/1528.
* Link to other resources instead of inlining their information
* Remove ancient and outdated reference to `config.mk`
* Suggest `profile = "user"` in the README
* Add detail about dependencies from the dev-guide
* Link to CONTRIBUTING.md instead of rustc-dev-guide in the main readme
* Link to `std-dev-guide` in CONTRIBUTING.md
bors [Sat, 24 Dec 2022 07:35:23 +0000 (07:35 +0000)]
Auto merge of #106081 - mina86:c, r=Mark-Simulacrum
char: µoptimise UTF-16 surrogates decoding
According to Godbolt¹, on x86_64 using binary and produces slightly
better code than using subtraction. Readability of both is pretty
much equivalent so might just as well use the shorter option.
Matthias Krüger [Fri, 23 Dec 2022 23:31:43 +0000 (00:31 +0100)]
Rollup merge of #106093 - notriddle:notriddle/docblock-short-overflow, r=GuillaumeGomez
rustdoc: remove no-op CSS from `.docblock-short`
The rules `overflow:hidden` and `text-overflow:ellipses` only have an effect if overflow occurs, which cannot happen because it will just line wrap instead.
These rules definitely became obsolete by https://github.com/rust-lang/rust/pull/77699, when the stylesheet was decidedly changed to have line wrapping in short docblocks, but given the bug it was fixing, this probably got broken earlier.
Matthias Krüger [Fri, 23 Dec 2022 23:31:43 +0000 (00:31 +0100)]
Rollup merge of #106091 - GuillaumeGomez:correct-css-pseudo-element, r=notriddle
Use correct CSS pseudo-element selector
Pseudo-element should use "::" to not be confused with pseudo selectors (nice explanation here: https://css-tricks.com/to-double-colon-or-not-do-double-colon/).
Matthias Krüger [Fri, 23 Dec 2022 23:31:42 +0000 (00:31 +0100)]
Rollup merge of #106084 - RalfJung:into-iter, r=thomcc
fix vec::IntoIter::drop on high-alignment ZST
This fixes a soundness bug: IntoIter would call `drop_in_place` on an insufficiently aligned pointer. So if a ZST with alignment greater 1 had drop glue, that would be called with an unaligned reference. Since https://github.com/rust-lang/rust/pull/103957, Miri checks alignment even if the type does not have drop glue, which is how this bug was found.
Matthias Krüger [Fri, 23 Dec 2022 23:31:41 +0000 (00:31 +0100)]
Rollup merge of #106069 - notriddle:notriddle/search-tabs, r=GuillaumeGomez
rustdoc: use a more evocative name for CSS/JS `#titles`
This renames the ID, which is only used in search results, to `#search-tabs`. Also changes the `.count` to a span, so it doesn't need its display mode to be overridden.
- fix: deduplicate dependencies by artifact target (rust-lang/cargo#11478)
- Add warning if potentially-scrapable examples are skipped due to dev-dependencies (rust-lang/cargo#11503)
- Don't scrape examples from library targets by default (rust-lang/cargo#11499)
- Stabilize terminal-width (rust-lang/cargo#11494)
- Make sure that hash of `SourceId` is stable (rust-lang/cargo#11501)
- Use workspace lockfile when running `cargo package` and `cargo publish` (rust-lang/cargo#11477)
- Show `--help` if there is no man page for subcommand (rust-lang/cargo#11473)
bors [Fri, 23 Dec 2022 19:46:36 +0000 (19:46 +0000)]
Auto merge of #106087 - Nilstrieb:rollup-2m3nies, r=Nilstrieb
Rollup of 6 pull requests
Successful merges:
- #105661 (implement the skeleton of the updated trait solver)
- #105853 (Make the pre-push script work on directories with spaces)
- #106043 (Move tests)
- #106048 (Run `tidy` in its own job in PR CI)
- #106055 (Check arg expressions properly on error in `confirm_builtin_call`)
- #106067 (A few metadata nits)
Michael Howell [Fri, 23 Dec 2022 18:42:47 +0000 (11:42 -0700)]
rustdoc: remove no-op CSS from `.docblock-short`
The rules `overflow:hidden` and `text-overflow:ellipses` only have an
effect if overflow occurs, which cannot happen because it will just line
wrap instead.
These rules definitely became obsolete by
https://github.com/rust-lang/rust/pull/77699, when the stylesheet was
decidedly changed to have line wrapping in short docblocks, but given the
bug it was fixing, this probably got broken earlier.
- fix: deduplicate dependencies by artifact target (rust-lang/cargo#11478)
- Add warning if potentially-scrapable examples are skipped due to dev-dependencies (rust-lang/cargo#11503)
- Don't scrape examples from library targets by default (rust-lang/cargo#11499)
- Stabilize terminal-width (rust-lang/cargo#11494)
- Make sure that hash of `SourceId` is stable (rust-lang/cargo#11501)
- Use workspace lockfile when running `cargo package` and `cargo publish` (rust-lang/cargo#11477)
- Show `--help` if there is no man page for subcommand (rust-lang/cargo#11473)
nils [Fri, 23 Dec 2022 17:02:15 +0000 (18:02 +0100)]
Rollup merge of #106055 - compiler-errors:too-many-calls, r=estebank
Check arg expressions properly on error in `confirm_builtin_call`
Makes sure we don't regress diagnostic output when we have an expr error nested inside of a bad fn call: https://github.com/rust-lang/rust/pull/105973#issuecomment-1363152232
nils [Fri, 23 Dec 2022 17:02:15 +0000 (18:02 +0100)]
Rollup merge of #106048 - fee1-dead-contrib:tidy-ci-continuation, r=jyn514
Run `tidy` in its own job in PR CI
This duplicates mingw-check into two jobs where one job runs `tidy` only while the other job does not. The tidy job will not cancel other jobs on failure.
nils [Fri, 23 Dec 2022 17:02:13 +0000 (18:02 +0100)]
Rollup merge of #105661 - lcnr:evaluate-new, r=compiler-errors
implement the skeleton of the updated trait solver
cc ```@rust-lang/initiative-trait-system-refactor```
This is mostly following the architecture discussed in the types team meetup.
After discussing the desired changes for the trait solver, we encountered cyclic dependencies between them. Most notably between changing evaluate to be canonical and returning inference constraints. We cannot canonicalize evaluate without returning inference constraints due to coinductive cycles. However, caching inference constraints also relies on canonicalization. Implementing both of these changes at once in-place is not feasible.
This somewhat closely mirrors the current `evaluate` implementation with the following notable differences:
- it moves `project` into the core solver, allowing us to correctly deal with coinductive projections (will be required for implied bounds, perfect derive)
- it changes trait solver overflow to be non-fatal (required to backcompat breakage from changes to the iteration order of nested goals, deferred projection equality, generally very useful)
- it returns inference constraints and canonicalizes inputs and outputs (required for a lot things, most notably merging fulfill and evaluate, and deferred projection equality)
- it is implemented to work with lazy normalization
A lot of things aren't yet implemented, but the remaining FIXMEs should all be fairly self-contained and parallelizable. If the architecture looks correct and is what we want here, I would like to quickly merge this and then split the work.
bors [Fri, 23 Dec 2022 13:37:11 +0000 (13:37 +0000)]
Auto merge of #106053 - compiler-errors:incr-test-revision, r=Mark-Simulacrum
Take revision into account in non-incremental-mode `// incremental` tests
A UI test I added in #105983 confusingly [failed](https://github.com/rust-lang/rust/pull/106031#issuecomment-1362558067) in a merge because two different revisions raced with each other for the same incremental directory for a (non-incremental-mode, i.e. `src/test/ui`) UI test.
Let's take the revision name into account when generating an incremental directory so that other UI tests that combine `// incremental` and `// revisions` won't race and cause possible flakiness in CI.
According to Godbolt¹, on x86_64 using binary and produces slightly
better code than using subtraction. Readability of both is pretty
much equivalent so might just as well use the shorter option.
`packed_simd_2` is only used as a dependency of `bytecount` which in turn is only used by `rustfmt`. I can't see any issue with the minor version bump.
The bigger jump is `getrandom@0.2.0` which is used by a number of things, but 0.2.8 is still semver compatible and there doesn't seem to be any worrying changes (see the [changelog](https://github.com/rust-random/getrandom/blob/master/CHANGELOG.md)). The only breaking change are the removal of XP, stdweb and CloudAbi support but these are not host targets and rustc lacks support for them in any case (stdweb development was [abandonded](https://rustsec.org/advisories/RUSTSEC-2020-0056.html), XP is [tier 3 and `no_std`](https://doc.rust-lang.org/beta/rustc/platform-support.html#tier-3) and CloubAbi is [no longer supported](https://github.com/rust-lang/rust/pull/78439)).
Note that this doesn't affect `getrandom@0.1.16` which is what std depends on and which is already using the latest version of `cfg-if` (besides, there are already plans to remove that entirely).
Nikita Popov [Fri, 23 Dec 2022 08:40:24 +0000 (09:40 +0100)]
Provide more context on FileCheck failures
FileCheck provides 5 lines of context by default. This is often
insufficient to analyze failures that happen in CI. Increase the
amount of context to 100 lines.
bors [Fri, 23 Dec 2022 02:44:32 +0000 (02:44 +0000)]
Auto merge of #106070 - matthiaskrgr:rollup-jv9ctkl, r=matthiaskrgr
Rollup of 6 pull requests
Successful merges:
- #105978 (Mark `proc_macro_decls_static` as always used)
- #106051 (Allow building std with cranelift)
- #106056 (Make `sess.bug` much less noisy)
- #106057 (Give a more helpful error for "trimmed_def_paths constructed")
- #106058 (Fix the issue number in comment for as_local_call_operand)
- #106059 (Avoid running the `Profile` step twice on `x setup`)
Michael Howell [Thu, 22 Dec 2022 22:52:34 +0000 (15:52 -0700)]
rustdoc: use a more evocative name for CSS/JS `#titles`
This renames the ID, which is only used in search results, to
`#search-tabs`. Also changes the `.count` to a span, so it doesn't need its
display mode to be overridden.
Matthias Krüger [Fri, 23 Dec 2022 00:17:52 +0000 (01:17 +0100)]
Rollup merge of #106059 - jyn514:setup-twice, r=Nilstrieb
Avoid running the `Profile` step twice on `x setup`
Prevents runs like the following:
```
$ x setup
Welcome to the Rust project! What do you want to do with x.py?
a) library: Contribute to the standard library
b) compiler: Contribute to the compiler itself
c) codegen: Contribute to the compiler, and also modify LLVM or codegen
d) tools: Contribute to tools which depend on the compiler, but do not modify it directly (e.g. rustdoc, clippy, miri)
e) user: Install Rust from source
Please choose one (a/b/c/d/e): b
To get started, try one of the following commands:
- `x.py check`
- `x.py build`
- `x.py test`
For more suggestions, see https://rustc-dev-guide.rust-lang.org/building/suggested.html
`x.py` will now use the configuration at /home/nilsh/projects/rustfast/src/bootstrap/defaults/config.compiler.toml
Welcome to the Rust project! What do you want to do with x.py?
...
```
Matthias Krüger [Fri, 23 Dec 2022 00:17:51 +0000 (01:17 +0100)]
Rollup merge of #106056 - jyn514:quiet-bug, r=compiler-errors
Make `sess.bug` much less noisy
cc https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/ice.20debugging/near/315929150
Before:
<details>
```
Compiling core v0.0.0 (C:\Users\Joshua Nelson\src\rust2\library\core)
error: internal compiler error: no warnings or errors encountered even though `delayed_good_path_bugs` issued
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
error: could not compile `core`
```
</details>
After:
<details>
```
Compiling core v0.0.0 (C:\Users\Joshua Nelson\src\rust2\library\core)
error: internal compiler error: no warnings or errors encountered even though `delayed_good_path_bugs` issued
Matthias Krüger [Fri, 23 Dec 2022 00:17:50 +0000 (01:17 +0100)]
Rollup merge of #105978 - jyn514:unused_proc_macro_decl, r=tmiasko
Mark `proc_macro_decls_static` as always used
This would have avoided a bug in https://github.com/rust-lang/rust/pull/104860.
In practice this shouldn't matter since nothing uses the query other than the `dead_code` lint, but this isn't documented as an internal-only query so it seems nice for it to be accurate. I think for `dead_code` it doesn't matter because the relevant code is generated by `rustc_builtin_macros` and isn't linted.
I think `@tmiasko` or `@bjorn3` would be a good reviewer?
bors [Fri, 23 Dec 2022 00:02:15 +0000 (00:02 +0000)]
Auto merge of #105036 - jyn514:cargo-docs, r=Mark-Simulacrum
Support documenting cargo
The primary motivation is to have the cargo docs show up on https://doc.rust-lang.org/nightly/nightly-rustc/cargo, but as a nice side effect this makes `x doc cargo` work locally.