Commit Graph

233033 Commits

Author SHA1 Message Date
bors
784916ce24 Auto merge of #115290 - compiler-errors:ctor-unsafe, r=cjgillot
`rustc_layout_scalar_valid_range` makes ctors unsafe

We already validate this when we use the ctor in a call, e.g. `Variant(1)`, but not if we use the ctor as a fn ptr, e.g. `.map(Variant)`. The easiest way to fix the latter is (afaict) is by marking the ctor as unsafe itself.

Fixes #115284
2023-08-31 11:16:37 +00:00
bors
2bd81316f2 Auto merge of #115346 - oli-obk:smir_const, r=spastorino
Some SMIR Const cleanups

Only e1def3bd41b021ce87a5d639b10cdf4a7df1d0b5 is new logic, everywhere else I just used the implementations that y'all had already written.

r? `@spastorino`

cc `@ouz-a`
2023-08-31 09:30:58 +00:00
bors
dca2d1ff00 Auto merge of #115374 - RalfJung:miri-fn-abi, r=oli-obk
miri function ABI check: accept repr(transparent) wrappers as compatible
2023-08-31 07:43:23 +00:00
bors
8cbd2c847b Auto merge of #115398 - matthiaskrgr:rollup-88lj9gk, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #115373 (Fix bors missing a commit when merging #115355)
 - #115378 (`ignore-cross-compile` remaining tests that run binaries)
 - #115393 (Make `termcolor` types public in `rustc_errors`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-31 06:02:49 +00:00
Matthias Krüger
82675f6a39
Rollup merge of #115393 - LegNeato:patch-1, r=oli-obk
Make `termcolor` types public in `rustc_errors`

After https://github.com/rust-lang/rust/pull/114104, `rust-gpu` is unable to create a custom `Emitter` as the bounds have changed to include `WriteColor`.

I was able to work around this by adding `termcolor` as a direct dependency, but I believe this should be exposed as part of `rustc_errors` proper.

See https://github.com/rust-lang/rust/pull/102992 for why `rust-gpu` needs to create a custom emitter.
2023-08-31 07:52:44 +02:00
Matthias Krüger
a0d2cb0e0e
Rollup merge of #115378 - ferrocene:ignore-cross-compile, r=lqd
`ignore-cross-compile` remaining tests that run binaries

Follow up to https://github.com/rust-lang/rust/pull/114958
2023-08-31 07:52:43 +02:00
Matthias Krüger
0b62835043
Rollup merge of #115373 - lqd:come-on-bors, r=compiler-errors
Fix bors missing a commit when merging #115355

bors incorrectly merged an outdated version of PR #115355 (via rollup #115370):
- it [recorded r+](https://github.com/rust-lang/rust/pull/115355#issuecomment-1698372365) as approving commit 325b585259, and thus merged the original revision 7762ac7bb5
- but the branch at the time was at commit eefa07d69b, so bors missed the `compiler/rustc_trait_selection/src/solve/search_graph/mod.rs` cleanup in commit 0e1e964a34 😓

Thankfully the change that bors missed was small, and this new PR corrects the situation (as I'd rather avoid having confusing multiple merge commits of PR #115355 in the git history)

r? ``@compiler-errors``
2023-08-31 07:52:43 +02:00
bors
008c21c977 Auto merge of #115323 - onur-ozkan:curl-download-checksum-fix, r=Mark-Simulacrum
avoid stdout redirection on `curl` executions

Avoid redirecting the curl output directly to the stdout. This alteration affects the integrity of the file during the retry process, as it also redirects the logs from the retries. Consequently, this leads to the bootstrap process failing because of an invalid checksum.

For more information, see the [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/checksum.20errors)

Fixes #115275
2023-08-31 02:19:55 +00:00
bors
e51c5ea16f Auto merge of #115392 - compiler-errors:coherence-spans, r=aliemjay
Don't record spans for predicates in coherence

Should improve perf (https://github.com/rust-lang/rust/pull/115107#issuecomment-1695090589) for https://github.com/rust-lang/rust/pull/114023#issuecomment-1688514709

r? aliemjay
2023-08-31 00:34:04 +00:00
bors
b1b244da65 Auto merge of #115194 - tmiasko:inline-always-encode-mir, r=compiler-errors
Fix inlining with -Zalways-encode-mir

Only inline functions that are considered eligible for inlining
by the reachability pass.

This constraint was previously indirectly enforced by only exporting MIR
of eligible functions, but that approach doesn't work with
-Zalways-encode-mir enabled.
2023-08-30 22:51:12 +00:00
Michael Goulet
bf66723c0e Test and note unsafe ctor to fn ptr coercion
Also remove a note that I don't consider to be very useful in context.
2023-08-30 15:09:40 -07:00
Michael Goulet
0100a94231 rustc_layout_scalar_valid_range makes ctors unsafe 2023-08-30 15:01:58 -07:00
Christian Legnitto
da86cdf3a5
Make termcolor types public in rustc_errors
After https://github.com/rust-lang/rust/pull/114104, `rust-gpu` is unable to create a custom `Emitter` as the bounds have changed to include `WriteColor`.

I was able to work around this by adding `termcolor` as a direct dependency, but I believe this should be exposed as part of `rustc_errors` proper.

See https://github.com/rust-lang/rust/pull/102992 for why `rust-gpu` needs to create a custom emitter.
2023-08-30 16:06:49 -04:00
bors
59a8294849 Auto merge of #115144 - Zoxc:parallel-guard, r=compiler-errors
Add `ParallelGuard` type to handle unwinding in parallel sections

This adds a `ParallelGuard` type to handle unwinding in parallel sections instead of manually dealing with panics in each parallel operation. This also adds proper panic handling to the `join` operation.

cc `@SparrowLii`
2023-08-30 19:33:13 +00:00
Michael Goulet
4647aea7aa Don't record spans for predicates in coherence 2023-08-30 18:24:18 +00:00
bors
8c79e8d756 Auto merge of #115058 - Swatinem:inline-add-coverage, r=compiler-errors
Inline functions called from `add_coverage`

This removes quite a bit of indirection and duplicated code related to getting the `FunctionCoverage`.

CC `@Zalathar`
2023-08-30 17:43:38 +00:00
John Kåre Alsaker
c303c8abdd Use a parallel_guard function to handle the parallel guard 2023-08-30 18:17:38 +02:00
John Kåre Alsaker
d36393b839 Use Mutex to avoid issue with conditional locks 2023-08-30 18:17:38 +02:00
John Kåre Alsaker
242805442b Update failure status 2023-08-30 18:13:09 +02:00
John Kåre Alsaker
b56acac41d Add ParallelGuard type to handle unwinding in parallel sections 2023-08-30 18:13:06 +02:00
John Kåre Alsaker
51eb8427bf Make parallel! an expression 2023-08-30 18:12:18 +02:00
bors
ac02e40380 Auto merge of #114616 - oli-obk:gotta_capture_'em_all, r=compiler-errors
Capture all lifetimes for TAITs and impl trait in associated types

This reverts commit cb9467515b, reversing changes made to 57781b24c5. (This is only true for the tests, the change itself was done from scratch, as the compiler has diverged sufficiently for a revert to not make sense anymore).

This implements the lang team decision from this meeting: https://hackmd.io/sFaSIMJOQcuwCdnUvCxtuQ?view

r? `@cjgillot` on the impl
2023-08-30 15:57:26 +00:00
Ralf Jung
c37bd09d88 miri function ABI check: specifically look for repr(transparent) 2023-08-30 17:07:25 +02:00
Ralf Jung
c1a34729e1 organize failing ABI compat tests and add some more 2023-08-30 17:04:54 +02:00
Ralf Jung
1e95aa0c49 interpret: make sure we accept transparent newtypes as ABI-compatible
also we were missing the case for Vector arguments, so handle those as well
2023-08-30 17:04:54 +02:00
bors
26089ba0a2 Auto merge of #114483 - RalfJung:unsized-fields, r=oli-obk
interpret: fix projecting into an unsized field of a local

See the new Miri testcase that didn't work before.

r? `@oli-obk`
2023-08-30 11:55:48 +00:00
Ralf Jung
6d1ce9bd13 storage_live: avoid computing the layout unless necessary 2023-08-30 13:46:55 +02:00
Ralf Jung
f87e91de7d unify passing of sized and unsized function arguments :-) 2023-08-30 13:46:55 +02:00
Ralf Jung
7cdeff266c a bit of meta-related cleanup on Projectable 2023-08-30 13:46:55 +02:00
Ralf Jung
a09df43d9f move marking-locals-live out of push_stack_frame, so it happens with argument passing
this entirely avoids even creating unsized locals in Immediate::Uninitialized state
2023-08-30 13:46:54 +02:00
Lukas Wirth
76ee9acc61 ignore-cross-compile remaining tests that run binaries 2023-08-30 13:45:57 +02:00
Ralf Jung
bdd5855b8e interpret: fix projecting into an unsized field of a local
new invariant: Place::Local never refers to something unsized
2023-08-30 13:43:34 +02:00
Oli Scherer
e82ccd52db Test variances of TAITs 2023-08-30 11:23:42 +00:00
Oli Scherer
e0a60f0740 Revert "Auto merge of #102417 - oli-obk:opaque_lifetimes2, r=jackh726"
This reverts commit cb9467515b, reversing
changes made to 57781b24c5.
2023-08-30 11:06:46 +00:00
Rémy Rakic
72725529e1 clean up local_overflow_limit computation
fixes bors snafu where it merged an outdated commit and missed this
change
2023-08-30 09:43:36 +00:00
Oli Scherer
92cfd209f1 Move some logic using rustc datastructures to the rustc_smir module 2023-08-30 08:10:28 +00:00
Oli Scherer
03b03f9fee Reuse the ty::Const: Stable impl 2023-08-30 08:09:41 +00:00
Oli Scherer
3a736a747d Exhaustively match on ty::Const::kind 2023-08-30 08:08:39 +00:00
Oli Scherer
9b8e3eb8f7 Move around constants' Stable impls a bit 2023-08-30 08:08:39 +00:00
bors
61efe9d298 Auto merge of #111713 - Zoxc:lock-switch, r=nnethercote
Use conditional synchronization for Lock

This changes `Lock` to use synchronization only if `mode::is_dyn_thread_safe` could be true. This reduces overhead for the parallel compiler running with 1 thread.

The emitters are changed to use `DynSend` instead of `Send` so they can still use `Lock`.

A Rayon thread pool is not used with 1 thread anymore, as session globals contains `Lock`s which are no longer `Sync`.

Performance improvement with 1 thread and `cfg(parallel_compiler)`:
<table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">1.7665s</td><td align="right">1.7336s</td><td align="right">💚  -1.86%</td></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.2780s</td><td align="right">0.2736s</td><td align="right">💚  -1.61%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">0.9994s</td><td align="right">0.9824s</td><td align="right">💚  -1.70%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">1.5875s</td><td align="right">1.5656s</td><td align="right">💚  -1.38%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check</td><td align="right">6.0682s</td><td align="right">5.9532s</td><td align="right">💚  -1.90%</td></tr><tr><td>Total</td><td align="right">10.6997s</td><td align="right">10.5083s</td><td align="right">💚  -1.79%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9831s</td><td align="right">💚  -1.69%</td></tr></table>

cc `@SparrowLii`
2023-08-30 08:03:43 +00:00
bors
7659abc63d Auto merge of #115370 - matthiaskrgr:rollup-l0e1zuj, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #113565 (Make SIGSEGV handler emit nicer backtraces)
 - #114704 (parser: not insert dummy field in struct)
 - #115272 (miri/diagnostics: don't forget to print_backtrace when ICEing on unexpected errors)
 - #115313 (Make `get_return_block()` return `Some` only for HIR nodes in body)
 - #115347 (suggest removing `impl` in generic trait bound position)
 - #115355 (new solver: handle edge case of a recursion limit of 0)
 - #115363 (Don't suggest adding parentheses to call an inaccessible method.)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-30 06:16:17 +00:00
Matthias Krüger
ea2347843c
Rollup merge of #115363 - kpreid:suggest-private, r=compiler-errors
Don't suggest adding parentheses to call an inaccessible method.

Previously, code of this form would emit E0615 (attempt to use a method as a field), thus emphasizing the existence of private methods that the programmer probably does not care about. Now it ignores their existence instead, producing error E0609 (no field). The motivating example is:

```rust
let x = std::rc::Rc::new(());
x.inner;
```

which would previously mention the private method `Rc::inner()`, even though `Rc<T>` intentionally has no public methods so that it can be a transparent smart pointer for any `T`.

```rust
error[E0615]: attempted to take value of method `inner` on type `Rc<()>`
 --> src/main.rs:3:3
  |
3 | x.inner;
  |   ^^^^^ method, not a field
  |
help: use parentheses to call the method
  |
3 | x.inner();
  |        ++
  ```

  With this change, it emits E0609 and no suggestion.
2023-08-30 07:18:13 +02:00
Matthias Krüger
36182f1f13
Rollup merge of #115355 - lqd:issue-115351, r=compiler-errors
new solver: handle edge case of a recursion limit of 0

Apparently a recursion limit of 0 is possible/valid/useful/used/cute, the more you know 🌟 .

(It's somewhat interesting to me that the old solver seemingly handles this, and that the new solver currently requires a recursion limit of 2 here)

r? `@compiler-errors.`

Fixes #115351.
2023-08-30 07:18:13 +02:00
Matthias Krüger
58c690729c
Rollup merge of #115347 - y21:generic-bound-impl-trait-ty, r=compiler-errors
suggest removing `impl` in generic trait bound position

rustc already does this recovery in type param position (`<T: impl Trait>` -> `<T: Trait>`).
This PR also adds that suggestion in trait bound position (e.g. `where T: impl Trait` or `trait Trait { type Assoc: impl Trait; }`)
2023-08-30 07:18:12 +02:00
Matthias Krüger
2128efd87f
Rollup merge of #115313 - gurry:issue-114918-cycle-detected, r=compiler-errors
Make `get_return_block()` return `Some` only for HIR nodes in body

Fixes #114918

The issue occurred while compiling the following input:

```rust
fn uwu() -> [(); { () }] {
    loop {}
}
```

It was caused by the code below trying to suggest a missing return type which resulted in a const eval cycle: 1bd043098e/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs (L68-L75)

The root cause was `get_return_block()` returning an `Fn` node for a node in the return type (i.e. the second `()` in the return type `[(); { () }]` of the input) although it is supposed to do so only for nodes that lie in the body of the function and return `None` otherwise (at least as per my understanding).

The PR fixes the issue by fixing this behaviour of `get_return_block()`.
2023-08-30 07:18:11 +02:00
Matthias Krüger
23f86255ef
Rollup merge of #115272 - RalfJung:miri-error-print, r=saethlin
miri/diagnostics: don't forget to print_backtrace when ICEing on unexpected errors

This should fix the missing output encountered [here](https://github.com/rust-lang/rust/issues/115145#issuecomment-1694334410).

r? `@saethlin`
2023-08-30 07:18:11 +02:00
Matthias Krüger
639116505a
Rollup merge of #114704 - bvanjoi:fix-114636, r=compiler-errors
parser: not insert dummy field in struct

Fixes #114636

This PR eliminates the dummy field, initially introduced in #113999, thereby enabling unrestricted use of `ident.unwrap()`. A side effect of this action is that we can only report the error of the first macro invocation field within the struct node.

An alternative solution might be giving a virtual name to the macro, but it appears more complex.(https://github.com/rust-lang/rust/issues/114636#issuecomment-1670228715). Furthermore, if you think https://github.com/rust-lang/rust/issues/114636#issuecomment-1670228715 is a better solution, feel free to close this PR.
2023-08-30 07:18:10 +02:00
Matthias Krüger
dafea5f919
Rollup merge of #113565 - workingjubilee:better-signal-handler-message, r=pnkfelix
Make SIGSEGV handler emit nicer backtraces

This annotates the code heavily with comments to explain what is going on, for the benefit of other compiler contributors. The backtrace also emits appropriate comments to clarify, to a programmer who may not know why a bunch of file paths and hexadecimal blather was just dumped into stderr, what is going on. Finally, it detects cycles and uses their regularity to avoid repeating a bunch of text. The previous backtraces we were emitting was extremely unfriendly, potentially confusing, and often alarming, and this makes things almost "nice".

We can't necessarily make them much nicer than this, because a signal handler must use "signal-safe" functions. This precludes conveniences like dynamic allocations. Fortunately, Rust's stdlib has allocation-free formatting, but it may hinder integrating this error with our localization middleware, as I wasn't able to clearly ascertain, at a glance, whether there was a zero-alloc path through it.

r? `@Nilstrieb`
2023-08-30 07:18:10 +02:00
bors
82c2eb48ee Auto merge of #114908 - cjgillot:no-let-under, r=compiler-errors
Do not compute unneeded query results.

r? `@ghost`
2023-08-30 04:29:17 +00:00
John Kåre Alsaker
d35179f665 Don't use wait_for_query without the Rayon thread pool 2023-08-30 06:10:02 +02:00