Commit Graph

252517 Commits

Author SHA1 Message Date
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
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
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
bors 63f70b3d10 Auto merge of #123991 - fmease:rollup-96xcgnm, r=fmease
Rollup of 7 pull requests

Successful merges:

 - #123016 (Remove `TypeVariableOriginKind` and `ConstVariableOriginKind`)
 - #123462 (Cleanup: Rename `ModSep` to `PathSep`)
 - #123603 (Don't even parse an intrinsic unless the feature gate is enabled)
 - #123926 (Fix pretty HIR for anon consts in diagnostics)
 - #123973 (crashes: readme: add reminder to add Fixes #abcde to prs to automatically close issues.)
 - #123984 (sanitizers: Add rustc_sanitizers to triagebot.toml)
 - #123989 (Just use `type_dependent_def_id` to figure out what the method is for an expr)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-16 00:03:54 +00:00
León Orell Valerian Liehr daa2ebc70c
Rollup merge of #123989 - compiler-errors:type-dependent-def-id, r=oli-obk
Just use `type_dependent_def_id` to figure out what the method is for an expr

The calls to `lookup_method_for_diagnostic` are overkill.

r? oli-obk
2024-04-16 01:12:39 +02:00
León Orell Valerian Liehr 445eb2e876
Rollup merge of #123984 - rcvalle:rust-triagebot-add-rustc-sanitizers, r=compiler-errors
sanitizers: Add rustc_sanitizers to triagebot.toml
2024-04-16 01:12:39 +02:00
León Orell Valerian Liehr f0d235ac04
Rollup merge of #123973 - matthiaskrgr:crashs_fix_cmt, r=fmease
crashes: readme: add reminder to add Fixes #abcde to prs to automatically close issues.
2024-04-16 01:12:38 +02:00
León Orell Valerian Liehr 1069ad3982
Rollup merge of #123926 - compiler-errors:no-ann, r=estebank
Fix pretty HIR for anon consts in diagnostics

This removes the `NoAnn` printer which skips over nested bodies altogether, which is confusing, and requires users of `{ty|qpath|pat}_to_string` to pass in `&tcx` which now impleemnts `hir_pretty::PpAnn`.

There's one case where this "regresses" by actually printing out the body of the anon const -- we could suppress that, but I don't expect people to actually get anon consts like that unless they're fuzzing, tbh.

r? estebank
2024-04-16 01:12:38 +02:00
León Orell Valerian Liehr 1ad9fea871
Rollup merge of #123603 - compiler-errors:no-intrinsic, r=estebank
Don't even parse an intrinsic unless the feature gate is enabled

Don't return true in `tcx.is_intrinsic` if the function is defined locally and `#![feature(intrinsics)]` is not enabled. This is a slightly more general fix than #123526, since #123587 shows that we have simplifying assumptions about intrinsics elsewhere in the compiler.

This will make the code ICE again if the user **enables** `#[feature(intrinsics)]`, but I kind of feel like if we want to fix that, we should make the `INTERNAL_FEATURES` lint `Deny` again. Perhaps we could do that on non-nightly compilers. Or we should just stop compilation altogether if they have `#![feature]` enabled on a non-nightly compiler.

As for the UX of *real* cases of hitting these ICEs, I believe pretty strongly that if a compiler/stdlib dev is modifying internal intrinsics (intentionally, like when making a change to rustc) we have no guarantee to make the ICE better looking for them. Honestly, *not* spitting out a stack trace is probably a disservice to the people who hit those ICEs in that case.

r? `@Nilstrieb` `@estebank`
2024-04-16 01:12:37 +02:00
León Orell Valerian Liehr c5665990c5
Rollup merge of #123462 - fmease:rn-mod-sep-to-path-sep, r=nnethercote
Cleanup: Rename `ModSep` to `PathSep`

`::` is usually referred to as the *path separator* (citation needed).

The existing name `ModSep` for *module separator* is a bit misleading since it in fact separates the segments of arbitrary path segments, not only ones resolving to modules. Let me just give a shout-out to associated items (`T::Assoc`, `<Ty as Trait>::function`) and enum variants (`Option::None`).

Motivation: Reduce friction for new contributors, prevent potential confusion.

cc `@petrochenkov`
r? nnethercote or compiler
2024-04-16 01:12:37 +02:00
León Orell Valerian Liehr 9cc26b598a
Rollup merge of #123016 - compiler-errors:no-type-var-origin, r=lcnr
Remove `TypeVariableOriginKind` and `ConstVariableOriginKind`

It's annoying to have to import `TypeVariableOriginKind` just to fill it with `MiscVariable` for almost every use. Every other usage other than `TypeParameterDefinition` wasn't even used -- I can see how it may have been useful once for debugging, but I do quite a lot of typeck debugging and I've never really needed it.

So let's just remove it, and keep around the only useful thing which is the `DefId` of the param for `var_for_def`.

This is based on #123006, which removed the special use of `TypeVariableOriginKind::OpaqueInference`, which I'm pretty sure I was the one that added.

r? lcnr or re-roll to types
2024-04-16 01:12:36 +02:00
Michael Goulet 2beb6a4782 Fix clippy 2024-04-15 18:48:12 -04:00
Michael Goulet 9d72808b1e Add test 2024-04-15 18:48:12 -04:00
Michael Goulet 619e044178 Fix pretty hir for anon consts in diagnostics 2024-04-15 18:48:12 -04:00
Michael Howell ecbe327e71 rustdoc: move tests into applicable subdirectories 2024-04-15 15:22:04 -07:00
Michael Howell 9a577e81c3 rustdoc: rename `issue-\d+.rs` tests to have meaningful names 2024-04-15 15:13:05 -07:00
Michael Howell 381a0e3cb0 Move ice tests to rustdoc-ui 2024-04-15 15:11:49 -07:00
Michael Howell 31052bb8a4 Add URL and crate_name to test cases 2024-04-15 15:11:48 -07:00
Michael Goulet 98890be9c4 Rebase fallout 2024-04-15 17:37:56 -04:00
bors ccfcd950b3 Auto merge of #123451 - Kobzol:arbitrary-try-build, r=pietroalbini
CI: add a script for dynamically computing CI job matrix

It would be great if was easier to run specific CI workflows locally, and also to allow us to spawn a specific CI workflow by bors, to enable running arbitrary try builds. See discussion [here](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/CI.20workflows.20refactoring).

This PR is a first step in that direction.
- Moves the definition of CI runners and (for now) PR jobs into a separate `jobs.yml` file.
- Adds a simple Python script that reads the file, decides which jobs should be active for the current CI workflow, and prints them as JSON to their output.
- The PR job then reads this output and generates its job matrix based on it.

By moving the job definitions from `ci.yml` into a separate file, we can handle it programmatically, which should make it easier to both do local execution of CI jobs and also to do arbitrary try builds.
2024-04-15 21:28:25 +00:00
Michael Goulet 05bb3d2683 Just use type_dependent_def_id to figure out what the method is for an expr 2024-04-15 17:14:59 -04:00
Michael Goulet 25c0cf0a66 nits 2024-04-15 16:52:51 -04:00
Michael Goulet ba6c166ee4 Account for Self params properly 2024-04-15 16:52:50 -04:00
Michael Goulet eb6f856169 Remove ConstVariableOriginKind 2024-04-15 16:52:12 -04:00
Michael Goulet 34bce07e8e Remove TypeVariableOriginKind 2024-04-15 16:51:50 -04:00
Matthias Krüger 83d73e4929 crashes: readme: add reminder to add Fixes #abcde to prs to automatically close issues. 2024-04-15 21:44:04 +02:00
Ramon de C Valle 99e88e59c8 sanitizers: Add rustc_sanitizers to triagebot.toml 2024-04-15 12:41:32 -07:00
Jakub Beránek 72104e245b
Add comments 2024-04-15 21:21:45 +02:00
bors 3493a56529 Auto merge of #123982 - compiler-errors:rollup-m2v4epp, r=compiler-errors
Rollup of 4 pull requests

Successful merges:

 - #123900 (Stop using `PolyTraitRef` for closure/coroutine predicates already instantiated w placeholders)
 - #123924 (Fix various bugs in `ty_kind_suggestion`)
 - #123943 (Use the rustc_private libc less in tests)
 - #123970 (zkvm: fix references to `os_str` module)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-15 19:19:50 +00:00
Michael Goulet 27cb6bcb9b
Rollup merge of #123970 - risc0:erik/zkvm-fix-os-str, r=joboet
zkvm: fix references to `os_str` module

The `os_str` module has been moved to `sys`. This change fixes build issues by changing `use` to point to `crate::sys::os_str`.
2024-04-15 15:18:07 -04:00
Michael Goulet 89e55f7bef
Rollup merge of #123943 - saethlin:less-sysroot-libc, r=workingjubilee
Use the rustc_private libc less in tests

I started looking into our use of `rustc_private` + `extern crate libc;` in tests because of https://github.com/rust-lang/rust/pull/123938 and it looks like some fraction of the users of libc simply don't need the libc crate anymore.
2024-04-15 15:18:06 -04:00
Michael Goulet 20a5fb3b4a
Rollup merge of #123924 - compiler-errors:tuple-sugg, r=estebank
Fix various bugs in `ty_kind_suggestion`

Consolidates two implementations of `ty_kind_suggestion`
Fixes some misuse of the empty param-env
Fixes a problem where we suggested `(42)` instead of `(42,)` for tuple suggestions
Suggest a value when `return;`, making it consistent with `break;`
Fixes #123906
2024-04-15 15:18:06 -04:00
Michael Goulet 314dee528b
Rollup merge of #123900 - compiler-errors:nobound, r=lcnr
Stop using `PolyTraitRef` for closure/coroutine predicates already instantiated w placeholders

r? lcnr
2024-04-15 15:18:05 -04:00
bors 99d0186b1d Auto merge of #123968 - jieyouxu:rollup-1pnkxor, r=jieyouxu
Rollup of 12 pull requests

Successful merges:

 - #123423 (Distribute LLVM bitcode linker as a preview component)
 - #123548 (libtest: also measure time in Miri)
 - #123666 (Fix some typos in doc)
 - #123864 (Remove a HACK by instead inferring opaque types during expected/formal type checking)
 - #123896 (Migrate some diagnostics in `rustc_resolve` to session diagnostic)
 - #123919 (builtin-derive: tag → discriminant)
 - #123922 (Remove magic constants when using `base_n`.)
 - #123931 (Don't leak unnameable types in `-> _` recover)
 - #123933 (move the LargeAssignments lint logic into its own file)
 - #123934 (`rustc_data_structures::graph` mini refactor)
 - #123941 (Fix UB in LLVM FFI when passing zero or >1 bundle)
 - #123957 (disable create_dir_all_bare test on all(miri, windows))

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-15 16:46:59 +00:00
Erik Kaneda ee0aea5f65
zkvm: fix references to `os_str` module
The `os_str` module has been moved to `sys`.
2024-04-15 09:32:21 -07:00
Michael Goulet 9e630d3f21 PolyTraitRefs -> TraitRefs 2024-04-15 12:04:44 -04:00
许杰友 Jieyou Xu (Joe) 723c0e23bc
Rollup merge of #123957 - RalfJung:create_dir_all_bare, r=joboet
disable create_dir_all_bare test on all(miri, windows)
2024-04-15 16:56:19 +01:00
许杰友 Jieyou Xu (Joe) 4f3a39ba79
Rollup merge of #123941 - Mark-Simulacrum:fix-llvm-ub, r=nikic
Fix UB in LLVM FFI when passing zero or >1 bundle

Rust passes a `*const &OperandBundleDef` to these APIs, usually from a `Vec<&OperandBundleDef>` or so. Previously we were dereferencing that pointer and passing it to the ArrayRef constructor with some length (N).

This meant that if the length was 0, we were dereferencing a pointer to nowhere (if the vector on the Rust side didn't actually get allocated or so), and if the length was >1 then loading the *second* element somewhere in LLVM would've been reading past the end.

Since Rust can't hold OperandBundleDef by-value we're forced to indirect through a vector that copies out the OperandBundleDefs from the by-reference list on the Rust side in order to match the LLVM expected API.
2024-04-15 16:56:19 +01:00
许杰友 Jieyou Xu (Joe) 5580ae9795
Rollup merge of #123934 - WaffleLapkin:graph-mini-refactor, r=fmease
`rustc_data_structures::graph` mini refactor

Who doesn't love to breathe dust from the ancient times?
2024-04-15 16:56:18 +01:00
许杰友 Jieyou Xu (Joe) b79d0b0849
Rollup merge of #123933 - RalfJung:large-assignments, r=michaelwoerister
move the LargeAssignments lint logic into its own file

The collector is a file full of very subtle logic, so let's try to keep that separate from the logic that only serves to implement this lint.
2024-04-15 16:56:18 +01:00
许杰友 Jieyou Xu (Joe) 313b02a86b
Rollup merge of #123931 - compiler-errors:variance-unnameables, r=fmease
Don't leak unnameable types in `-> _` recover

Fixes #123899
2024-04-15 16:56:17 +01:00
许杰友 Jieyou Xu (Joe) 1870e2d09f
Rollup merge of #123922 - TDecking:base_n_magic_removal, r=jieyouxu
Remove magic constants when using `base_n`.

Some use cases of `base_n` use number literals instead of the predefined constants. The latter are more descriptive so it might be better to use those instead.
2024-04-15 16:56:17 +01:00