Commit Graph

258101 Commits

Author SHA1 Message Date
Jubilee Young
26dccadb47 Allow "C-unwind" fn to have C variadics 2024-06-22 15:14:14 -07:00
bors
a0f01c3c10 Auto merge of #126838 - matthiaskrgr:rollup-qkop22o, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #126140 (Rename `std::fs::try_exists` to  `std::fs::exists` and stabilize fs_try_exists)
 - #126318 (Add a `x perf` command for integrating bootstrap with `rustc-perf`)
 - #126552 (Remove use of const traits (and `feature(effects)`) from stdlib)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-22 18:48:10 +00:00
Matthias Krüger
dc9a08f535
Rollup merge of #126552 - fee1-dead-contrib:rmfx, r=compiler-errors
Remove use of const traits (and `feature(effects)`) from stdlib

The current uses are already unsound because they are using non-const impls in const contexts. We can reintroduce them by reverting the commit in this PR, after #120639 lands.

Also, make `effects` an incomplete feature.

cc `@rust-lang/project-const-traits`
r? `@compiler-errors`
2024-06-22 19:33:56 +02:00
Matthias Krüger
162120b4fa
Rollup merge of #126318 - Kobzol:bootstrap-perf, r=onur-ozkan
Add a `x perf` command for integrating bootstrap with `rustc-perf`

This PR adds a new `x perf` command to bootstrap. The idea is to let rustc developers profile (`profile_local`) and benchmark (`bench_local`) a stage1/stage2 compiler directly from within `rust`.

Before, if you wanted to use `rustc-perf`, you had to clone it, set it up, copy the `rustc` sysroot after every change to `rust` etc. This is an attempt to automate that.

I opened this PR mostly for discussion. My idea is to offer an interface that looks something like this (a random sample of commands):
```bash
x perf --stage 2 profile eprintln
x perf --stage1 profile cachegrind
x perf benchmark --id baseline
x perf benchmark --id after-edit
x perf cmp baseline after-edit
```

In this PR, I'd like to only implement the simplest case (`profile_local (eprintln)`), because that only requires a single sysroot (you don't compare anything), and it's relatively easy to set up. Also, I'd like to avoid forcing developers to deal with the rustc-perf UI, so more complex use-cases (like benchmarking two sysroots and comparing the results) should probably wait for https://github.com/rust-lang/rustc-perf/issues/1734 (which is hopefully coming along soon-ish).

I'm not sure if it's better to do this in bootstrap directly, or if I should create some shim tool that will receive a `rustc` sysroot, and offer a simplified CLI on top of `rustc-perf`.

## Why is a separate CLI needed?
We definitely need to add some support to bootstrap to automate preparing `rustc-perf` and the `rustc` sysroot, but in theory after that we could just let people invoke `rustc-perf` manually. While that is definitely possible, you'd need to manually figure out where is your sysroot located, which seems annoying to me. The `rustc-perf` CLI is also relatively complex, and for this use-case it makes sense to only use a subset of it. So I thought that it would be better to offer a simplified interface on top of it that would make life easier for contributors. But maybe it's not worth it.

CC `@onur-ozkan`
2024-06-22 19:33:56 +02:00
Matthias Krüger
f3ced9d540
Rollup merge of #126140 - eduardosm:stabilize-fs_try_exists, r=Amanieu
Rename `std::fs::try_exists` to  `std::fs::exists` and stabilize fs_try_exists

FCP completed in tracking issue.

Tracking issue: https://github.com/rust-lang/rust/issues/83186

Closes https://github.com/rust-lang/rust/issues/83186

Stabilized API:

```rust
mod fs {
    pub fn exists<P: AsRef<Path>>(path: P) -> io::Result<bool>;
}
```
2024-06-22 19:33:55 +02:00
bors
f944afe380 Auto merge of #116113 - kpreid:arcmut, r=dtolnay
Generalize `{Rc,Arc}::make_mut()` to unsized types.

* `{Rc,Arc}::make_mut()` now accept any type implementing the new unstable trait `core::clone::CloneToUninit`.
* `CloneToUninit` is implemented for `T: Clone` and for `[T] where T: Clone`.
* `CloneToUninit` is a generalization of the existing internal trait `alloc::alloc::WriteCloneIntoRaw`.
* New feature gate: `clone_to_uninit`

This allows performing `make_mut()` on `Rc<[T]>` and `Arc<[T]>`, which was not previously possible.

---

Previous PR description, now obsolete:

>  Add `{Rc, Arc}::make_mut_slice()`
>
> These functions behave identically to `make_mut()`, but operate on `Arc<[T]>` instead of `Arc<T>`.
>
> This allows performing the operation on slices, which was not previously possible because `make_mut()` requires `T: Clone` (and slices, being `!Sized`, do not and currently cannot implement `Clone`).
>
> Feature gate: `make_mut_slice`

try-job: test-various
2024-06-22 16:35:29 +00:00
Kevin Reid
88c3db57e4 Generalize {Rc,Arc}::make_mut() to unsized types.
This requires introducing a new internal type `RcUninit` (and
`ArcUninit`), which can own an `RcBox<T>` without requiring it to be
initialized, sized, or a slice. This is similar to `UniqueRc`, but
`UniqueRc` doesn't support the allocator parameter, and there is no
`UniqueArc`.
2024-06-22 08:08:00 -07:00
Kevin Reid
a9a4830d25 Replace WriteCloneIntoRaw with CloneToUninit. 2024-06-22 08:08:00 -07:00
Kevin Reid
ec201b8650 Add core::clone::CloneToUninit.
This trait allows cloning DSTs, but is unsafe to implement and use
because it writes to possibly-uninitialized memory which must be of the
correct size, and must initialize that memory.

It is only implemented for `T: Clone` and `[T] where T: Clone`, but
additional implementations could be provided for specific `dyn Trait`
or custom-DST types.
2024-06-22 08:08:00 -07:00
Deadbeef
81da6a6d40 Make effects an incomplete feature 2024-06-22 14:11:11 +00:00
bors
ac47dbad50 Auto merge of #126824 - GuillaumeGomez:rollup-sybv8o7, r=GuillaumeGomez
Rollup of 5 pull requests

Successful merges:

 - #126555 (Add `f16` inline ASM support for 32-bit ARM)
 - #126686 (Add `#[rustc_dump_{predicates,item_bounds}]`)
 - #126723 (Fix `...` in multline code-skips in suggestions)
 - #126731 (Bootstrap command refactoring: refactor `BootstrapCommand` (step 1))
 - #126823 (Migrate `run-make/inline-always-many-cgu` to `rmake.rs`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-22 13:05:31 +00:00
Guillaume Gomez
d265538016
Rollup merge of #126823 - GuillaumeGomez:migrate-run-make-inline-always-many-cgu, r=Kobzol
Migrate `run-make/inline-always-many-cgu` to `rmake.rs`

Part of https://github.com/rust-lang/rust/issues/121876.

r? `@jieyouxu`
2024-06-22 12:57:21 +02:00
Guillaume Gomez
25bcc7d130
Rollup merge of #126731 - Kobzol:bootstrap-cmd-refactor, r=onur-ozkan
Bootstrap command refactoring: refactor `BootstrapCommand` (step 1)

This PR is a first step towards https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap.

It refactors `BoostrapCommand` to get it closer to a state where it is an actual command wrapper that can be routed through a central place of command execution, and also to make the distinction between printing output vs handling output programatically clearer (since now it's a mess).

The existing usages of `BootstrapCommand` are complicated primarily because of different ways of handling output. There are commands that:
1) Want to eagerly print stdout/stderr of the executed command, plus print an error message if the command fails (output mode `PrintAll`). Note that this error message attempts to print stdout/stderr of the command when `-v` is enabled, but that will always be empty, since this mode uses `.status()` and not `.output()`.
2) Want to eagerly print stdout/stderr of the executed command, but do not print any additional error message if it fails (output mode `PrintOutput`)
3) Want to capture stdout/stderr of the executed command, but print an error message if it fails (output mode `PrintFailure`). This means that the user wants to either ignore the output or handle it programatically, but that's not obvious from the name.

The difference between 1) and 2) (unless explicitly specified) is determined dynamically based on the bootstrap verbosity level.

It is very difficult for me to wrap my head around all these modes. I think that in a future PR, we should split these axes into e.g. this:
1) Do I want to handle the output programmatically or print it to the terminal? This should be a separate axis, true/false. (Note that "hiding the output" essentially just means saying that I handle it programmatically, and then I ignore the output).
2) Do I want to print a message if the command fails? Yes/No/Based on verbosity (which would be the default).

Then there is also the failure mode, but that is relatively simple to handle, the command execution will just shutdown bootstrap (either eagerly or late) when the command fails.

Note that this is just a first refactoring steps, there are a lot of other things to be done, so some things might not look "final" yet. The next steps are (not necessarily in this order):
- Remove `run` and `run_cmd` and implement everything in terms of `run_tracked` and rename `run_tracked` to `run`
- Implement the refactoring specified above (change how output modes work)
- Modify `BootstrapCmd` so that it stores `Command` instead of `&mut Command` and remove all the annoying `BootstrapCmd::from` by changing `Command::new` to `BootstrapCmd::new`
- Refactor the rest of command executions not currently using `BootstrapCmd` that can access Builder to use the correct output and failure modes. This will include passing Builder to additional places.
- Handle the most complex cases, such as output streaming. That will probably need to be handled separately.
- Refactor the rest of commands that cannot access builder (e.g. `Config::parse`) by introducing a new command context that will be passed to these places, and then stored in `Builder`. Move certain fields (such as `fail_fast`) from `Builder` to the command context.
- Handle the co-operation of `Builder`, `Build`, `Config` and command context. There are some fields and logic used during command execution that are distributed amongst `Builder/Build/Config`, so it will require some refactoring to make it work if the execution will happen on a separate place (in the command context).
- Refactor logging of commands, so that it is either logged to a file or printed in a nice hierarchical way that cooperates with the `Step` debug hierarchical output.
- Implement profiling of commands (add command durations to the command log, print a log of slowest commands and their execution counts at the end of bootstrap execution, perhaps store command executions to `metrics.json`).
- Implement caching of commands.
- Implement testing of commands through snapshot tests/mocking.

Best reviewed commit by commit.

r? ``@onur-ozkan``
2024-06-22 12:57:20 +02:00
Guillaume Gomez
399c5cabdd
Rollup merge of #126723 - estebank:dot-dot-dot, r=Nadrieril
Fix `...` in multline code-skips in suggestions

When we have long code skips, we write `...` in the line number gutter.

For suggestions, we were "centering" the `...` with the line, but that was inconsistent with what we do in every other case *and* off-center.
2024-06-22 12:57:19 +02:00
Guillaume Gomez
3ed2cd74b5
Rollup merge of #126686 - fmease:dump-preds-n-item-bounds, r=compiler-errors
Add `#[rustc_dump_{predicates,item_bounds}]`

Conflicts with #126668.

As discussed
r? compiler-errors CC ``@fee1-dead``
2024-06-22 12:57:19 +02:00
Guillaume Gomez
07e8b3ac01
Rollup merge of #126555 - beetrees:f16-inline-asm-arm, r=Amanieu
Add `f16` inline ASM support for 32-bit ARM

Adds `f16` inline ASM support for 32-bit ARM. SIMD vector types are taken from [here](https://developer.arm.com/architectures/instruction-sets/intrinsics/#f:`@navigationhierarchiesreturnbasetype=[float]&f:@navigationhierarchieselementbitsize=[16]&f:@navigationhierarchiesarchitectures=[A32]).`

Relevant issue: #125398
Tracking issue: #116909

`@rustbot` label +F-f16_and_f128
2024-06-22 12:57:18 +02:00
bors
d03d6c0fea Auto merge of #126750 - scottmcm:less-unlikely, r=jhpratt
Stop using `unlikely` in `strict_*` methods

The `strict_*` methods don't need (un)likely, because the `overflow_panic` calls are all `#[cold]`, [meaning](https://llvm.org/docs/LangRef.html#function-attributes) that LLVM knows any branch to them is unlikely without us needing to say so.

r? libs
2024-06-22 10:54:53 +00:00
Guillaume Gomez
e7dfd4a913 Migrate run-make/inline-always-many-cgu to rmake.rs 2024-06-22 12:35:58 +02:00
Guillaume Gomez
d9962bb4d8 Make read_dir method take a mutable callback 2024-06-22 12:35:28 +02:00
bors
f1b0d54ca9 Auto merge of #126816 - weihanglo:update-cargo, r=weihanglo
Update cargo

17 commits in 3ed207e416fb2f678a40cc79c02dcf4f936a21ce..bc89bffa5987d4af8f71011c7557119b39e44a65
2024-06-18 19:18:22 +0000 to 2024-06-22 00:36:36 +0000
- test: migrate weak_dep_features, workspaces and yank to snapbox (rust-lang/cargo#14111)
- test: migrate features and features(2|_namespaced) to snapbox (rust-lang/cargo#14100)
- test: Add auto-redaction for not found error (rust-lang/cargo#14124)
- test: migrate build to snapbox (rust-lang/cargo#14068)
- test: migrate unit_graph, update and vendor to snapbox (rust-lang/cargo#14119)
- fix(test): Un-redact Packaged files (rust-lang/cargo#14123)
- test: Auto-redact file number (rust-lang/cargo#14121)
- test: migrate lints_table and lints/(mod|unknown_lints) to snapbox (rust-lang/cargo#14104)
- Simplify checking feature syntax (rust-lang/cargo#14106)
- test: migrate testsuites to snapbox (rust-lang/cargo#14091)
- Make `-Cmetadata` consistent across platforms (rust-lang/cargo#14107)
- fix(toml): Warn when edition is unuset, even when MSRV is unset (rust-lang/cargo#14110)
- Add `CodeFix::apply_solution` and impl `Clone` (rust-lang/cargo#14092)
- test: migrate `cargo_alias_config&cargo_config/mod` to snapbox (rust-lang/cargo#14093)
- Simplify checking for dependency cycles (rust-lang/cargo#14089)
- test: Migrate `pub_priv.rs` to snapshot (rust-lang/cargo#14103)
- test: migrate rustdoc and rustdocflags to snapbox (rust-lang/cargo#14098)

<!--
r? ghost
-->
2024-06-22 08:02:27 +00:00
Jakub Beránek
0bd58d8122
Apply review comments. 2024-06-22 09:35:39 +02:00
Jakub Beránek
250586cb2e
Wrap std Output in CommandOutput 2024-06-22 09:18:58 +02:00
bors
f0aceed540 Auto merge of #126817 - workingjubilee:rollup-0rg0k55, r=workingjubilee
Rollup of 7 pull requests

Successful merges:

 - #126530 (Add `f16` inline ASM support for RISC-V)
 - #126712 (Migrate `relocation-model`, `error-writing-dependencies` and `crate-name-priority` `run-make` tests to rmake)
 - #126722 (Add method to get `FnAbi` of function pointer)
 - #126787 (Add direct accessors for memory addresses in `Machine` (for Miri))
 - #126798 ([fuchsia-test-runner] Remove usage of kw_only)
 - #126809 (Remove stray `.` from error message)
 - #126811 (Add a tidy rule to check that fluent messages and attrs don't end in `.`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-22 05:51:57 +00:00
León Orell Valerian Liehr
38bd7a0fcb
Add #[rustc_dump_{predicates,item_bounds}] 2024-06-22 06:34:09 +02:00
Jubilee
1916b3d57f
Rollup merge of #126811 - compiler-errors:tidy-ftl, r=estebank
Add a tidy rule to check that fluent messages and attrs don't end in `.`

This adds a new dependency on `fluent-parse` to `tidy` -- we already rely on it in rustc so I feel like it's not that big of a deal.

This PR also adjusts many error messages that currently end in `.`; not all of them since I added an `ALLOWLIST`, excluded `rustc_codegen_*` ftl files, and `.teach_note` attributes.

r? ``@estebank`` ``@oli-obk``
2024-06-21 21:02:29 -07:00
Jubilee
539090e5cd
Rollup merge of #126809 - estebank:wording-tweak, r=oli-obk
Remove stray `.` from error message
2024-06-21 21:02:28 -07:00
Jubilee
b9ab6c3501
Rollup merge of #126798 - miguelfrde:master, r=tmandry
[fuchsia-test-runner] Remove usage of kw_only

We are still at Python 3.8 in Fuchsia infra. This was introduced at Python 3.10.

r? tmandry
r? erickt
2024-06-21 21:02:28 -07:00
Jubilee
9498d5cf2f
Rollup merge of #126787 - Strophox:get-bytes, r=RalfJung
Add direct accessors for memory addresses in `Machine` (for Miri)

The purpose of this PR is to enable direct (immutable) access to memory addresses in `Machine`, which will be needed for further extension of Miri.

This is done by adding (/completing missings pairs of) accessor functions, with the relevant signatures as follows:
```rust
/* rust/compiler/rustc_middle/src/mir/interpret/allocation.rs */

pub trait AllocBytes {
  // ..

  fn as_ptr(&self) -> *const u8;
/*fn as_mut_ptr(&mut self) -> *mut u8; -- Already in the compiler*/
}

impl<Prov: Provenance, Extra, Bytes: AllocBytes> Allocation<Prov, Extra, Bytes> {
  // ..

  pub fn get_bytes_unchecked_raw(&self) -> *const u8;
/*pub fn get_bytes_unchecked_raw_mut(&mut self) -> *mut u8; -- Already in the compiler*/
}
```
```rust
/* rust/compiler/rustc_const_eval/src/interpret/memory.rs */

impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
  // ..

  pub fn get_alloc_bytes_unchecked_raw(&self, id: AllocId) -> InterpResult<'tcx, *const u8>;
  pub fn get_alloc_bytes_unchecked_raw_mut(&mut self, id: AllocId) -> InterpResult<'tcx, *mut u8>;
}
```

r? ``@RalfJung``
2024-06-21 21:02:27 -07:00
Jubilee
1f9793f1aa
Rollup merge of #126722 - adwinwhite:ptr_fn_abi, r=celinval
Add method to get `FnAbi` of function pointer

Provide a StableMIR API to query `FnAbi` of a function pointer.

Fixes [rust-lang/project-stable-mir#63](https://github.com/rust-lang/project-stable-mir/issues/63)
2024-06-21 21:02:27 -07:00
Jubilee
84b0922565
Rollup merge of #126712 - Oneirical:bootest-constestllation, r=jieyouxu
Migrate `relocation-model`, `error-writing-dependencies` and `crate-name-priority` `run-make` tests to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

Needs MSVC try-job due to #28026, almost guaranteed to fail, but let's see anyways.

try-job: aarch64-gnu
`/* try-job: x86_64-msvc */`
try-job: x86_64-apple-1
try-job: armhf-gnu
try-job: test-various
2024-06-21 21:02:26 -07:00
Jubilee
e7956cd994
Rollup merge of #126530 - beetrees:f16-inline-asm-riscv, r=Amanieu
Add `f16` inline ASM support for RISC-V

This PR adds `f16` inline ASM support for RISC-V. A `FIXME` is left for `f128` support as LLVM does not support the required `Q` (Quad-Precision Floating-Point) extension yet.

Relevant issue: #125398
Tracking issue: #116909

`@rustbot` label +F-f16_and_f128
2024-06-21 21:02:26 -07:00
bors
10e1f5d212 Auto merge of #124101 - the8472:pidfd-methods, r=cuviper
Add PidFd::{kill, wait, try_wait}

#117957 changed `Child` kill/wait/try_wait to use its pidfd instead of the pid, when one is available.
This PR extracts those implementations and makes them available on `PidFd` directly.

The `PidFd` implementations differ significantly from the corresponding `Child` methods:

* the methods can be called after the child has been reaped, which will result in an error but will be safe. This state is not observable in `Child` unless something stole the zombie child
* the `ExitStatus` is not kept, meaning that only the first time a wait succeeds it will be returned
* `wait` does not close stdin
* `wait` only requires `&self` instead of `&mut self` since there is no state to maintain and subsequent calls are safe

Tracking issue: #82971
2024-06-22 03:35:52 +00:00
Weihang Lo
2c65a24b8c
Update cargo 2024-06-21 22:47:06 -04:00
bors
fcae62649e Auto merge of #126758 - spastorino:avoid-safe-outside-unsafe-blocks, r=compiler-errors
Do not allow safe/unsafe on static and fn items

Fixes #126749

r? `@compiler-errors`

Tracking:

- https://github.com/rust-lang/rust/issues/123743
2024-06-22 00:40:12 +00:00
Michael Goulet
ffd72b1700 Fix remaining cases 2024-06-21 19:00:18 -04:00
Michael Goulet
ea681ef281 Add a tidy rule to make sure that diagnostics don't end in periods 2024-06-21 19:00:18 -04:00
The 8472
8abf149bde to extract a pidfd we must consume the child
As long as a pidfd is on a child it can be safely reaped. Taking it
would mean the child would now have to be awaited through its pid, but could also
be awaited through the pidfd. This could then suffer from a recycling race.
2024-06-22 00:46:55 +02:00
The 8472
0787c7308c Add PidFd::{kill, wait, try_wait} 2024-06-22 00:46:55 +02:00
Esteban Küber
5d5892e966 Remove stray . from error message 2024-06-21 21:13:10 +00:00
bors
c1b336cb6b Auto merge of #126650 - compiler-errors:renames, r=lcnr
Rename a bunch of things in the new solver and `rustc_type_ir`

* Renames `interner()` to `cx()` in the solver and `TypeFolder`.
* Renames `Infcx` generic param to `D`
* Moves `infcx.rs` to `delegate.rs`

r? lcnr
2024-06-21 18:14:50 +00:00
Miguel Flores Ruiz de Eguino
d94a40516e
[fuchsia-test-runner] Remove usage of kw_only
We are still at Python 3.8 in Fuchsia infra. This was introduced at
Python 3.10.
2024-06-21 10:48:30 -07:00
beetrees
771e44ebd3
Add f16 inline ASM support for RISC-V 2024-06-21 18:48:20 +01:00
beetrees
753fb070bb
Add f16 inline ASM support for 32-bit ARM 2024-06-21 18:26:42 +01:00
Michael Goulet
db638ab968 Rename a bunch of things 2024-06-21 12:32:05 -04:00
bors
5ced3dad57 Auto merge of #125853 - tesuji:promote-fail-fast, r=cjgillot
promote_consts: some clean-up after experimenting

This is some clean-up after experimenting in #125916,
Prefer to review commit-by-commit.
2024-06-21 16:00:14 +00:00
Lzu Tao
7002a3f37f interpret: use trace to reduce noice 2024-06-21 13:51:33 +00:00
Lzu Tao
62a287528a Reuse allocation for Vec<Candidate> 2024-06-21 13:51:33 +00:00
bors
25c9f2ca06 Auto merge of #123165 - oli-obk:no_ord_def_id3, r=cjgillot
Stop sorting `Span`s' `SyntaxContext`, as that is incompatible with incremental

work towards https://github.com/rust-lang/rust/issues/90317

Luckily no one actually needed these to be sorted, so it didn't even affect diagnostics. I'm guessing they'd have been sorted by creation time anyway, so it wouldn't really have mattered.

r? `@cjgillot`
2024-06-21 13:47:43 +00:00
Santiago Pastorino
22831ed117
Do not allow safe usafe on static and fn items 2024-06-21 09:12:13 -03:00
Deadbeef
a6a83d3d4e bless tests 2024-06-21 11:57:24 +00:00