Commit Graph

273892 Commits

Author SHA1 Message Date
Walnut
a1191e30b6 force enum DISCR_* to const u64 to allow for inspection via LLDB's SBTypeStaticField::GetConstantValue() 2024-12-30 19:01:48 -06:00
Walnut
bc4266ca96 add LLVMRustDIBuilderCreateQualifiedType to ffi 2024-12-23 19:12:32 -06:00
bors
65fe42a5f4 Auto merge of #134493 - compiler-errors:drops-elaborated, r=oli-obk
Always run `tail_expr_drop_order` lint in promoted MIR query

Rather than running the lint at the beginning of `mir_drops_elaborated_and_const_checked`, run it at the end of `mir_promoted`.  This should ensure that the lint gets picked up when running `cargo fix`, which runs with `--emit metadata` and therefore doesn't actually query `mir_drops_elaborated_and_const_checked`.

We could probably push this down into `mir_built` too? but I don't really see a good reason to do so.

https://github.com/rust-lang/rust/issues/132861#issuecomment-2539960199

cc `@ehuss`
2024-12-23 22:14:38 +00:00
Michael Goulet
b893221517 Always run tail_expr_drop_order lint on promoted MIR 2024-12-23 20:25:41 +00:00
bors
bdc6b3de48 Auto merge of #134405 - rmehri01:x-completions, r=onur-ozkan
Generate shell completions for x as well

It would be nice to be have shell completions for both `./x` and `x` (installed with `cargo install --path src/tools/x`) instead of just `x.py`. This pr generates the corresponding completions for each shell in a similar way to `x.py` but under `x.<shell>` instead.
2024-12-23 19:31:58 +00:00
bors
addbd001ec Auto merge of #134687 - matthiaskrgr:rollup-m32tkax, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #134363 (Use `#[derive(Default)]` instead of manual `impl` when possible)
 - #134517 (Add tests for coverage attribute on trait functions)
 - #134528 (opt-dist: propagate channel info to bootstrap)
 - #134669 (Document the `--dev` flag for `src/ci/docker/run.sh`)
 - #134680 (Clean up a few rmake tests  )

r? `@ghost`
`@rustbot` modify labels: rollup
2024-12-23 16:40:02 +00:00
Matthias Krüger
a16fc10f23
Rollup merge of #134680 - lqd:run-make-cleanup, r=jieyouxu
Clean up a few rmake tests

Now I'm aware it's a bit late to start participating in the Advent of Tests, but here are a few cleanups in the rmake tests to put under the 🎄 anyways. A handful of unused imports, some warnings, and a couple typos.

r? `@jieyouxu` 🎅
2024-12-23 14:44:22 +01:00
Matthias Krüger
a62f245fb7
Rollup merge of #134669 - clubby789:dev-ci-mode, r=jieyouxu
Document the `--dev` flag for `src/ci/docker/run.sh`

This flag is very helpful for debugging CI issues locally, but it's not documented anywhere and I wasn't aware of it until `@jieyouxu` pointed it out. Add a note to the CI Docker readme to make this more discoverable
2024-12-23 14:44:21 +01:00
Matthias Krüger
cfb7a56676
Rollup merge of #134528 - jieyouxu:fix-rustc-bootstrap-test, r=Kobzol
opt-dist: propagate channel info to bootstrap

Fixes #133503.

Previously, `tests/ui/bootstrap/rustc_bootstap.rs` [sic] failed during [beta bump](https://github.com/rust-lang/rust/pull/133447#issuecomment-2501298794) in opt-dist tests. This is because:

- `opt-dist` tried to run `./x test` against beta-channel dist `rustc` through `bootstrap`.
- The dist build produced during the beta bump produces a `rustc` which correctly thinks that it is a beta compiler based on `src/ci/channel` info.
- `opt-dist` tries to run `./x test` on the beta `rustc` from the dist build, but without specifying channel through a synthetic `config.toml`, so `bootstrap` tells `compiletest` that we're on the `nightly` channel (by default).
- Now there's a channel mismatch: `compiletest` believes the `rustc` under test is a *nightly* rustc, but the `rustc` under test actually considers itself a *beta* rustc. This means that `//@ only-nightly` will be satisfied yet the test will fail as the *beta* rustc is not a *nightly* rustc.

This PR:

- Fixes the test failure during beta bump (i.e. #133503) by having `opt-dist` faithfully report the channel of the dist `rustc` being tested (i.e. "beta" in a beta bump PR). This will properly make the test be ignored during beta bump as the `rustc` under test is not a *nightly* rustc.
- Fixes the test name `rustc_bootstap.rs` -> `rustc_bootstrap.rs`. No more stapping.
- Slightly adjusts the doc comment in the test to make it more clear.

I ran a try-job against the beta branch (explicitly running the opt-dist tests by modifying the job definition) with these changes in #134131, and it appears that the try-job was [successful](https://github.com/rust-lang/rust/pull/134131#issuecomment-2555492215). The two commits in this PR are cherry-picked from #134131, with the test commit slightly modified (to also adjust the test comments).

r? `@Kobzol` (or compiler or bootstrap or infra I guess?)
2024-12-23 14:44:21 +01:00
Matthias Krüger
369be1855d
Rollup merge of #134517 - ehuss:coverage-trait-test, r=Zalathar
Add tests for coverage attribute on trait functions

This adds tests for the coverage attribute on trait functions. cc https://github.com/rust-lang/rust/issues/84605#issuecomment-2552420962
2024-12-23 14:44:20 +01:00
Matthias Krüger
95c33e303b
Rollup merge of #134363 - estebank:derive-default, r=SparrowLii
Use `#[derive(Default)]` instead of manual `impl` when possible

While working on #134175 I noticed a few manual `Default` `impl`s that could be `derive`d instead. These likely predate the existence of the `#[default]` attribute for `enum`s.
2024-12-23 14:44:20 +01:00
Eric Huss
5d9f17f58c Add test for coverage on a body-less trait function 2024-12-24 00:09:39 +11:00
Eric Huss
0efa90f246 Add a test for coverage attr on trait function 2024-12-24 00:09:38 +11:00
bors
904d8f6b39 Auto merge of #134681 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer`

r? `@ghost`
2024-12-23 12:18:14 +00:00
Laurențiu Nicola
8dbdcc03eb
Merge pull request #18746 from lnicola/sync-from-rust
minor: Sync from downstream
2024-12-23 10:12:23 +00:00
Rémy Rakic
6f19bd08b0 fix a few typos in rmake tests' comments 2024-12-23 09:40:38 +00:00
Rémy Rakic
9ca5df692b remove unnecessary mut from dump-ice-to-disk rmake test 2024-12-23 09:40:38 +00:00
Rémy Rakic
1d77a2c677 clean up remove-dir-all-race rmake test
- removes unused variables
- fixes a few typos
2024-12-23 09:40:38 +00:00
Rémy Rakic
d6a9ad6190 remove unused imports from rmake tests 2024-12-23 09:40:25 +00:00
bors
85c39893a7 Auto merge of #134677 - tgross35:rollup-ozoeyop, r=tgross35
Rollup of 4 pull requests

Successful merges:

 - #129220 (Add platform docs for FreeBSD.)
 - #134659 (test-infra: improve compiletest and run-make-support symlink handling)
 - #134668 (Make sure we don't lose default struct value when formatting struct)
 - #134672 (Revert stabilization of the `#[coverage(..)]` attribute)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-12-23 09:36:29 +00:00
clubby789
d124ec68b3 Link to dev guide on Docker testing 2024-12-23 09:35:14 +00:00
Laurențiu Nicola
0180d2d16f Bump rustc crates 2024-12-23 11:33:26 +02:00
Laurențiu Nicola
9420a0b11a Merge from rust-lang/rust 2024-12-23 11:27:07 +02:00
Laurențiu Nicola
214134902f Preparing for merge from rust-lang/rust 2024-12-23 11:26:54 +02:00
Trevor Gross
8fc4ba2ac1
Rollup merge of #134672 - Zalathar:revert-coverage-attr, r=wesleywiser
Revert stabilization of the `#[coverage(..)]` attribute

Due to a process mixup, the PR to stabilize the `#[coverage(..)]` attribute (#130766) was merged while there are still outstanding concerns. The default action in that situation is to revert, and the feature is not sufficiently urgent or uncontroversial to justify special treatment, so this PR reverts that stabilization.

---

- A key point that came up in offline discussions is that unlike most user-facing features, this one never had a proper RFC, so parts of the normal stabilization process that implicitly rely on an RFC break down in this case.
- As the implementor and de-facto owner of the feature in its current form, I would like to think that I made good choices in designing and implementing it, but I don't feel comfortable proceeding to stabilization without further scrutiny.
- There hasn't been a clear opportunity for T-compiler to weigh in or express concerns prior to stabilization.
- The stabilization PR cites a T-lang FCP that occurred in the tracking issue, but due to the messy design and implementation history (and lack of a clear RFC), it's unclear what that FCP approval actually represents in this case.
  - At the very least, we should not proceed without a clear statement from T-lang or the relevant members about the team's stance on this feature, especially in light of the other concerns listed here.
- The existing user-facing documentation doesn't clearly reflect which parts of the feature are stable commitments, and which parts are subject to change. And there doesn't appear to be a clear consensus anywhere about where that line is actually drawn, or whether the chosen boundary is acceptable to the relevant teams and individuals.
  - For example, the [stabilization report comment](https://github.com/rust-lang/rust/issues/84605#issuecomment-2166514660) mentions that some aspects are subject to change, but that text isn't consistent with my earlier comments, and there doesn't appear to have been any explicit discussion or approval process.
  - [The current reference text](https://github.com/rust-lang/reference/blob/4dfaa4f/src/attributes/coverage-instrumentation.md) doesn't mention this distinction at all, and instead simply describes the current implementation behaviour.
- When the implementation was changed to its current form, the associated user-facing error messages were not updated, so they still refer to the attribute only being allowed on functions and closures.
  - On its own, this might have been reasonable to fix-forward in the absence of other concerns, but the fact that it never came up earlier highlights the breakdown in process that has occurred here.

---

Apologies to everyone who was excited for this stabilization to land, but unfortunately it simply isn't ready yet.
2024-12-23 02:07:32 -05:00
Trevor Gross
c9c90dc4b5
Rollup merge of #134668 - compiler-errors:default-struct-value-fmt, r=ytmimi
Make sure we don't lose default struct value when formatting struct

The reason why https://github.com/rust-lang/rustfmt/issues/6424 broke when https://github.com/rust-lang/rust/pull/129514 landed is because the parser now *successfully* parses default struct values. That means that where we used to fail in `rewrite_macro_inner`:

e108481f74/src/tools/rustfmt/src/macros.rs (L263-L267)

... we now succeed, and we now proceed to format the inner struct as a macro arg. Since formatting was never implemented for default struct values, this means that we’ll always rewrite the struct to exclude the default value.

This PR makes it so that we simply don’t rewrite struct fields if they have a default value.

r? `@ytmimi`
2024-12-23 02:07:32 -05:00
Trevor Gross
fde85a8e5f
Rollup merge of #134659 - jieyouxu:recursive-remove, r=ChrisDenton
test-infra: improve compiletest and run-make-support symlink handling

I was trying to implement #134656 to port `tests/run-make/incr-add-rust-src-component.rs`, but found some blockers related to symlink handling, so in this PR I tried to resolve them by improving symlink handling in compiletest and run-make-support (particularly for native windows msvc environment).

Key changes:

- I needed to copy symlinks (duplicate a symlink pointing to the same file), so I pulled out the copy symlink logic and re-exposed it as `run_make_support::rfs::copy_symlink`. This helper correctly accounts for the Windows symlink-to-file vs symlink-to-dir distinction (hereafter "Windows symlinks") when copying symlinks.
- `recursive_remove`:
    - I needed a way to remove symlinks themselves (no symlink traversal). `std::fs::remove_dir_all` handles them, but only if the root path is a directory. So I wrapped `std::fs::remove_dir_all` to also handle when the root path is a non-directory entity (e.g. file or symlink). Again, this properly accounts for Windows symlinks.
    - I wanted to use this for both compiletest and run-make-support, so I put the implementation and accompanying tests in `build_helper`.
    - In this sense, it's a reland of #129302 with proper test coverage.
    - It's a thin wrapper around `std::fs::remove_dir_all` (`remove_dir_all` correctly handles read-only entries on Windows). The helper has additional permission-setting logic for when the root path is a non-dir entry on Windows to handle read-only non-dir entry.

Fixes #126334.
2024-12-23 02:07:31 -05:00
Trevor Gross
3acf9c93a4
Rollup merge of #129220 - asomers:target-maintainer, r=tgross35
Add platform docs for FreeBSD.
2024-12-23 02:07:31 -05:00
bors
66bb586952 Auto merge of #134608 - DianQK:disable-93775, r=jieyouxu
Add `ignore-rustc-debug-assertions` to `tests/ui/associated-consts/issue-93775.rs`

Closes #132111. Closes #133432.

I think this test case is flaky because the recursive calls happen to hit the upper limit of the call stack.

IMO, this may not be an issue, as it's reasonable for overly complex code to require additional build configurations (such as increasing the call stack size).

After set `rust.debug-assertions` is true, the test case requires a larger call stack, so disable it on `rust.debug-assertions=true`.

r? jieyouxu

try-job: x86_64-msvc
try-job: i686-msvc
2024-12-23 06:55:31 +00:00
bors
0eca4dd320 Auto merge of #134465 - lcnr:type-verifier, r=compiler-errors
cleanup `TypeVerifier`

We should merge it with the `TypeChecker` as we no longer bail in cases where it encounters an error since #111863.

It's quite inconsistent whether a check lives in the verifier or the `TypeChecker`, so this feels like a quite impactful cleanup. I expect that for this we may want to change the `TypeChecker` to also be a MIR visitor 🤔 this is non-trivial so I didn't fully do it in this PR.

Best reviewed commit by commit.

r? `@compiler-errors` feel free to reassign however
2024-12-23 04:15:41 +00:00
Esteban Küber
1f82b45b6a Use #[derive(Default)] instead of manually implementing it 2024-12-23 03:01:29 +00:00
Zalathar
87c2f9a5be Revert "Auto merge of #130766 - clarfonthey:stable-coverage-attribute, r=wesleywiser"
This reverts commit 1d35638dc3, reversing
changes made to f23a80a4c2.
2024-12-23 12:30:37 +11:00
bors
908af5ba4a Auto merge of #134666 - matthiaskrgr:rollup-whe0chp, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #130289 (docs: Permissions.readonly() also ignores root user special permissions)
 - #134583 (docs: `transmute<&mut T, &mut MaybeUninit<T>>` is unsound when exposed to safe code)
 - #134611 (Align `{i686,x86_64}-win7-windows-msvc` to their parent targets)
 - #134629 (compiletest: Allow using a specific debugger when running debuginfo tests)
 - #134642 (Implement `PointerLike` for `isize`, `NonNull`, `Cell`, `UnsafeCell`, and `SyncUnsafeCell`.)
 - #134660 (Fix spacing of markdown code block fences in compiler rustdoc)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-12-23 01:18:40 +00:00
Michael Goulet
68c46e13a2 Make sure we don't lose default struct value when formatting struct 2024-12-22 23:55:42 +00:00
bors
5a14967f7b Auto merge of #131311 - rust-lang:cargo_update, r=clubby789
Weekly `cargo update`

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

The following is the output from `cargo update`:

```txt

compiler & tools dependencies:
     Locking 15 packages to latest compatible versions
    Updating clap_complete v4.5.39 -> v4.5.40
    Updating env_filter v0.1.2 -> v0.1.3
    Updating env_logger v0.11.5 -> v0.11.6
    Updating expect-test v1.5.0 -> v1.5.1
    Updating foldhash v0.1.3 -> v0.1.4
    Updating miniz_oxide v0.8.1 -> v0.8.2
    Updating object v0.36.5 -> v0.36.7
    Updating serde_json v1.0.133 -> v1.0.134
    Updating thiserror v2.0.7 -> v2.0.9
    Updating thiserror-impl v2.0.7 -> v2.0.9
    Updating tinyvec v1.8.0 -> v1.8.1
    Updating wasm-encoder v0.221.2 -> v0.222.0
    Removing wasmparser v0.218.0
    Removing wasmparser v0.221.2
      Adding wasmparser v0.222.0
    Updating wast v221.0.2 -> v222.0.0
    Updating wat v1.221.2 -> v1.222.0
note: pass `--verbose` to see 35 unchanged dependencies behind latest

library dependencies:
     Locking 1 package to latest compatible version
    Updating object v0.36.5 -> v0.36.7
note: pass `--verbose` to see 6 unchanged dependencies behind latest

rustbook dependencies:
     Locking 9 packages to latest compatible versions
    Updating cc v1.2.0 -> v1.2.5
    Updating clap_complete v4.5.39 -> v4.5.40
    Updating env_filter v0.1.2 -> v0.1.3
    Updating env_logger v0.11.5 -> v0.11.6
    Updating libc v0.2.168 -> v0.2.169
    Updating miniz_oxide v0.8.1 -> v0.8.2
    Updating serde_json v1.0.133 -> v1.0.134
    Updating thiserror v2.0.7 -> v2.0.9
    Updating thiserror-impl v2.0.7 -> v2.0.9
```
2024-12-22 22:29:29 +00:00
Matthias Krüger
d05edbe652
Rollup merge of #134660 - dtolnay:markdowncode, r=lqd
Fix spacing of markdown code block fences in compiler rustdoc

Two place have misaligned open and close ```` ``` ````.

I noticed these because one of them disrupted syntax highlighting in my editor for the rest of the file as I was working on a different change.

<p align="center"><img src="https://github.com/user-attachments/assets/5de21d08-c30c-4e9c-8587-e83b988b9db5" width="500"></p>
2024-12-22 21:59:28 +01:00
Matthias Krüger
c16f00cff6
Rollup merge of #134642 - kpreid:pointerlike-cell, r=compiler-errors
Implement `PointerLike` for `isize`, `NonNull`, `Cell`, `UnsafeCell`, and `SyncUnsafeCell`.

* Implementing `PointerLike` for `UnsafeCell` enables the possibility of interior mutable `dyn*` values. Since this means potentially exercising new codegen behavior, I added a test for it in `tests/ui/dyn-star/cell.rs`. Please let me know if there are further sorts of tests that should be written, or other care that should be taken with this change.

  It is unfortunately not possible without compiler changes to implement `PointerLike` for `Atomic*` types, since they are not `repr(transparent)` (and, in theory if not in practice, `AtomicUsize`'s alignment may be greater than that of an ordinary pointer or `usize`).

* Implementing `PointerLike` for `NonNull` is useful for pointer types which wrap `NonNull`.

* Implementing `PointerLike` for `isize` is just for completeness; I have no use cases in mind, but I cannot think of any reason not to do this.

* Tracking issue: #102425

`@rustbot` label +F-dyn_star
(there is no label or tracking issue for F-pointer_like_trait)
2024-12-22 21:59:27 +01:00
Matthias Krüger
e86874f807
Rollup merge of #134629 - clubby789:debuginfo-specific, r=jieyouxu
compiletest: Allow using a specific debugger when running debuginfo tests

r? `@jieyouxu`

Closes #134468

Example: `./x test tests/debuginfo -- --debugger gdb`
2024-12-22 21:59:26 +01:00
Matthias Krüger
3d86da7939
Rollup merge of #134611 - tbu-:pr_win7_msvc_align, r=jieyouxu
Align `{i686,x86_64}-win7-windows-msvc` to their parent targets

There were some changes to `{i686,x86_64}-pc-windows-msvc`, include them in the backward compatibility targets as well.

CC `@roblabla`
2024-12-22 21:59:25 +01:00
Matthias Krüger
6ade237b6c
Rollup merge of #134583 - Enselic:maybe-uninit-transmute, r=workingjubilee
docs: `transmute<&mut T, &mut MaybeUninit<T>>` is unsound when exposed to safe code

Closes #66699

On my system (Edit: And also in the [playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=90529e2a9900599cb759e4bfaa5b5efe)) the example program terminates with an unpredictable exit code:
```console
$ cargo +nightly build && target/debug/bin ; echo $?
255
$ cargo +nightly build && target/debug/bin ; echo $?
253
```

And miri considers the code to have undefined behavior:
```console
$ cargo +nightly miri run
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
  --> src/main.rs:12:24
   |
12 |     std::process::exit(*code); // UB! Accessing uninitialized memory
   |                        ^^^^^ using uninitialized data, but this operation requires initialized memory
   |
error: aborting due to 1 previous error
```
2024-12-22 21:59:24 +01:00
Matthias Krüger
bd160f11f0
Rollup merge of #130289 - intgr-forks:Permissions-readonly-vs-unix-root, r=ChrisDenton
docs: Permissions.readonly() also ignores root user special permissions

The root user can write to files without any (write) permission bits set. But this is not taken into account by `std::fs::Permissions.readonly()`.

The rustdoc for `readonly()` also mentions shortcomings later:

> On Unix-based platforms this checks if any of the owner, group or others write permission bits are set. It does not check if the current user is in the file’s assigned group. It also does not check ACLs.

But since this part already clarifies how it works -- it checks write permission bits -- I think it's not necessary to repeat the root user shortcomings here.
2024-12-22 21:59:24 +01:00
Alan Somers
12b54b1e73 Add platform docs for FreeBSD. 2024-12-22 13:57:18 -07:00
Jieyou Xu
4d3bf1f5ee run-make-support: re-export recursive_remove
This facade is like other `run_make_support::fs` APIs that
panic-on-failure but includes the path that the operation was called on
in the panic message.
2024-12-23 03:25:36 +08:00
Jieyou Xu
7e2240338a compiletest: use recursive_remove instead of aggressive_rm_rf
`aggressive_rm_rf` does not correctly handle distinction between
symlink-to-file vs symlink-to-dir on Windows.
2024-12-23 03:25:36 +08:00
Jieyou Xu
98fdcaed50 build_helper: add recursive_remove helper
`recursive_remove` is intended to be a wrapper around
`std::fs::remove_dir_all`, but which also allows the removal target to
be a non-directory entry, i.e. a file or a symlink. It also tries to
remove read-only attributes from filesystem entities on Windows for
non-dir entries, as `std::fs::remove_dir_all` handles the dir (and its
children) read-only cases.

Co-authored-by: Chris Denton <chris@chrisdenton.dev>
2024-12-23 03:25:36 +08:00
许杰友 Jieyou Xu (Joe)
3b388eb9b6 run_make_support: extract copy_symlink helper 2024-12-23 03:25:36 +08:00
Kevin Reid
5c04151c6c Implement PointerLike for isize, NonNull, Cell, UnsafeCell, and SyncUnsafeCell.
Implementing `PointerLike` for `UnsafeCell` enables the possibility of
interior mutable `dyn*` values. Since this means potentially exercising
new codegen behavior, I added a test for it in `tests/ui/dyn-star/cell.rs`.

Also updated UI tests to account for the `isize` implementation changing
error messages.
2024-12-22 11:18:56 -08:00
bors
e108481f74 Auto merge of #134330 - scottmcm:no-more-rvalue-len, r=matthewjasper
Delete `Rvalue::Len` 🎉

Everything's moved to `PtrMetadata`, so we can get rid of the `Len` variant now.

~~Depends on #134326, so draft until that lands~~ Ready!

r? mir
2024-12-22 18:49:18 +00:00
Marti Raudsepp
edfdfbe832 docs: Permissions.readonly() also ignores root user special permissions
The root user can write to files without any (write) access bits set. But this is not taken into account by `std::fs::Permissions.readonly()`.
2024-12-22 20:47:41 +02:00
David Tolnay
34b33a6763
Fix spacing of markdown code block fences in compiler rustdoc 2024-12-22 10:16:31 -08:00