Commit Graph

252611 Commits

Author SHA1 Message Date
bors
1cec373f65 Auto merge of #124034 - GuillaumeGomez:rollup-ayztp9l, r=GuillaumeGomez
Rollup of 7 pull requests

Successful merges:

 - #122811 (Move `SourceMap` initialization)
 - #123512 (Match ergonomics 2024: Implement eat-one-layer)
 - #123811 (Use queue-based `RwLock` on more platforms)
 - #123859 (Remove uneeded clones now that TrustedStep implies Copy)
 - #123979 (Subtype predicates only exist on inference types, so we can allow them to register opaque types within them.)
 - #124016 (Outline default query and hook provider function implementations)
 - #124023 (Allow workproducts without object files.)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-16 19:52:48 +00:00
Guillaume Gomez
7709b7d44a
Rollup merge of #124023 - pacak:less-splody, r=jieyouxu
Allow workproducts without object files.

This pull request partially reverts changes from e16c3b4a44

Original motivation for this assert was described with "A WorkProduct without a saved file is useless"
which was true at the time but now it is possible to have work products with other types of files
(llvm-ir, asm, etc) and there are bugreports for this failure:

For example: https://github.com/rust-lang/rust/issues/123695

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

Now existing `assert` and `.unwrap_or_else` are unified into a single
check that emits slightly more user friendly error message if an object
files was meant to be produced but it's missing
2024-04-16 21:41:27 +02:00
Guillaume Gomez
4779115f2b
Rollup merge of #124016 - DaniPopes:dedup-default-providers, r=lcnr
Outline default query and hook provider function implementations

The default query and hook provider functions call `bug!` with a decently long message.
Due to argument inlining in `format_args!` ([`flatten_format_args`](https://github.com/rust-lang/rust/issues/78356)), this ends up duplicating the message for each query, adding ~90KB to `librustc_driver.so` of unreachable panic messages.
To avoid this, we can outline the common `bug!` logic.
2024-04-16 21:41:26 +02:00
Guillaume Gomez
f939d1ff48
Rollup merge of #123979 - oli-obk:define_opaque_types7, r=compiler-errors
Subtype predicates only exist on inference types, so we can allow them to register opaque types within them.

We were unable to come up with an example where this could be reached (subtype predicates with either side not being an infer var gets consumed during any `select_where_possible` invocation, of which we have a lot in typeck). To ensure we don't silently accept new behaviour in case we missed a situation where this could occur, I have added an assert that prevents opaque types from having their hidden type constrained.

r? `@compiler-errors`
2024-04-16 21:41:26 +02:00
Guillaume Gomez
183c706305
Rollup merge of #123859 - krtab:uneeded_clone, r=cuviper
Remove uneeded clones now that TrustedStep implies Copy

This is a follow up to 11fa1764ee (from #112083)
2024-04-16 21:41:25 +02:00
Guillaume Gomez
1176134114
Rollup merge of #123811 - joboet:queue_em_up, r=ChrisDenton
Use queue-based `RwLock` on more platforms

This switches over Windows 7, SGX and Xous to the queue-based `RwLock` implementation added in #110211, thereby fixing #121949 for Windows 7 and partially resolving #114581 on SGX. TEEOS can't currently be switched because it doesn't have a good thread parking implementation.

CC `@roblabla` `@raoulstrackx` `@xobs` Could you help me test this, please?
r? `@ChrisDenton` the Windows stuff should be familiar to you
2024-04-16 21:41:25 +02:00
Guillaume Gomez
239b3728d5
Rollup merge of #123512 - Jules-Bertholet:ref-pat-eat-one-layer-2024, r=Nadrieril
Match ergonomics 2024: Implement eat-one-layer

r? `@Nadrieril`

cc #123076

`@rustbot` label A-edition-2024 A-patterns
2024-04-16 21:41:24 +02:00
Guillaume Gomez
14496d561e
Rollup merge of #122811 - nnethercote:mv-SourceMap-init, r=WaffleLapkin
Move `SourceMap` initialization

So it happens at the same time as `SessionGlobals` initialization, rather than shortly afterward.

r? `@WaffleLapkin`
2024-04-16 21:41:23 +02:00
bors
468f115684 Auto merge of #124026 - matthiaskrgr:rollup-an6s6gq, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #122632 (fetch submodule before checking llvm stamp)
 - #123355 (Support type '/' to search)
 - #123501 (Stabilize checking of cfgs at compile-time: `--check-cfg` option)
 - #123535 (Match ergonomics 2024: `mut` doesn't reset binding mode)
 - #123711 (drop `changelog-seen`)
 - #123969 (The new solver ignores `DefineOpaqueTypes`, so switch it to `Yes`)
 - #124007 (Miri subtree update)
 - #124017 (Change a diagnostics-path-only `DefineOpaqueTypes` to `Yes`.)
 - #124018 (interpret: pass MemoryKind to before_memory_deallocation)
 - #124024 (interpret: remove outdated comment)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-16 17:37:00 +00:00
Matthias Krüger
4971d9ffe4
Rollup merge of #124024 - RalfJung:interpret-comment, r=oli-obk
interpret: remove outdated comment

In https://github.com/rust-lang/rust/pull/107756, allocation became generally fallible, so the "only panic if there is provenance" no longer applies.

r? ``@oli-obk``
2024-04-16 17:54:46 +02:00
Matthias Krüger
864ab0cc36
Rollup merge of #124018 - RalfJung:dealloc-memory-kind, r=oli-obk
interpret: pass MemoryKind to before_memory_deallocation

This will be needed for https://github.com/rust-lang/miri/pull/3475.

r? ``@oli-obk``
2024-04-16 17:54:45 +02:00
Matthias Krüger
25fd90cea8
Rollup merge of #124017 - oli-obk:define_opaque_types8, r=compiler-errors
Change a diagnostics-path-only `DefineOpaqueTypes` to `Yes`.

This can't possibly affect compilation, so it's safe to flip, even if I couldn't come up with an affected test

r? ``@compiler-errors``
2024-04-16 17:54:45 +02:00
Matthias Krüger
cf7900476e
Rollup merge of #124007 - RalfJung:miri, r=RalfJung
Miri subtree update

r? ``@ghost``
2024-04-16 17:54:44 +02:00
Matthias Krüger
cad7d94e0f
Rollup merge of #123969 - oli-obk:define_opaque_types6, r=compiler-errors
The new solver ignores `DefineOpaqueTypes`, so switch it to `Yes`

We assert that we are in the new solver in the line above

r? ``@compiler-errors``
2024-04-16 17:54:43 +02:00
Matthias Krüger
0aa7235423
Rollup merge of #123711 - onur-ozkan:drop-changelog-seen, r=albertlarsan68
drop `changelog-seen`

It's been 7 months since we deprecated this. It should be fine to remove it now.
2024-04-16 17:54:42 +02:00
Matthias Krüger
dc40da83e3
Rollup merge of #123535 - Jules-Bertholet:mut_dont_reset_binding_mode_2024, r=Nadrieril
Match ergonomics 2024: `mut` doesn't reset binding mode

r? ``@Nadrieril``

cc https://github.com/rust-lang/rust/issues/123076

``@rustbot`` label A-edition-2024 A-patterns
2024-04-16 17:54:42 +02:00
Matthias Krüger
f54219c473
Rollup merge of #123501 - Urgau:stabilize-check-cfg, r=petrochenkov
Stabilize checking of cfgs at compile-time: `--check-cfg` option

This PR stabilize the `--check-cfg` CLI option of `rustc` (and `rustdoc`) 🎉.

In particular this PR does two things:
  1. it makes the `--check-cfg` option stable
  2. and it moves the documentation to the stable books

FCP: https://github.com/rust-lang/rust/issues/82450#issuecomment-1965328542

Resolves #82450

``@rustbot`` labels +S-blocked +F-check-cfg
r? ``@petrochenkov``
2024-04-16 17:54:41 +02:00
Matthias Krüger
49f6c95ba3
Rollup merge of #123355 - mu001999:rustdoc/search, r=GuillaumeGomez
Support type '/' to search

Related topic on IRLO: https://internals.rust-lang.org/t/rustdoc-use-key-to-search-instead-of-s/20559
2024-04-16 17:54:40 +02:00
Matthias Krüger
592b1ca99a
Rollup merge of #122632 - onur-ozkan:fix-llvm-caching-bug, r=albertlarsan68
fetch submodule before checking llvm stamp

Previously, we were checking the LLVM stamp before fetching the submodule which leads to not being able to compile llvm on submodule updates.

Fixes #122612
Fixes #122787
2024-04-16 17:54:39 +02:00
Ralf Jung
5b8b9cfaaa interpret: remove outdated comment 2024-04-16 17:33:12 +02:00
Michael Baikov
a03aeca99a Allow workproducts without object files.
This pull request partially reverts changes from e16c3b4a44

Original motivation for this assert was described with "A WorkProduct without a saved file is useless"
which was true at the time but now it is possible to have work products with other types of files
(llvm-ir, asm, etc) and there are bugreports for this failure:

For example: https://github.com/rust-lang/rust/issues/123695

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

Now existing `assert` and `.unwrap_or_else` are unified into a single
check that emits slightly more user friendly error message if an object
files was meant to be produced but it's missing
2024-04-16 11:19:35 -04:00
joboet
10b6ca139e
std: fix lint on SGX 2024-04-16 16:50:56 +02:00
Ralf Jung
18bfca50f1 interpret: pass MemoryKind to before_memory_deallocation 2024-04-16 16:37:34 +02:00
Arthur Carcano
864eb7fa14 Remove uneeded clones now that TrustedStep implies Copy
This is a follow up to 11fa1764ee
2024-04-16 16:11:06 +02:00
Oli Scherer
e03926c143 Change a diagnostics-path-only DefineOpaqueTypes to Yes. 2024-04-16 14:00:53 +00:00
DaniPopes
780dfb803f
Outline default query and hook provider function implementations 2024-04-16 15:41:02 +02:00
bors
1dea922ea6 Auto merge of #124015 - GuillaumeGomez:rollup-s46ksxa, r=GuillaumeGomez
Rollup of 14 pull requests

Successful merges:

 - #120781 (Correct usage note on OpenOptions::append())
 - #121694 (sess: stabilize `-Zrelro-level` as `-Crelro-level`)
 - #122521 (doc(bootstrap): add top-level doc-comment to utils/tarball.rs)
 - #123491 (Fix ICE in `eval_body_using_ecx`)
 - #123574 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 6))
 - #123687 (Update ar_archive_writer to 0.2.0)
 - #123721 (Various visionOS fixes)
 - #123797 (Better graphviz output for SCCs and NLL constraints)
 - #123990 (Make `suggest_deref_closure_return` more idiomatic/easier to understand)
 - #123995 (Make `thir_tree` and `thir_flat` into hooks)
 - #123998 (Opaque types have no namespace)
 - #124001 (Fix docs for unstable_features lint.)
 - #124006 (Move size assertions for `mir::syntax` types into the same file)
 - #124011 (rustdoc: update the module-level docs of `rustdoc::clean`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-16 13:26:03 +00:00
Guillaume Gomez
f11b21bdb7
Rollup merge of #124011 - fmease:rustdoc-updated-clean-docs, r=GuillaumeGomez
rustdoc: update the module-level docs of `rustdoc::clean`

Let's update this 11-year-old documentation.
This would've helped me greatly when first starting out.

Please point out if I should add, clarify or correct anything.
I plan on looking through the rustc dev guide later to see if anything can be expanded upon over there, too.
2024-04-16 15:19:17 +02:00
Guillaume Gomez
dd083470e1
Rollup merge of #124006 - Zalathar:static-assert, r=nnethercote
Move size assertions for `mir::syntax` types into the same file

A redundant size assertion for `StatementKind` was added in #122937, because the existing assertion was in a different file.

This PR cleans that up, and also moves the `TerminatorKind` assertion into the same file where it belongs, to avoid the same thing happening again.

r? `@nnethercote`
2024-04-16 15:19:16 +02:00
Guillaume Gomez
583c1a09ee
Rollup merge of #124001 - ehuss:fix-unstable_features-docs, r=compiler-errors
Fix docs for unstable_features lint.

This fixes the `unstable_features` lint documentation (at https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html#unstable-features) so that it correctly displays the output (instead of showing `{{produces}}`). The lint was undeprecated in https://github.com/rust-lang/rust/pull/118639, but this little part was missed when that happened.
2024-04-16 15:19:16 +02:00
Guillaume Gomez
f5adfa0e69
Rollup merge of #123998 - compiler-errors:opaque-ns, r=davidtwco
Opaque types have no namespace

Opaques are never referenced by name -- even when we have `type X = impl Sized;`, `X` is the name of the type alias, not the opaque.
2024-04-16 15:19:15 +02:00
Guillaume Gomez
6629fe6c6d
Rollup merge of #123995 - compiler-errors:thir-hooks, r=oli-obk
Make `thir_tree` and `thir_flat` into hooks

No need for them to be queries, since they are only called with `-Zunpretty`
2024-04-16 15:19:15 +02:00
Guillaume Gomez
24cdb7ed56
Rollup merge of #123990 - compiler-errors:suggest-closure-ret-deref, r=oli-obk
Make `suggest_deref_closure_return` more idiomatic/easier to understand

The only functional change here really is just making it not use a fresh type variable for upvars. I'll point that out in the code.

The rest of the changes are just stylistic, because reading this code was really confusing me (variable names were vague, ways of accessing types were unidiomatic, order of operations was kind of strange, etc).

This is stacked on #123989.

r? oli-obk since you approved #122213
2024-04-16 15:19:14 +02:00
Guillaume Gomez
9da8f04da3
Rollup merge of #123797 - amandasystems:better-graphviz, r=oli-obk
Better graphviz output for SCCs and NLL constraints

This PR modifies the output for `-Z dump-mir-graphviz=yes`. Specifically, it changes the output of the files `.-------.nll.0.regioncx.all.dot` and `nll.0.regioncx.scc.dot` to be easier to read and contain some information that helped me during debugging. In particular:

- SCC indices are contracted to `SCC(n)` instead of `ConstraintSccIndex(n)` to compress the nodes
- SCC regions are in `{}` rather than `[]` (controversial since they are technically ordered by index, but I figured they're more sets than arrays conceptually since they're equivalence classes).
- For regions in other universes than the root, also show the region universe (as ?8/U1)
- For regions with external names, show the external name in parenthesis
- For the region graph where edges are locations, render the All variant of the enum without the file since it's extremely long and often destroys the rendering
- For region graph edge annotations for single locations, remove the wrapping around the Location variant and just add its contents since this can be unambiguously done

Example output (from the function `foo()` of `tests/ui/error-codes/E0582.rs`) for an SCC graph:
![a graph showing SCCs](https://github.com/rust-lang/rust/assets/102855/0b998338-0379-4829-b99e-d8105c094897)

...and for the constraints:
![a graph showing regions and their constraints](https://github.com/rust-lang/rust/assets/102855/e984c4ca-7aa2-4db2-9878-bf38fe8208d5)

This PR also gives `UniverseIndex`es the `is_root()` method since this is now an operation that happens three times in the borrowck crate.
2024-04-16 15:19:14 +02:00
Guillaume Gomez
1c8bdb93d9
Rollup merge of #123721 - madsmtm:fix-visionos, r=davidtwco
Various visionOS fixes

A few small mistakes was introduced in https://github.com/rust-lang/rust/pull/121419, probably after the rename from `xros` to `visionos`. See the commits for details.

CC `@agg23`

Since you reviewed https://github.com/rust-lang/rust/pull/121419
r? davidtwco
2024-04-16 15:19:13 +02:00
Guillaume Gomez
9a7adb8d81
Rollup merge of #123687 - bjorn3:ar_archive_writer_0_2_0, r=oli-obk
Update ar_archive_writer to 0.2.0

This adds a whole bunch of tests checking for any difference with llvm's archive writer. It also fixes two mistakes in the porting from C++ to Rust. The first one causes a divergence for Mach-O archives which may or may not be harmless. The second will definitively cause issues, but only applies to thin archives, which rustc currently doesn't create.
2024-04-16 15:19:13 +02:00
Guillaume Gomez
e7c13c3357
Rollup merge of #123574 - notriddle:notriddle/issue-d, r=fmease
rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 6)

Follow up

* https://github.com/rust-lang/rust/pull/116214
* https://github.com/rust-lang/rust/pull/116432
* https://github.com/rust-lang/rust/pull/116824
* https://github.com/rust-lang/rust/pull/118105
* https://github.com/rust-lang/rust/pull/119561
2024-04-16 15:19:12 +02:00
Guillaume Gomez
ea7eb713d9
Rollup merge of #123491 - gurry:123154-ice-unsized-struct-eval, r=oli-obk
Fix ICE in `eval_body_using_ecx`

Ensures `TypeckResults` is tainted by failing candidate assembly for types with error

Fixes #123154
2024-04-16 15:19:11 +02:00
Guillaume Gomez
4232361d89
Rollup merge of #122521 - bnleft:master, r=albertlarsan68
doc(bootstrap): add top-level doc-comment to utils/tarball.rs
2024-04-16 15:19:11 +02:00
Guillaume Gomez
26b6a234a1
Rollup merge of #121694 - davidtwco:stabilize-relro-level, r=Mark-Simulacrum
sess: stabilize `-Zrelro-level` as `-Crelro-level`

Stabilise `-Zrelro-level` as `-Crelro-level`. There's no tracking issue for this flag to close.
2024-04-16 15:19:10 +02:00
Guillaume Gomez
17d62bcb1d
Rollup merge of #120781 - hniksic:master, r=m-ou-se
Correct usage note on OpenOptions::append()

This PR aims to correct the following usage note in `OpenOptions::append()`, which currently contains misleading information:

> One maybe obvious note when using append-mode: make sure that all data that belongs together is written to the file in one operation. This can be done by concatenating strings before passing them to [write()](https://doc.rust-lang.org/std/io/trait.Write.html#tymethod.write), or using a buffered writer (with a buffer of adequate size), and calling [flush()](https://doc.rust-lang.org/std/io/trait.Write.html#tymethod.flush) when the message is complete.

The above is misleading because, despite appearances, neither concatenating data before passing it to `write()`, nor delaying writes using `BufWriter`, ensures atomicity. `File::write()`, as well as the underlying `write(2)` system call, makes no guarantees that the data passed to it will be written out in full. It is allowed to write out only a part of the data, and has a return value that tells you how much it has written, at which point it has already returned and modified the file with partial data. Given this limitation, the only way to ensure atomicity of appends is through external locking.

Attempting to ensure atomicity by issuing data in a single `write()` is a footgun often stumbled upon by beginners, which shouldn't be advertised in the docs. The worst thing about the footgun is that it *appears* to work at first, only failing when the string becomes sufficiently large, or when some internal properties of the output file descriptor change (e.g. it is switched from regular file to a special file that talks to a socket or TTY), making it accept smaller writes. Additionally, the suggestion to use `BufWriter` skims over the issue of buffer sizes, as well as the fact that `BufWriter::flush()` contains a *loop* that can happily issue multiple writes. This loop is completely opaque to the caller, so you can't even assert atomicity after-the-fact.

The PR makes the following changes:

* removes the paragraph that suggests concatenating strings to pass them to `write()` for atomicity or using `BufWriter`
* adds a paragraph explaining why attempting to use `write()` to append atomically is not a good idea.
2024-04-16 15:19:10 +02:00
Hrvoje Niksic
d8745f9346 Update usage note on OpenOptions::append()
Avoid implying that concatenating data before passing it to `write()` (with
or without `BufWriter`) ensures atomicity.
2024-04-16 14:07:48 +02:00
León Orell Valerian Liehr
a5a1775c11
rustdoc: update module-level docs of rustdoc::clean 2024-04-16 13:55:28 +02:00
bors
4e1f5d90bc Auto merge of #123468 - compiler-errors:precise-capturing, r=oli-obk
Implement syntax for `impl Trait` to specify its captures explicitly (`feature(precise_capturing)`)

Implements `impl use<'a, 'b, T, U> Sized` syntax that allows users to explicitly list the captured parameters for an opaque, rather than inferring it from the opaque's bounds (or capturing *all* lifetimes under 2024-edition capture rules). This allows us to exclude some implicit captures, so this syntax may be used as a migration strategy for changes due to #117587.

We represent this list of captured params as `PreciseCapturingArg` in AST and HIR, resolving them between `rustc_resolve` and `resolve_bound_vars`. Later on, we validate that the opaques only capture the parameters in this list.

We artificially limit the feature to *require* mentioning all type and const parameters, since we don't currently have support for non-lifetime bivariant generics. This can be relaxed in the future.

We also may need to limit this to require naming *all* lifetime parameters for RPITIT, since GATs have no variance. I have to investigate this. This can also be relaxed in the future.

r? `@oli-obk`

Tracking issue:

- https://github.com/rust-lang/rust/issues/123432
2024-04-16 11:22:35 +00:00
bors
ad18fe08de Auto merge of #123963 - lqd:gdb15-failures, r=Kobzol
Disable two debuginfo tests failing under the future GDB 15 release

As seen in #123960, it seems two of our debuginfo tests started failing on gdb 15, which is also already in use in the `x86_64-gnu-llvm-18` builder: CI will randomly start to fail whenever this cached docker image expires.

This PR disables the following two tests under gdb 15+, to prevent future CI failures.

- `tests/debuginfo/include_string.rs`
- `tests/debuginfo/vec-slices.rs`

This seems very much related to https://sourceware.org/bugzilla/show_bug.cgi?id=30330 and https://sourceware.org/bugzilla/show_bug.cgi?id=31517 -- and I just now saw #122751 as well, where one of these bugzilla issues and one of the two test failures here was previously mentioned.

I don't know whether these are unexpected gdb changes, or if we need to change our tests as it seems some of the gdb changes are definitely intentional, so I'll just cc `@rust-lang/wg-debugging` and `@tromey.`

(In the same area, `tests/debuginfo/unsized.rs` was previously disabled due to https://sourceware.org/bugzilla/show_bug.cgi?id=30330. This issue has been fixed but I don't believe our test passes, so it's in the same boat as the 2 above regarding whether this test is expected to work or needs changes as well)

r? wg-debugging

I've confirmed this is enough to have CI pass on gdb 15 with the llvm 18 builder.
2024-04-16 09:20:20 +00:00
Oli Scherer
82e7773bc1 Subtype predicates only exist on inference types, so we can allow them to register opaque types within them. 2024-04-16 08:09:24 +00:00
Gurinder Singh
c30e15aded Fail candidate assembly for erroneous types
Trait predicates for types which have errors may still
evaluate to OK leading to downstream ICEs. Now we return
a selection error for such types in candidate assembly and
thereby prevent such issues
2024-04-16 12:42:48 +05:30
Ralf Jung
876ac7b1c3 avoid passing --sysroot twice in bootstrap 2024-04-16 08:52:36 +02:00
Ralf Jung
2f08c2c965 update lockfile 2024-04-16 07:52:25 +02:00
Zalathar
c0e7659cae Move size assertions for mir::syntax types into the same file
A redundant size assertion for `StatementKind` was added in #122937, because
the existing assertion was in a different file.

This patch cleans that up, and also moves the `TerminatorKind` assertion into
the same file where it belongs, to avoid the same thing happening again.
2024-04-16 15:18:43 +10:00