Commit Graph

241968 Commits

Author SHA1 Message Date
bors
1ab783112a Auto merge of #119258 - compiler-errors:closure-kind, r=eholk
Make closures carry their own ClosureKind

Right now, we use the "`movability`" field of `hir::Closure` to distinguish a closure and a coroutine. This is paired together with the `CoroutineKind`, which is located not in the `hir::Closure`, but the `hir::Body`. This is strange and redundant.

This PR introduces `ClosureKind` with two variants -- `Closure` and `Coroutine`, which is put into `hir::Closure`. The `CoroutineKind` is thus removed from `hir::Body`, and `Option<Movability>` no longer needs to be a stand-in for "is this a closure or a coroutine".

r? eholk
2023-12-26 04:25:53 +00:00
bors
2271c26e4a Auto merge of #119146 - nnethercote:rm-DiagCtxt-api-duplication, r=compiler-errors
Remove `DiagCtxt` API duplication

`DiagCtxt` defines the internal API for creating and emitting diagnostics: methods like `struct_err`, `struct_span_warn`, `note`, `create_fatal`, `emit_bug`. There are over 50 methods.

Some of these methods are then duplicated across several other types: `Session`, `ParseSess`, `Parser`, `ExtCtxt`, and `MirBorrowckCtxt`. `Session` duplicates the most, though half the ones it does are unused. Each duplicated method just calls forward to the corresponding method in `DiagCtxt`. So this duplication exists to (in the best case) shorten chains like `ecx.tcx.sess.parse_sess.dcx.emit_err()` to `ecx.emit_err()`.

This API duplication is ugly and has been bugging me for a while. And it's inconsistent: there's no real logic about which methods are duplicated, and the use of `#[rustc_lint_diagnostic]` and `#[track_caller]` attributes vary across the duplicates.

This PR removes the duplicated API methods and makes all diagnostic creation and emission go through `DiagCtxt`. It also adds `dcx` getter methods to several types to shorten chains. This approach scales *much* better than API duplication; indeed, the PR adds `dcx()` to numerous types that didn't have API duplication: `TyCtxt`, `LoweringCtxt`, `ConstCx`, `FnCtxt`, `TypeErrCtxt`, `InferCtxt`, `CrateLoader`, `CheckAttrVisitor`, and `Resolver`. These result in a lot of changes from `foo.tcx.sess.emit_err()` to `foo.dcx().emit_err()`. (You could do this with more types, but it gets into diminishing returns territory for types that don't emit many diagnostics.)

After all these changes, some call sites are more verbose, some are less verbose, and many are the same. The total number of lines is reduced, mostly because of the removed API duplication. And consistency is increased, because calls to `emit_err` and friends are always preceded with `.dcx()` or `.dcx`.

r? `@compiler-errors`
2023-12-26 02:24:39 +00:00
Michael Goulet
ba912855cc Flatten match 2023-12-25 21:13:41 +00:00
Michael Goulet
27dce304cb Fix clippy's usage of Body's coroutine_kind
Also fixes a bug where we weren't peeling blocks from async bodies
2023-12-25 21:13:41 +00:00
Michael Goulet
3320c09eab Only regular coroutines have movability 2023-12-25 21:13:41 +00:00
bors
e4c626dd9a Auto merge of #119261 - cjgillot:outlive-def-kind, r=compiler-errors
Do not fetch HIR in inferred_outlives_of.

Small simplification allowed by https://github.com/rust-lang/rust/pull/119248
2023-12-25 18:52:48 +00:00
Michael Goulet
909dd864f1 Make closures carry their own ClosureKind, rather than deducing what it is from movability 2023-12-25 16:29:15 +00:00
Michael Goulet
981fc6e174 Don't pass body into check_closure and child functions 2023-12-25 16:28:56 +00:00
Michael Goulet
bacfa976ca Remove unnecessary body_expr_count 2023-12-25 16:28:56 +00:00
bors
f8fe517144 Auto merge of #116274 - RalfJung:soft_unstable, r=cjgillot
make soft_unstable show up in future breakage reports

If we want to break these in the future, let's warn users of affected crates.
2023-12-25 16:26:15 +00:00
bors
71696e516d Auto merge of #119226 - Mark-Simulacrum:format-efficiency, r=TaKO8Ki
Improve coding efficiency for RawDefId

This copies the scheme already used for LazyArray, cutting a couple hundred kilobytes from libcore's metadata.
2023-12-25 14:28:00 +00:00
bors
13ea97cb14 Auto merge of #119292 - onur-ozkan:share-make-with-rustdoc, r=albertlarsan68
bootstrap: use same make flags with rustdoc

Keeping same `MAKEFLAGS` and `MFLAGS` for rustdoc should allow rustdoc to use the same jobserver.
2023-12-25 12:31:34 +00:00
onur-ozkan
c350d3c5dd bootstrap: use same make flags with rustdoc
Keeping same `MAKEFLAGS` and `MFLAGS` for rustdoc
should allow rustdoc to use the same jobserver.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-12-25 14:55:22 +03:00
bors
f2348fb29a Auto merge of #119122 - matthewjasper:if-let-guard-scoping, r=TaKO8Ki
Give temporaries in if let guards correct scopes

Temporaries in if-let guards have scopes that escape the match arm, this causes problems because the drops might be for temporaries that are not storage live. This PR changes the scope of temporaries in if-let guards to be limited to the arm:

```rust
_ if let Some(s) = std::convert::identity(&Some(String::new())) => {}
//                Temporary for Some(String::new()) is dropped here ^
```

We also now deduplicate temporaries between copies of the guard created for or-patterns:

```rust
// Only create a single Some(String::new()) temporary variable
_ | _ if let Some(s) = std::convert::identity(&Some(String::new())) => {}
```

This changes MIR building to pass around `ExprId`s rather than `Expr`s so that we have a way to index different expressions.

cc #51114
Closes #116079
2023-12-25 04:06:58 +00:00
bors
b87f649a5d Auto merge of #119283 - GuillaumeGomez:warning-block-pos, r=notriddle
Fix display of warning block if it is first element of the top doc block

It fixes the display of the warning block "i" element in case it is the first element:

![Screenshot from 2023-12-23 11-15-48](https://github.com/rust-lang/rust/assets/3050060/99b6796e-2a09-4053-813e-84288ce76c4c)

It now looks like this:

![image](https://github.com/rust-lang/rust/assets/3050060/306b4cf1-3a7d-4681-b0cf-3e721186bfe8)

The update for the `browser-ui-test` framework is because it didn't detect correctly pseudo elements if they ended with a digit or a dash.

r? `@notriddle`
2023-12-25 02:08:21 +00:00
bors
471dcbdb09 Auto merge of #119274 - RalfJung:raw-ptr-pattern-ice, r=compiler-errors
fix ICE when using raw ptr in a pattern

Fixes https://github.com/rust-lang/rust/issues/119270
2023-12-25 00:03:59 +00:00
bors
bf8716f1cd Auto merge of #119139 - michaelwoerister:cleanup-stable-source-file-id, r=cjgillot
Unify SourceFile::name_hash and StableSourceFileId

This PR adapts the existing `StableSourceFileId` type so that it can be used instead of the `name_hash` field of `SourceFile`. This simplifies a few things that were kind of duplicated before.

The PR should also fix issues https://github.com/rust-lang/rust/issues/112700 and https://github.com/rust-lang/rust/issues/115835, but I was not able to reproduce these issues in a regression test. As far as I can tell, the root cause of these issues is that the id of the originating crate is not hashed in the `HashStable` impl of `Span` and thus cache entries that should have been considered invalidated were loaded. After this PR, the `stable_id` field of `SourceFile` includes information about the originating crate, so that ICE should not occur anymore.
2023-12-24 21:58:39 +00:00
bors
e87ccb8676 Auto merge of #119276 - faern:stabilize-ip_in_core, r=dtolnay
Stabilize ip_in_core feature

Finally the last stage of https://github.com/rust-lang/rfcs/pull/2832. Since the FCP was [just completed with disposition *merge*](https://github.com/rust-lang/rust/issues/108443#issuecomment-1867864920), I create the stabilization PR for the `ip_in_core` feature. Allowing usage of `core::net` on stable Rust.

The error type `core::net::AddrParseError` itself becomes stable with this PR. However, `core::error::Error` is still unstable, so the `Error` impl for this type is not available on stable rust. Simply because `error_in_core` is not stable yet, but that should be fine!
2023-12-24 20:00:53 +00:00
Guillaume Gomez
98b71bf345 Add GUI regression test for position of warning block 2023-12-24 19:24:04 +01:00
Guillaume Gomez
279b11c4b5 Fix display of warning block if it is first element of the top doc block 2023-12-24 19:23:42 +01:00
Guillaume Gomez
2378227d73 Update browser-ui-test version to 0.16.11 2023-12-24 19:23:27 +01:00
bors
f736079c3c Auto merge of #119278 - bjorn3:sync_cg_clif-2023-12-24, r=bjorn3
Subtree sync for rustc_codegen_cranelift

This implements simd_masked_store and fixes two borked subtree syncs that forgot to sync back some changes to the rust repo.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2023-12-24 16:38:28 +00:00
bors
1a086e49f1 Auto merge of #118796 - Nadrieril:fix-exponential-id-match-2, r=cjgillot
Exhaustiveness: Improve complexity on some wide matches

https://github.com/rust-lang/rust/issues/118437 revealed an exponential case in exhaustiveness checking. While [exponential cases are unavoidable](https://compilercrim.es/rust-np/), this one only showed up after my https://github.com/rust-lang/rust/pull/117611 rewrite of the algorithm. I remember anticipating a case like this and dismissing it as unrealistic, but here we are :').

The tricky match is as follows:
```rust
match command {
    BaseCommand { field01: true, .. } => {}
    BaseCommand { field02: true, .. } => {}
    BaseCommand { field03: true, .. } => {}
    BaseCommand { field04: true, .. } => {}
    BaseCommand { field05: true, .. } => {}
    BaseCommand { field06: true, .. } => {}
    BaseCommand { field07: true, .. } => {}
    BaseCommand { field08: true, .. } => {}
    BaseCommand { field09: true, .. } => {}
    BaseCommand { field10: true, .. } => {}
    // ...20 more of the same

    _ => {}
}
```

To fix this, this PR formalizes a concept of "relevancy" (naming is hard) that was already used to decide what patterns to report. Now we track it for every row, which in wide matches like the above can drastically cut on the number of cases we explore. After this fix, the above match is checked with linear-many cases instead of exponentially-many.

Fixes https://github.com/rust-lang/rust/issues/118437

r? `@cjgillot`
2023-12-24 14:40:36 +00:00
bjorn3
bc1f3f5222 Fix borked subtree syncs 2023-12-24 14:38:37 +00:00
bjorn3
4b854efc9c Merge commit '26c02eb2904da9a53d2220d4f3069b19a3c81d3d' into sync_cg_clif-2023-12-24 2023-12-24 14:35:19 +00:00
bjorn3
26c02eb290 Rustup to rustc 1.77.0-nightly (2d7be7393 2023-12-23) 2023-12-24 14:26:46 +00:00
bjorn3
23e26ca386 Sync from rust 2d7be73931 2023-12-24 14:20:28 +00:00
bors
ebb821f625 Auto merge of #119265 - Mark-Simulacrum:remove-cache, r=cjgillot
Remove metadata decoding DefPathHash cache

My expectation is that this cache is largely useless. Decoding a DefPathHash from metadata is essentially a pair of memory loads - there's no heavyweight processing involved. Caching it behind a HashMap just adds extra cost and incurs hashing overheads for the indices.

Based on https://github.com/rust-lang/rust/pull/119238.
2023-12-24 12:41:58 +00:00
Linus Färnstrand
98899b7131 Stabilize ip_in_core feature 2023-12-24 12:23:50 +01:00
bors
08cc634f1a Auto merge of #117176 - bvanjoi:fix-116796, r=jackh726
mark ty::Const::Error when meet unsupport ty for const generic params

Close #116796
2023-12-24 10:28:25 +00:00
Ralf Jung
41020d1337 fix ICE when using raw ptr in a pattern 2023-12-24 11:10:38 +01:00
bors
cf6427373b Auto merge of #119238 - Mark-Simulacrum:def-hash-efficiency, r=cjgillot
Skip duplicate stable crate ID encoding into metadata

Instead, we store just the local crate hash as a bare u64. On decoding,
we recombine it with the crate's stable crate ID stored separately in
metadata. The end result is that we save ~8 bytes/DefIndex in metadata
size.

One key detail here is that we no longer distinguish in encoded metadata
between present and non-present DefPathHashes. It used to be highly
likely we could distinguish as we used DefPathHash::default(), an
all-zero representation. However in theory even that is fallible as
nothing strictly prevents the StableCrateId from being zero. In review it
was pointed out that we should never have a missing hash for a DefIndex anyway,
so this shouldn't matter.
2023-12-24 07:56:37 +00:00
bors
3166bbef92 Auto merge of #119268 - matthiaskrgr:rollup-7ggmcdn, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #119165 (improve container runner script)
 - #119205 (fix minor mistake in comments describing VecDeque resizing)
 - #119257 (interpret/memory: explain why we check is_thread_local_static)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-12-24 00:58:42 +00:00
Matthias Krüger
511eb0ae9b
Rollup merge of #119257 - RalfJung:tls-comments, r=petrochenkov
interpret/memory: explain why we check is_thread_local_static
2023-12-24 01:08:09 +01:00
Matthias Krüger
89c3236789
Rollup merge of #119205 - mumbleskates:vecdeque-comment-fix, r=Mark-Simulacrum
fix minor mistake in comments describing VecDeque resizing

Avoiding confusion where one of the items in the deque seems to disappear in two of the three cases
2023-12-24 01:08:09 +01:00
Matthias Krüger
09131a2e31
Rollup merge of #119165 - onur-ozkan:update-container-entrypoint, r=Kobzol
improve container runner script

First commit fixes #118930

Second commit is mostly for development purposes. In read-only mode submodules cannot be initialized due to access limitations (see the log below), which means that tools cannot be built.

```sh
Updating submodule src/tools/cargo
error: could not lock config file .git/config: Read-only file system
error: could not lock config file .git/config: Read-only file system
fatal: Failed to register url for submodule path 'src/tools/cargo'
error: could not lock config file .git/config: Read-only file system
error: could not lock config file .git/config: Read-only file system
fatal: Failed to register url for submodule path 'src/tools/cargo'
Build completed unsuccessfully in 0:00:00

```
2023-12-24 01:08:08 +01:00
bors
cdd6374f16 Auto merge of #119218 - Nadrieril:nested-opaque-reveal, r=compiler-errors
Exhaustiveness: Reveal empty opaques in depth

Follow-up to https://github.com/rust-lang/rust/pull/116821. As noted [there](https://github.com/rust-lang/rust/pull/116821#discussion_r1376673420), the current implementation doesn't detect emptiness of opaques when the opaque is nested inside a type. This doesn't matter for stable behavior (which ignores nested empty types anyway) but does matter for the [`exhaustive_patterns`](https://github.com/rust-lang/rust/issues/51085)/[`min_exhaustive_patterns`](https://github.com/rust-lang/rust/pull/118803) features.

This PR fixes this behavior by adding `InhabitedPredicate::apply_reveal_opaque` that considers opaque types when determining inhabitedness.

r? `@compiler-errors`
2023-12-23 23:00:08 +00:00
onur-ozkan
b498489c13 allow devs to turn-off read-only mode
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-12-24 00:58:46 +03:00
Nadrieril
efb04e6572 Rework the explanation of relevancy 2023-12-23 22:43:06 +01:00
Nicholas Nethercote
8a9db25459 Remove more Session methods that duplicate DiagCtxt methods. 2023-12-24 08:17:47 +11:00
Nicholas Nethercote
8af3d8dcab Remove MirBorrowckCtxt methods that duplicate DiagCtxt methods. 2023-12-24 08:17:46 +11:00
Nicholas Nethercote
99472c7049 Remove Session methods that duplicate DiagCtxt methods.
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier
access.
2023-12-24 08:05:28 +11:00
Nicholas Nethercote
d51db05d7e Remove ParseSess methods that duplicate DiagCtxt methods.
Also add missing `#[track_caller]` attributes to `DiagCtxt` methods as
necessary to keep tests working.
2023-12-24 07:59:21 +11:00
Nicholas Nethercote
ec9af0d6cb Remove Parser methods that duplicate DiagCtxt methods. 2023-12-24 07:48:47 +11:00
bors
2d7be73931 Auto merge of #119263 - matthiaskrgr:rollup-zxok9fb, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #112936 (Add illumos aarch64 target for rust.)
 - #119153 (stabilize `file_create_new`)
 - #119246 ([rustdoc] Add `is_object_safe` information for traits in JSON output)
 - #119254 (Remove an unused diagnostic struct)
 - #119255 (add a test for ICE #112822)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-12-23 20:39:47 +00:00
Nicholas Nethercote
d86a48278f Remove ExtCtxt methods that duplicate DiagCtxt methods. 2023-12-24 07:24:52 +11:00
Mark Rousskov
f098f346ec Remove metadata decoding DefPathHash cache
This cache is largely useless. Decoding a DefPathHash from metadata is
essentially a pair of memory loads - there's no heavyweight processing
involved. Caching it behind a HashMap just adds extra cost and incurs
hashing overheads.
2023-12-23 14:22:36 -05:00
Mark Rousskov
6630d69085 Specialize DefPathHash table to skip crate IDs
Instead, we store just the local crate hash as a bare u64. On decoding,
we recombine it with the crate's stable crate ID stored separately in
metadata. The end result is that we save ~8 bytes/DefIndex in metadata
size.

One key detail here is that we no longer distinguish in encoded metadata
between present and non-present DefPathHashes. It used to be highly
likely we could distinguish as we used DefPathHash::default(), an
all-zero representation. However in theory even that is fallible as
nothing strictly prevents the StableCrateId from being zero.
2023-12-23 14:10:28 -05:00
Matthias Krüger
aa2e5fadd8
Rollup merge of #119255 - fee1-dead-contrib:fix-ice, r=compiler-errors
add a test for ICE #112822

closes #112822.
2023-12-23 20:02:29 +01:00
Matthias Krüger
63290a90d3
Rollup merge of #119254 - fee1-dead-contrib:randomfix, r=compiler-errors
Remove an unused diagnostic struct

this is used at `rustc_middle::error`, is duplicated here somehow
2023-12-23 20:02:29 +01:00