Commit Graph

272426 Commits

Author SHA1 Message Date
bjorn3
401dd840ff Remove all threading through of ErrorGuaranteed from the driver
It was inconsistently done (sometimes even within a single function) and
most of the rest of the compiler uses fatal errors instead, which need
to be caught using catch_with_exit_code anyway. Using fatal errors
instead of ErrorGuaranteed everywhere in the driver simplifies things a
bit.
2024-12-06 18:42:31 +00:00
bjorn3
030545d8c3 Store a single copy of the error registry in DiagCtxt
And pass this to the individual emitters when necessary.
2024-12-06 18:42:31 +00:00
bjorn3
ea6f5cbd2f Move some timers around 2024-12-06 18:42:30 +00:00
bjorn3
84873f8613 Remove 'tcx lifetime from OnDiskCache 2024-12-06 18:41:50 +00:00
bors
cdeddae4f6 Auto merge of #133956 - bjorn3:sync_cg_clif-2024-12-06, r=bjorn3
Sync cg clif 2024 12 06

The main highlights this time are a Cranelift update disabling the clif ir verifier by default for better performance.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2024-12-06 15:49:11 +00:00
bjorn3
063e21b4c4 Cargo decided to add serde to cg_clif's lockfile despite serde support in Cranelift being disabled 2024-12-06 12:16:54 +00:00
bjorn3
b3d837afe1 Merge commit '57845a397ec15e4e6a561ed2c4bfa3dcf49144fb' into sync_cg_clif-2024-12-06 2024-12-06 12:10:30 +00:00
bjorn3
57845a397e Rustup to rustc 1.85.0-nightly (c94848c04 2024-12-05) 2024-12-06 11:56:16 +00:00
bors
bc145cec45 Auto merge of #133950 - matthiaskrgr:rollup-b7g5p73, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #130777 (rust_for_linux: -Zreg-struct-return commandline flag for X86 (#116973))
 - #133211 (Extend Miri to correctly pass mutable pointers through FFI)
 - #133790 (Improve documentation for Vec::extend_from_within)
 - #133930 (rustbook: update to use new mdbook-trpl package from The Book)
 - #133931 (Only allow PassMode::Direct for aggregates on wasm when using the C ABI)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-12-06 10:48:10 +00:00
Matthias Krüger
875df6c59c
Rollup merge of #133931 - bjorn3:even_stricter_fn_abi_sanity_checking, r=nnethercote
Only allow PassMode::Direct for aggregates on wasm when using the C ABI

For the Rust ABI we don't have any ABI compat reasons to allow PassMode::Direct for aggregates.
2024-12-06 09:27:41 +01:00
Matthias Krüger
026d21d2c1
Rollup merge of #133930 - chriskrycho:mdbook-trpl-package, r=ehuss
rustbook: update to use new mdbook-trpl package from The Book

Updates to the latest merge from `rust-lang/book` and simplifies the dependency chain there. There are now three preprocessors, but only one package, so everything is a lot nicer to deal with from the consuming POV (i.e. here).
2024-12-06 09:27:40 +01:00
Matthias Krüger
b7804043ed
Rollup merge of #133790 - HypheX:improve-vec-docs, r=harudagondi,workingjubilee
Improve documentation for Vec::extend_from_within

This closes #104762.

It rephrases some of the explanations, and greatly improves the clarity of the example.
Based on this PR and its discussions:
https://github.com/rust-lang/rust/pull/105030/files#r1059808792
2024-12-06 09:27:39 +01:00
Matthias Krüger
576176d8b7
Rollup merge of #133211 - Strophox:miri-correct-state-update-ffi, r=RalfJung
Extend Miri to correctly pass mutable pointers through FFI

Based off of https://github.com/rust-lang/rust/pull/129684, this PR further extends Miri to execute native calls that make use of pointers to *mutable* memory.
We adapt Miri's bookkeeping of internal state upon any FFI call that gives external code permission to mutate memory.

Native code may now possibly write and therefore initialize and change the pointer provenance of bytes it has access to: Such memory is assumed to be *initialized* afterwards and bytes are given *arbitrary (wildcard) provenance*. This enables programs that correctly use mutating FFI calls to run Miri without errors, at the cost of possibly missing Undefined Behaviour caused by incorrect usage of mutating FFI.

> <details>
>
> <summary> Simple example </summary>
>
> ```rust
> extern "C" {
>   fn init_int(ptr: *mut i32);
> }
>
> fn main() {
>   let mut x = std::mem::MaybeUninit::<i32>::uninit();
>   let x = unsafe {
>     init_int(x.as_mut_ptr());
>     x.assume_init()
>   };
>
>   println!("C initialized my memory to: {x}");
> }
> ```
> ```c
> void init_int(int *ptr) {
>   *ptr = 42;
> }
> ```
> should now show `C initialized my memory to: 42`.
>
> </details>

r? ``@RalfJung``
2024-12-06 09:27:39 +01:00
Matthias Krüger
820ddaf67a
Rollup merge of #130777 - azhogin:azhogin/reg-struct-return, r=workingjubilee
rust_for_linux: -Zreg-struct-return commandline flag for X86 (#116973)

Command line flag `-Zreg-struct-return` for X86 (32-bit) for rust-for-linux.
This flag enables the same behavior as the `abi_return_struct_as_int` target spec key.

- Tracking issue: https://github.com/rust-lang/rust/issues/116973
2024-12-06 09:27:38 +01:00
bjorn3
8922d30a87 Only allow PassMode::Direct for aggregates on wasm when using the C ABI
For the Rust ABI we don't have any ABI compat reasons to allow
PassMode::Direct for aggregates.
2024-12-06 08:26:33 +00:00
bors
acf48426b6 Auto merge of #133559 - compiler-errors:structurally-resolve-adjust-for-branch, r=lcnr
Structurally resolve in `adjust_for_branches`

r? lcnr
2024-12-06 04:55:35 +00:00
bors
706141b8d9 Auto merge of #133940 - GuillaumeGomez:rollup-nm1cz5j, r=GuillaumeGomez
Rollup of 8 pull requests

Successful merges:

 - #132155 (Always display first line of impl blocks even when collapsed)
 - #133256 (CI: use free runners for i686-gnu jobs)
 - #133607 (implement checks for tail calls)
 - #133821 (Replace black with ruff in `tidy`)
 - #133827 (CI: rfl: move job forward to Linux v6.13-rc1)
 - #133910 (Normalize target-cpus.rs stdout test for LLVM changes)
 - #133921 (Adapt codegen tests for NUW inference)
 - #133936 (Avoid fetching the anon const hir node that is already available)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-12-05 23:42:57 +00:00
Guillaume Gomez
5dc05a8d01
Rollup merge of #133936 - oli-obk:push-qmvqsmwqrtqr, r=lqd
Avoid fetching the anon const hir node that is already available
2024-12-05 23:47:13 +01:00
Guillaume Gomez
beb9b240f1
Rollup merge of #133921 - TimNN:nuw-infer, r=nikic
Adapt codegen tests for NUW inference

These were broken by 462cb3cd6c

Let me know if you think we should have a FIXME / tracking issue to update the tests after the LLVM 20 upgrade to make these required.

`@rustbot` label: +llvm-main

r? `@nikic`
2024-12-05 23:47:12 +01:00
Guillaume Gomez
e82ee9626e
Rollup merge of #133910 - TimNN:llvm-target-cpus, r=jieyouxu
Normalize target-cpus.rs stdout test for LLVM changes

LLVM has recently added support for the `lime1` CPU in 35cce408ee, so the `target-cpus.rs` test currently produces different output depending on the LLVM version.

This CL adds a normalization directive, to remove the new CPU from the output list.

Alternatives fixes I can think of:

* Add two revisions of the test (one per LLVM version)
* Ignore the test on one of the LLVM versions
  * I dislike this, because it's possible that the test won't get updated for the next LLVM version.

I don't think the exact list of target CPUs is relevant for this test, so it shouldn't be too bad if the normalization sticks around longer than necessary.

`@rustbot` label: +llvm-main
2024-12-05 23:47:12 +01:00
Guillaume Gomez
9765a4ee75
Rollup merge of #133827 - ojeda:ci-rfl, r=lqd
CI: rfl: move job forward to Linux v6.13-rc1

Linux v6.13-rc1 contains commit 28e848386b92 ("rust: block: fix formatting of `kernel::block::mq::request` module"), which in turn contains commit c95bbb59a9b2 ("rust: enable arbitrary_self_types and remove `Receiver`"), which is why we had a hash rather than a tag.

r? ```@Kobzol``` ```@lqd```
try-job: x86_64-rust-for-linux
```@rustbot``` label A-rust-for-linux
```@bors``` try
2024-12-05 23:47:11 +01:00
Guillaume Gomez
5a9c9ef541
Rollup merge of #133821 - Kobzol:replace-black-with-ruff, r=onur-ozkan
Replace black with ruff in `tidy`

`ruff` can both lint and format Python code (in fact, it should be a mostly drop-in replacement for `black` in terms of formatting), so it's not needed to use `black` anymore. This PR removes `black` and replaces it with `ruff`, to get rid of one Python dependency, and also to make Python formatting faster (although that's a small thing).

If we decide to merge this, we'll need to "reformat the world" - `ruff` is not perfectly compatible with `black`, and it also looks like `black` was actually ignoring some files before. I tried it locally (`./x test tidy --extra-checks=py:fmt --bless`) and it also reformatted some code in subtrees (e.g. `clippy` or `rustc_codegen_gcc`) - I'm not sure how to handle that.
2024-12-05 23:47:11 +01:00
Guillaume Gomez
e941e73368
Rollup merge of #133607 - WaffleLapkin:tail-call-checks, r=compiler-errors
implement checks for tail calls

Quoting the [RFC draft](https://github.com/phi-go/rfcs/blob/guaranteed-tco/text/0000-explicit-tail-calls.md):

> The argument to become is a function (or method) call, that exactly matches the function signature and calling convention of the callee. The intent is to ensure a matching ABI. Note that lifetimes may differ as long as they pass borrow checking, see [below](https://github.com/phi-go/rfcs/blob/guaranteed-tco/text/0000-explicit-tail-calls.md#return-type-coercion) for specifics on the return type.

> Tail calling closures and tail calling from closures is not allowed. This is due to the high implementation effort, see below, this restriction can be lifted by a future RFC.

> Invocations of operators were considered as valid targets but were rejected on grounds of being too error-prone. In any case, these can still be called as methods.

> Tail calling [variadic functions](https://doc.rust-lang.org/beta/unstable-book/language-features/c-variadic.html) and tail calling from variadic functions is not allowed. As support for variadic function is stabilized on a per target level, support for tail-calls regarding variadic functions would need to follow a similar approach. To avoid this complexity and to minimize implementation effort for backends, this interaction is currently not allowed but support can be added with a future RFC.

-----

The checks are implemented as a query, similarly to `check_unsafety`.

The code is cherry-picked straight out of #112657 which was written more than a year ago, so I expect we might need to change some things ^^"
2024-12-05 23:47:10 +01:00
Guillaume Gomez
7416c33780
Rollup merge of #133256 - MarcoIeni:use-linux-free-runners, r=Kobzol
CI: use free runners for i686-gnu jobs

try-job: i686-gnu-1
try-job: i686-gnu-2
try-job: i686-gnu-nopt-1
try-job: i686-gnu-nopt-2
2024-12-05 23:47:09 +01:00
Guillaume Gomez
a424813c43
Rollup merge of #132155 - GuillaumeGomez:impl-block-doc, r=rustdoc
Always display first line of impl blocks even when collapsed

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

It the line is too long, only the beginning will be visible:

![Screenshot from 2024-10-25 17-21-41](https://github.com/user-attachments/assets/dd2d912c-ad55-4410-8195-1d66a0a99ad4)

Otherwise, it looks like this:

![image](https://github.com/user-attachments/assets/1f40b9e0-2143-4b9d-a4b0-338a0cd740df)

Can be tested [here](https://rustdoc.crud.net/imperio/impl-block-doc/foo/struct.ImplDoc.html).

r? `@notriddle`
2024-12-05 23:47:07 +01:00
Guillaume Gomez
854ebe7522 Update GUI test after rebase 2024-12-05 22:50:21 +01:00
Guillaume Gomez
90feb9a645 Improve positioning of "..." in collapsed impl block 2024-12-05 22:50:21 +01:00
Guillaume Gomez
448d9adc38 Use text ellipsis instead of bottom blurring 2024-12-05 22:50:21 +01:00
Guillaume Gomez
6e0dabd9e2 Turn markdown_split_summary_and_content into a method of Markdown 2024-12-05 22:50:21 +01:00
Guillaume Gomez
abcd094c51 Update GUI tests 2024-12-05 22:50:21 +01:00
Guillaume Gomez
5d26accecd Add GUI test for impl block doc display 2024-12-05 22:50:21 +01:00
Guillaume Gomez
32e6826a95 Update browser-ui-test version to 0.18.2 2024-12-05 22:50:21 +01:00
Guillaume Gomez
fad5f51183 Always display first line of impl blocks even when collapsed 2024-12-05 22:50:20 +01:00
Strophox
712ceaba35 extend Miri to correctly pass mutable pointers through FFI
Co-authored-by: Ralf Jung <post@ralfj.de>
2024-12-05 22:41:07 +01:00
Chris Krycho
74756c1f45
rustbook: update to use new mdbook-trpl package from The Book 2024-12-05 11:01:42 -07:00
bors
c94848c046 Auto merge of #133905 - jhpratt:rollup-iho8sl1, r=jhpratt
Rollup of 6 pull requests

Successful merges:

 - #127565 (Teach rustc about the Xtensa VaListImpl)
 - #133844 (clarify simd_relaxed_fma non-determinism)
 - #133867 (Fix "std" support status of some tier 3 targets)
 - #133882 (Improve comments for the default backtrace printer)
 - #133888 (Improve bootstrap job objects)
 - #133898 (skip `setup::Hook` on non-git sources)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-12-05 17:54:18 +00:00
Xelph
b781165a4c Improve documentation
Fix missing newlines that rustfmt removed.

fix trailing whitespace

Fix duplicate word.

Reformat panic reasons into a list

remove trailing whitespace 2 electric boogaloo

Change verbe tense.

Integrate suggestions
2024-12-05 10:52:51 -07:00
bjorn3
7e0d1b69fd
Merge pull request #1546 from rust-lang/libcall_abi_fixes
Fix the ABI for libcalls
2024-12-05 16:56:04 +01:00
bjorn3
d8edcd516a Handle abi adjusting in lib_call correctly for s390x 2024-12-05 15:41:05 +00:00
bjorn3
9fd3b18b0b Avoid depending on the unadjusted abi
It is ill defined and for this specific case it may become impossible
to call using Cranelift in the future.
2024-12-05 15:36:03 +00:00
Tim Neumann
8f0ea9a7be Adapt codegen tests for NUW inference 2024-12-05 16:08:41 +01:00
Tim Neumann
9aa4be0499 Normalize target-cpus.rs stdout test for LLVM changes 2024-12-05 15:37:56 +01:00
bjorn3
0974099e30 Revert "Switch to -ffunction-sections by default"
This reverts commit 65c5c7f8cf.

It unfortunately regresses the size of the target dir by a non-trivial
amount. It could be re-enabled again once each subsection doesn't get a
unique name anymore.
2024-12-05 12:43:01 +00:00
bjorn3
92b5873072 Make artifact_size usage closer to what cg_llvm does 2024-12-05 12:09:07 +00:00
bjorn3
65c5c7f8cf Switch to -ffunction-sections by default
With lld the perf difference is within noise while producing slightly
(or in exceptional cases significantly) smaller binaries.
2024-12-05 12:03:58 +00:00
bjorn3
a767a103bb Extract codegen_cgu_content 2024-12-05 11:41:14 +00:00
bjorn3
53e1043e82 Extract emit_allocator_module 2024-12-05 11:38:18 +00:00
bjorn3
1d940adc86 Extract emit_metadata_module 2024-12-05 11:37:19 +00:00
bjorn3
623a6dadfd Move SelfProfilerRef out of CodegenCx 2024-12-05 11:33:03 +00:00
Jacob Pratt
6b58941688
Rollup merge of #133898 - onur-ozkan:ignore-git-hook-on-dist-sources, r=jieyouxu
skip `setup::Hook` on non-git sources

Running `setup::Hook` (with `x setup`) leads tarball sources to panic and this PR resolves that problem by skipping `Hook` step on non-git sources.
2024-12-05 05:50:55 -05:00