Commit Graph

250550 Commits

Author SHA1 Message Date
Matthias Krüger fe0222be07
Rollup merge of #123005 - maurer:cfi-arbitrary-receivers, r=compiler-errors
CFI: Support complex receivers

Right now, we only support rewriting `&self` and `&mut self` into `&dyn MyTrait` and `&mut dyn MyTrait`. This expands it to handle the full gamut of receivers by calculating the receiver based on *substitution* rather than based on a rewrite. This means that, for example, `Arc<Self>` will become `Arc<dyn MyTrait>` appropriately with this change.

This approach also allows us to support associated type constraints as well, so we will correctly rewrite `&self` into `&dyn MyTrait<T=i32>`, for example.

r? ```@workingjubilee```
2024-03-25 11:00:14 +01:00
Matthias Krüger 84ec66e15b
Rollup merge of #123003 - maurer:dyn-empty, r=compiler-errors
CFI: Handle dyn with no principal

In user-facing Rust, `dyn` always has at least one predicate following it. Unfortunately, because we filter out marker traits from receivers at callsites and `dyn Sync` is, for example, legal, this results in us having `dyn` types with no predicates on occasion in our alias set encoding. This patch handles cases where there are no predicates in a `dyn` type which are relevant to its alias set.

Fixes #122998

r? workingjubilee
2024-03-25 11:00:14 +01:00
Matthias Krüger d1fca06662
Rollup merge of #122995 - Zalathar:flags-mir-opt, r=Mark-Simulacrum
Clean up unnecessary headers/flags in coverage mir-opt tests

During #122542, I noticed that some of the headers and flags I had copied over from `tests/mir-opt/instrument_coverage.rs`  were unnecessary. And while working to remove those, I noticed even more that could be removed or replaced.
2024-03-25 11:00:13 +01:00
Matthias Krüger e3fbaa87c9
Rollup merge of #122990 - SkiFire13:transmute-may-copy, r=jhpratt
Clarify transmute example

The example claims using an iterator will copy the entire vector, but this is not true in practice thanks to internal specializations in the stdlib (see https://godbolt.org/z/cnxo3MYs5 for confirmation that this doesn't reallocate nor iterate over the vec's elements). Since neither the copy nor the optimization is guaranteed I opted for saying that they _may_ happen.
2024-03-25 11:00:13 +01:00
Matthias Krüger fbb81fa89c
Rollup merge of #122982 - Zalathar:bootstrap-coverage-docs, r=onur-ozkan
Add more comments to the bootstrap code that handles `tests/coverage`

At the bootstrap level, coverage tests are a bit more complicated than other test suites, because we want to run the same set of test files in multiple different modes, in a way that's convenient and flexible when invoked manually.

This PR adds a few more comments to explain what's going on.
2024-03-25 11:00:12 +01:00
Matthias Krüger 4cae68b0cf
Rollup merge of #122858 - nnethercote:tweak-parse_dot_suffix_expr, r=est31
Tweak `parse_dot_suffix_expr`

I find this function hard to understand, so I rewrote it.

r? ```@est31```
2024-03-25 11:00:12 +01:00
bors 42198bf562 Auto merge of #122968 - rust-lang:cargo_update, r=Mark-Simulacrum
Weekly `cargo update`

Automation to keep dependencies in `Cargo.lock` current.

The following is the output from `cargo update`:

```txt
    Updating aho-corasick v1.1.2 -> v1.1.3
    Updating backtrace v0.3.69 -> v0.3.71
    Updating bitflags v2.4.2 -> v2.5.0
    Updating bytes v1.5.0 -> v1.6.0
    Updating cargo-platform v0.1.7 -> v0.1.8
    Updating fastrand v2.0.1 -> v2.0.2
    Updating indexmap v2.2.5 -> v2.2.6
    Updating libz-sys v1.1.15 -> v1.1.16
    Updating rayon v1.9.0 -> v1.10.0
    Updating reqwest v0.11.26 -> v0.11.27 (latest: v0.12.1)
    Updating rustix v0.38.31 -> v0.38.32
    Updating smallvec v1.13.1 -> v1.13.2
    Updating syn v2.0.53 -> v2.0.55
    Updating uuid v1.7.0 -> v1.8.0
note: pass `--verbose` to see 87 unchanged dependencies behind latest
```
2024-03-25 06:39:44 +00:00
bors fa374a8071 Auto merge of #122951 - Nilstrieb:nodejs20, r=Kobzol
Update upload-artifact to v4

This contains a breaking change around artifact merging no longer being done. This was not relied on, so it's fine.
2024-03-25 04:39:30 +00:00
Zalathar 1bbab7148b Add more comments to the bootstrap code that handles `tests/coverage` 2024-03-25 15:31:33 +11:00
Nicholas Nethercote dce0f7f5c2 Clarify `parse_dot_suffix_expr`.
For the `MiddleDot` case, current behaviour:
- For a case like `1.2`, `sym1` is `1` and `sym2` is `2`, and `self.token`
  holds `1.2`.
- It creates a new ident token from `sym1` that it puts into `self.token`.
- Then it does `bump_with` with a new dot token, which moves the `sym1`
  token into `prev_token`.
- Then it does `bump_with` with a new ident token from `sym2`, which moves the
  `dot` token into `prev_token` and discards the `sym1` token.
- Then it does `bump`, which puts whatever is next into `self.token`,
  moves the `sym2` token into `prev_token`, and discards the `dot` token
  altogether.

New behaviour:
- Skips creating and inserting the `sym1` and dot tokens, because they are
  unnecessary.
- This also demonstrates that the comment about `Spacing::Alone` is
  wrong -- that value is never used. That comment was added in #77250,
  and AFAICT it has always been incorrect.

The commit also expands comments. I found this code hard to read
previously, the examples in comments make it easier.
2024-03-25 13:08:07 +11:00
Nicholas Nethercote 9c091160dc Change `parse_expr_tuple_field_access`.
Pass in the span for the field rather than using `prev_token`.
Also rename it `mk_expr_tuple_field_access`, because it doesn't do any
actual parsing, it just creates an expression with what it's given.

Not much of a clarity win by itself, but unlocks additional subsequent
simplifications.
2024-03-25 13:05:59 +11:00
Nicholas Nethercote 90eeb3d681 Remove `next_token` handling from `parse_expr_tuple_field_access`.
It's clearer at the call site.
2024-03-25 13:05:59 +11:00
Nicholas Nethercote 42066b029f Inline and remove `Parser::parse_expr_tuple_field_access_float`.
It has a single call site, and afterwards all the calls to
`parse_expr_tuple_field_access` are in a single method, which is nice.
2024-03-25 13:05:59 +11:00
bors 13dac8fb73 Auto merge of #122721 - oli-obk:merge_queries, r=davidtwco
Replace `mir_built` query with a hook and use mir_const everywhere instead

A small perf improvement due to less dep graph handling.

Mostly just a cleanup to get rid of one of our many mir queries
2024-03-25 01:33:46 +00:00
Matthew Maurer 40f41e7e89 CFI: Support arbitrary receivers
Previously, we only rewrote `&self` and `&mut self` receivers. By
instantiating the method from the trait definition, we can make this
work work with arbitrary legal receivers instead.
2024-03-24 22:46:48 +00:00
bors 0824b300eb Auto merge of #122658 - cuviper:gccjit-archive, r=Mark-Simulacrum
ci: Build gccjit from a git archive

A full `git clone` of GCC includes quite a lot of history, and it's
completely unnecessary for building it in CI. We can use a GitHub
archive URL to get a simple tarball that is much faster to download.

Also, the `gcc-build` directory can be removed after install to reduce
the image size even further.
2024-03-24 18:15:27 +00:00
Matthew Maurer ea4518522f CFI: Handle dyn with no principal
In user-facing Rust, `dyn` always has at least one predicate following
it. Unfortunately, because we filter out marker traits from receivers at
callsites and `dyn Sync` is, for example, legal, this results in us
having `dyn` types with no predicates on occasion in our alias set
encoding. This patch handles cases where there are no predicates in a
`dyn` type which are relevant to its alias set.

Fixes #122998
2024-03-24 16:58:33 +00:00
bors d36bdd19f2 Auto merge of #123004 - matthiaskrgr:rollup-s3v4p50, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #122737 (conditionally ignore fatal diagnostic in the SilentEmitter)
 - #122757 (Fixed the `private-dependency` bug)
 - #122886 (add test for #90192)
 - #122937 (Unbox and unwrap the contents of `StatementKind::Coverage`)
 - #122949 (Add a regression test for #117310)
 - #122962 (Track run-make-support lib in common inputs stamp)
 - #122977 (Rename `Arguments::as_const_str` to `as_statically_known_str`)
 - #122983 (Fix build failure on ARM/AArch64/PowerPC/RISC-V FreeBSD/NetBSD)
 - #122984 (panic-in-panic-hook: formatting a message that's just a string is risk-free)
 - #122992 (std:🧵 refine available_parallelism for solaris/illumos.)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-24 16:09:51 +00:00
Matthias Krüger cdf86bf443
Rollup merge of #122992 - devnexen:available_parallelism_sol_upd, r=Amanieu
std:🧵 refine available_parallelism for solaris/illumos.

Rather than the system-wide available cpus fallback solution, we fetch the cpus bound to the current process.
2024-03-24 17:08:19 +01:00
Matthias Krüger f67fb08605
Rollup merge of #122984 - RalfJung:panic-in-hook, r=Amanieu
panic-in-panic-hook: formatting a message that's just a string is risk-free

This slightly improves the output in the 'panic while processing panic' case if the panic message does not involve any formatting. Follow-up to https://github.com/rust-lang/rust/pull/122930.

r? ``@Amanieu``
2024-03-24 17:08:19 +01:00
Matthias Krüger a5852ef941
Rollup merge of #122983 - taiki-e:bsd, r=workingjubilee
Fix build failure on ARM/AArch64/PowerPC/RISC-V FreeBSD/NetBSD

Fixes https://github.com/rust-lang/rust/pull/121881#discussion_r1536764650

Checked targets: aarch64-unknown-freebsd, powerpc64-unknown-freebsd, armv7-unknown-freebsd, riscv64gc-unknown-freebsd, aarch64-unknown-netbsd.

r? ``@Amanieu``
cc ``@devnexen``
2024-03-24 17:08:18 +01:00
Matthias Krüger 6b1f4e44d2
Rollup merge of #122977 - cuviper:as_statically_known_str, r=RalfJung
Rename `Arguments::as_const_str` to `as_statically_known_str`

While `const` has a particular meaning about language guarantees, here
we need a fuzzier notion like whether constant propagation was
effective, and `statically_known` is the best term we have for now.

r? ``@RalfJung``
2024-03-24 17:08:18 +01:00
Matthias Krüger 5281fe29cc
Rollup merge of #122962 - jieyouxu:stamp-rmake-support-lib, r=onur-ozkan
Track run-make-support lib in common inputs stamp

So that when the support library gets modified, `run-make` tests are forced to re-run instead of being still ignored as if nothing changed.

Fixes #122961.
2024-03-24 17:08:17 +01:00
Matthias Krüger 96a5348c05
Rollup merge of #122949 - ShoyuVanilla:issue-117310, r=lcnr
Add a regression test for #117310

Closes #117310

It seems to have been fixed in `rustc 1.79.0-nightly (1388d7a06 2024-03-20)` or before, so just adding a regression test for it.
2024-03-24 17:08:17 +01:00
Matthias Krüger 19d3827efe
Rollup merge of #122937 - Zalathar:unbox, r=oli-obk
Unbox and unwrap the contents of `StatementKind::Coverage`

The payload of coverage statements was historically a structure with several fields, so it was boxed to avoid bloating `StatementKind`.

Now that the payload is a single relatively-small enum, we can replace `Box<Coverage>` with just `CoverageKind`.

This patch also adds a size assertion for `StatementKind`, to avoid accidentally bloating it in the future.

``@rustbot`` label +A-code-coverage
2024-03-24 17:08:16 +01:00
Matthias Krüger 702261dce6
Rollup merge of #122886 - matthiaskrgr:issue90192, r=fee1-dead
add test for #90192

Fixes #90192
2024-03-24 17:08:16 +01:00
Matthias Krüger 04eedb24c9
Rollup merge of #122757 - h1467792822:priv-dep, r=davidtwco
Fixed the `private-dependency` bug

Fixed the private-dependency bug: If the directly dependent crate is loaded last and is not configured with `--extern`, it may be incorrectly set to `private-dependency`

Fixes #122756
2024-03-24 17:08:15 +01:00
Matthias Krüger 3fe9f66133
Rollup merge of #122737 - ytmimi:conditionally_ignore_fatal_diagnostic, r=davidtwco
conditionally ignore fatal diagnostic in the SilentEmitter

This change is primarily meant to allow rustfmt to ignore all diagnostics when using the `SilentEmitter`. Back in #121301 the `SilentEmitter` was shared between rustc and rustfmt. This changed rustfmt's behavior from ignoring all diagnostic to emitting fatal diagnostics, which lead to https://github.com/rust-lang/rustfmt/issues/6109.

These changes allow rustfmt to maintain its previous behaviour when using the `SilentEmitter`, while allowing rustc code to still emit fatal diagnostics.
2024-03-24 17:08:15 +01:00
David Carlier 1871ea5710 fix build. 2024-03-24 16:02:02 +00:00
bors 6e6c721742 Auto merge of #122895 - matthiaskrgr:ice-tests-5xxxx-to-9xxxx, r=fmease
add some ice tests 5xxxx to 9xxxx

  Fixes rust-lang/rust#98842
  Fixes rust-lang/rust#90691
  Fixes rust-lang/rust#88421
  Fixes rust-lang/rust#88212
  Fixes rust-lang/rust#83056
  Fixes rust-lang/rust#80125
  Fixes rust-lang/rust#64784
  Fixes rust-lang/rust#52334
2024-03-24 13:38:12 +00:00
github-actions 1848b46c0b cargo update
Updating aho-corasick v1.1.2 -> v1.1.3
    Updating backtrace v0.3.69 -> v0.3.71
    Updating bitflags v2.4.2 -> v2.5.0
    Updating bytes v1.5.0 -> v1.6.0
    Updating cargo-platform v0.1.7 -> v0.1.8
    Updating fastrand v2.0.1 -> v2.0.2
    Updating indexmap v2.2.5 -> v2.2.6
    Updating libz-sys v1.1.15 -> v1.1.16
    Updating rayon v1.9.0 -> v1.10.0
    Updating reqwest v0.11.26 -> v0.11.27 (latest: v0.12.1)
    Updating rustix v0.38.31 -> v0.38.32
    Updating smallvec v1.13.1 -> v1.13.2
    Updating syn v2.0.53 -> v2.0.55
    Updating uuid v1.7.0 -> v1.8.0
note: pass `--verbose` to see 87 unchanged dependencies behind latest
2024-03-24 12:09:28 +00:00
Zalathar b5ee20f714 Clean up unnecessary headers/flags in coverage mir-opt tests
These headers and flags were historically needed, but are now unnecessary due
to various changes in how coverage information is stored in MIR.
2024-03-24 22:17:47 +11:00
bors 6a92312a1e Auto merge of #122891 - compiler-errors:encode-implied-predicates-always, r=oli-obk
Encode implied predicates for traits

In #112629, we decided to make associated type bounds in the "supertrait" AST position *implied* even though they're not supertraits themselves.

This means that the `super_predicates` and `implied_predicates` queries now differ for regular traits. The assumption that they didn't differ was hard-coded in #107614, so in cross-crate positions this means that we forget the implied predicates from associated type bounds.

This isn't unsound, just kind of annoying. This should be backported since associated type bounds are slated to stabilize for 1.78 -- either that, or associated type bounds can be reverted on beta and re-shipped in 1.79 with this patch.

Fixes #122859
2024-03-24 11:17:21 +00:00
David Carlier 4b84df9ea3 std:🧵 refine available_parallelism for solaris/illumos.
Rather than the system-wide available cpus fallback solution, we fetch
the cpus bound to the current process.
2024-03-24 10:57:17 +00:00
Giacomo Stevanato fb65ca14b2 Clarify transmute example 2024-03-24 11:27:34 +01:00
Ralf Jung 0727b6ad0d panic-in-panic-hook: formatting a message that's just a string is risk-free 2024-03-24 10:29:44 +01:00
bors 4a52e9cc2a Auto merge of #122980 - workingjubilee:rollup-r5i1rke, r=workingjubilee
Rollup of 7 pull requests

Successful merges:

 - #120419 (Expand sys/os for UEFI)
 - #121940 (Mention Register Size in `#[warn(asm_sub_register)]`)
 - #122762 (fix typo of endianness)
 - #122797 (Fix compile of wasm64-unknown-unknown target)
 - #122875 (CFI: Support self_cell-like recursion)
 - #122879 (CFI: Strip auto traits off Virtual calls)
 - #122969 (Simplify an iterator search in borrowck diag)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-24 09:04:01 +00:00
Matthias Krüger 114d012a0e add issue numbers via // issue: rust-lang/rust#ISSUE_NUM directive 2024-03-24 09:34:11 +01:00
Taiki Endo 7aa76a7ac3 Fix build failure on ARM/AArch64/PowerPC/RISC-V FreeBSD/NetBSD 2024-03-24 17:26:48 +09:00
Matthias Krüger 57f500512b add test for stack overflow with recursive type #98842
Fixes #98842
2024-03-24 09:23:13 +01:00
Matthias Krüger 5ae90256da add test for ice #90691 ICE: resolution failed during building vtable representation
Fixes #90691
2024-03-24 09:23:13 +01:00
Matthias Krüger f44ee8f87d add test for 88421 ICE: could not fully normalize `&<MyType as std::ops::Index<MyType>>::Output
Fixes #88421
2024-03-24 09:23:13 +01:00
Matthias Krüger 74ca9813ed add test for #88212 ICE when lambda captures unsized local
Fixes #88212
2024-03-24 09:23:13 +01:00
Matthias Krüger 445507a19d add test for ice 83056 "bad input type for cast"
Fixes #83056
2024-03-24 09:23:12 +01:00
Matthias Krüger 19310ce2cc add test for str as extern "C" arg causes compiler panic #80125
Fixes #80125
2024-03-24 09:23:12 +01:00
Matthias Krüger a5ad0be52f add test for #64784 Declarative macros can create infinite glob import cycles
Fixes #64784
2024-03-24 09:23:12 +01:00
Matthias Krüger 14d05c4c4b add test for #52334
Fixes #52334
2024-03-24 09:23:12 +01:00
Matthias Krüger fc5085d570 add test for #90192
Fixes #90192
2024-03-24 09:19:29 +01:00
Jubilee c94d229337
Rollup merge of #122969 - cuviper:borrowck-rposition, r=matthewjasper
Simplify an iterator search in borrowck diag

Rather than `.into_iter().rev().find_position(...)`, this case can
simply call `.iter().rposition(...)`.
2024-03-23 22:59:43 -07:00
Jubilee 992aa1edb6
Rollup merge of #122879 - maurer:callsite-instances, r=workingjubilee
CFI: Strip auto traits off Virtual calls

We already use `Instance` at declaration sites when available to glean additional information about possible abstractions of the type in use. This does the same when possible at callsites as well.

The primary purpose of this change is to allow CFI to alter how it generates type information for indirect calls through `Virtual` instances.

This is needed for the "separate machinery" version of my approach to the vtable issues (#122573), because we need to respond differently to a `Virtual` call to the same type as a non-virtual call, specifically [stripping auto traits off the receiver's `Self`](54b15b0c36) because there isn't a separate vtable for `Foo` vs `Foo + Send`.

This would also make a more general underlying mechanism that could be used by rcvalle's [proposed drop detection / encoding](edcd1e20a1) if we end up using his approach, as we could condition out on the `def_id` in the CFI code rather than requiring the generating code to explicitly note whether it was calling drop.
2024-03-23 22:59:42 -07:00