Commit graph

306845 commits

Author SHA1 Message Date
bors
1e1a39441b Auto merge of #147198 - matthiaskrgr:rollup-b0ryvvu, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#143069 (Add fast-path for accessing the current thread id)
 - rust-lang/rust#146518 (Improve the documentation around `ZERO_AR_DATE`)
 - rust-lang/rust#146596 (Add a dummy codegen backend)
 - rust-lang/rust#146617 (Don’t suggest foreign `doc(hidden)` types in "the following other types implement trait" diagnostics)
 - rust-lang/rust#146635 (cg_llvm: Stop using `as_c_char_ptr` for coverage-related bindings)
 - rust-lang/rust#147184 (Fix the bevy implied bounds hack for the next solver)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-01 04:46:14 +00:00
Matthias Krüger
598ba1f65f
Rollup merge of #147184 - jdonszelmann:bevy-outlives-bound, r=lcnr
Fix the bevy implied bounds hack for the next solver

The diff is trivial, of course, and basically what you already suggested. Mostly dug around a bunch to learn. I hope this is roughly what you had in mind.

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/236.

r? `@lcnr`
2025-09-30 21:53:35 +02:00
Matthias Krüger
b21c438eb5
Rollup merge of #146635 - Zalathar:llvm-cov, r=SparrowLii
cg_llvm: Stop using `as_c_char_ptr` for coverage-related bindings

[As explained by a note in `ffi.rs`](8a1b39995e/compiler/rustc_codegen_llvm/src/llvm/ffi.rs (L4-L11)), passing strings and byte slices through FFI is more convenient if we take advantage of the fact that `*const c_uchar` and `*const c_char` have the same ABI.

Doing so avoids having to rely on a special helper function, since we can just call `as_ptr` instead.

(The same logic applies to every other binding that currently uses the `as_c_char_ptr` helper; I just haven't adjusted all of them yet.)

---

As a drive-by change, this PR also marks some coverage-related FFI bindings as `safe`.
2025-09-30 21:53:35 +02:00
Matthias Krüger
014e0af149
Rollup merge of #146617 - Jules-Bertholet:E0277-NOFORN, r=SparrowLii
Don’t suggest foreign `doc(hidden)` types in "the following other types implement trait" diagnostics

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

``@rustbot`` label A-diagnostics T-compiler
2025-09-30 21:53:34 +02:00
Matthias Krüger
5a4713d8ea
Rollup merge of #146596 - bjorn3:dummy_backend, r=SparrowLii
Add a dummy codegen backend

This allows building a rustc capable of running the frontend without any backend present. While this may not seem all that useful, it allows running the frontend of rustc to report errors or running miri to interpret a program without any backend present. This is useful when you are trying to say run miri in the browser as upstream LLVM can't be compiled for wasm yet. Or to run rustc itself in miri like I did a while ago and caught some UB.
2025-09-30 21:53:33 +02:00
Matthias Krüger
0d78b1e657
Rollup merge of #146518 - madsmtm:ld-reproducible-doc, r=SparrowLii
Improve the documentation around `ZERO_AR_DATE`

In particular, document why we don't use the new `-reproducible` flag.

I went through [the source for Apple's old linker](https://github.com/apple-oss-distributions/ld64), and compared the versions with [the mapping to Xcode versions on Wikipedia](https://en.wikipedia.org/wiki/Xcode) to find the relevant Xcode versions for these features.

r? compiler
2025-09-30 21:53:33 +02:00
Matthias Krüger
3e621b3dbf
Rollup merge of #143069 - jsimmons:current-thread-id-accessor, r=joshtriplett,tgross35
Add fast-path for accessing the current thread id

Accessing the thread id is often used in profiling and debugging, as well as some approaches for sound single-threaded access to shared data.

Currently the only way to access the thread id is by first obtaining a handle to the current thread. While this is not exactly slow, it does require an atomic inc-ref and dec-ref operation, as well as the injection of `Thread`'s drop code into the caller.

This publicly exposes the existing fast-path for accessing the current thread id.

edit: ACP: https://github.com/rust-lang/libs-team/issues/650
2025-09-30 21:53:32 +02:00
Jana Dönszelmann
80e598bb12
clone region obligations instead of taking in implied bounds hack 2025-09-30 21:48:55 +02:00
bors
fa3155a644 Auto merge of #147197 - matthiaskrgr:rollup-du5e4pv, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#142506 (Add `Path::has_trailing_sep` and related methods)
 - rust-lang/rust#146886 (Add repr(align(2)) to RcInner and ArcInner)
 - rust-lang/rust#147166 (several small `proc_macro` cleanups)
 - rust-lang/rust#147172 (bootstrap: build bootstrap docs with in-tree rustdoc)
 - rust-lang/rust#147181 (cg_llvm: Replace enum `MetadataType` with a list of `MetadataKindId` constants)
 - rust-lang/rust#147187 (remove unnecessary test directives)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-30 19:41:53 +00:00
Josh Simmons
cbaec31c10
Add fast-path for accessing the current thread id
Accessing the thread id is often used in profiling and debugging, as
well as some approaches for sound single-threaded access to data.

Currently the only way to access the thread id is by first obtaining a
handle to the current thread. While this is not exactly slow, it does
require an atomic inc-ref and dec-ref operation, as well as the
injection of `Thread`'s drop code into the caller.

This publicly exposes the existing fast-path for accessing the current
thread id.
2025-09-30 20:51:03 +02:00
Matthias Krüger
561e02cea0
Rollup merge of #147187 - lcnr:rarw, r=lqd
remove unnecessary test directives

that's... odd
2025-09-30 20:46:47 +02:00
Matthias Krüger
6e577e18c6
Rollup merge of #147181 - Zalathar:fixed-metadata, r=petrochenkov
cg_llvm: Replace enum `MetadataType` with a list of `MetadataKindId` constants

The metadata kind ID values declared in `MetadataType` are not part of the LLVM-C API, and are not machine-checked. If a value that we use ever goes out of sync with LLVM, the resulting bugs could be difficult to track down. And the existing values lack any clear indication of what LLVM declarations they correspond to.

On top of that, we currently have another way of expressing metadata kind IDs in the form of `MetadataKindId`, which creates confusing inconsistency in LLVM bindings.

This PR therefore consolidates all usage of “fixed” metadata kind IDs into one list of `MetadataKindId` constants, which is backed by static assertions in our C++ code that match them up with named anonymous-enum variants in `llvm::LLVMContext`.
2025-09-30 20:46:46 +02:00
Matthias Krüger
4cbaa70101
Rollup merge of #147172 - notriddle:tooldoc, r=Kobzol
bootstrap: build bootstrap docs with in-tree rustdoc

All of the docs need to be built with the same rustdoc. Otherwise, any change to the search index breaks everything, because the two rustdocs don't agree on the format.

Fixes https://github.com/rust-lang/rust/issues/147142
2025-09-30 20:46:46 +02:00
Matthias Krüger
622ca20e78
Rollup merge of #147166 - cyrgani:proc-macro-cleanup-1, r=petrochenkov
several small `proc_macro` cleanups
2025-09-30 20:46:45 +02:00
Matthias Krüger
f7c7e34ae4
Rollup merge of #146886 - taiki-e:rc-inner-align, r=Mark-Simulacrum
Add repr(align(2)) to RcInner and ArcInner

`Rc` currently assumes that `RcInner` has at least 2-byte alignment, but on AVR, `usize` has 1-byte alignment (this is because the AVR has 1-byte register sizes, so having 2-byte alignment is generally useless), breaking this assumption.

9f32ccf35f/library/alloc/src/rc.rs (L3005-L3008)

This PR adds `repr(align(2))` to force `RcInner` to always have at least 2-byte alignment.

Note that `ArcInner` doesn't need `repr(align(2))` because atomic types have the alignment same as its size. This PR adds a comment about this.
2025-09-30 20:46:45 +02:00
Matthias Krüger
61b9467af8
Rollup merge of #142506 - clarfonthey:path-trailing-sep, r=joboet
Add `Path::has_trailing_sep` and related methods

Implements rust-lang/libs-team#335.

Tracking issue: rust-lang/rust#142503

Notable differences from ACP:

* `trim_trailing_sep` was added to `Path` since it felt reasonable to ensure that the inverse operation was available.
* Per suggestion of `@kennytm,` added `push_trailing_sep` and `pop_trailing_sep` to `PathBuf` in addition to `set_trailing_sep`.

This also updates some of the docs on various `Path` methods to use the term "trailing separator" instead of "trailing slash" for consistency.
2025-09-30 20:46:44 +02:00
bors
42d009c0a9 Auto merge of #147186 - Zalathar:rollup-sza9wxl, r=Zalathar
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#140916 (Fix unuseful span in type error in some format_args!() invocations)
 - rust-lang/rust#146011 (Point at fn bound that introduced lifetime obligation)
 - rust-lang/rust#146649 (cmse: fix 'region variables should not be hashed')
 - rust-lang/rust#147109 (Rename various "concrete opaque type" things to say "hidden type")
 - rust-lang/rust#147167 (Don't condition RUSTDOC_LIBDIR on `--no-doc`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-30 15:32:50 +00:00
Michael Howell
ba13b6ec6f bootstrap: build bootstrap docs with in-tree rustdoc
All of the docs need to be built with the same rustdoc. Otherwise,
any change to the search index breaks everything, because the two
rustdocs don't agree on the format.
2025-09-30 08:31:08 -07:00
Taiki Endo
9e79fac035 Add repr(align(2)) to RcInner and ArcInner 2025-09-30 22:39:10 +09:00
lcnr
198777a08e remove unnecessary test directives 2025-09-30 15:03:58 +02:00
Jana Dönszelmann
817e181ee8
test bevy compute_implied_bounds hack with new trait solver 2025-09-30 14:37:29 +02:00
Stuart Cook
22643032d4
Rollup merge of #147167 - jyn514:rustdoc-tests, r=Kobzol
Don't condition RUSTDOC_LIBDIR on `--no-doc`

In d94e7ff065, `rustdoc_path` was changed to ignore `want_rustdoc` (which is just whether `--no-doc` was passed). But RUSTDOC_LIBDIR wasn't kept in sync. Rather than trying to keep `rustdoc_path` in sync with `RUSTDOC_LIBDIR`, just pass LIBDIR to the rustc shim unconditionally.

This fix allows calling `ensure(doc::Step)` from a non-doc top-level Step, even if `--no-doc` was present in the command line.
2025-09-30 22:25:17 +10:00
Stuart Cook
156d150381
Rollup merge of #147109 - BoxyUwU:rename_concrete_opaques, r=lcnr
Rename various "concrete opaque type" things to say "hidden type"

r? lcnr

I've found "concrete opaque type" terminology to be somewhat confusing as in conversation and when explaining opaque type stuff to people I always just talk about things in terms of hidden types. Also the hidden types of opaques are very much not *concrete* in the same sense that a type without any generic parameters is concrete which is an unfortunate overlap in terminology.

I've tried to update comments to also stop referring to things as concrete opaque types but this is mostly best effort as it difficult to find all such cases amongst the massive amounts of uses of "concrete" or "hidden" across the whole compiler.
2025-09-30 22:25:17 +10:00
Stuart Cook
5a6ac8c322
Rollup merge of #146649 - folkertdev:cmse-call-erase-regions, r=lcnr
cmse: fix 'region variables should not be hashed'

tracking issue: https://github.com/rust-lang/rust/issues/81391
fixes https://github.com/rust-lang/rust/issues/131639

Some background: the `cmse-nonsecure-call` calling convention is used for a call from "secure" to "non-secure" code. To make sure that "non-secure" cannot read any secrets, restrictions are put on the signatures of functions with this calling convention: they can only use 4 arguments for passing arguments, and one register for passing a result. No arguments are passed via the stack, and all other registers are cleared before the call.

We check during `hir_ty_lowering` that the signature follows these rules. We do that by determining and then inspecting the layout of the type. That works well overall, but can run into asserts when the type itself is ill-formed. This PR fixes one such case.

I believe that the fix here, just erasing the regions, is the right shape, but there may be some nuance that I'm missing.

r? types
2025-09-30 22:25:16 +10:00
Stuart Cook
1aa426b335
Rollup merge of #146011 - estebank:lifetime-obligation-span, r=lcnr
Point at fn bound that introduced lifetime obligation

The last note is new
```
error[E0597]: `c` does not live long enough
  --> $DIR/without-precise-captures-we-are-powerless.rs:19:20
   |
LL | fn simple<'a>(x: &'a i32) {
   |           -- lifetime `'a` defined here
...
LL |     let c = async move || { println!("{}", *x); };
   |         - binding `c` declared here
LL |     outlives::<'a>(c());
   |     ---------------^---
   |     |              |
   |     |              borrowed value does not live long enough
   |     argument requires that `c` is borrowed for `'a`
LL |     outlives::<'a>(call_once(c));
LL | }
   | - `c` dropped here while still borrowed
   |
note: requirement that `c` is borrowed for `'a` introduced here
  --> $DIR/without-precise-captures-we-are-powerless.rs:7:33
   |
LL | fn outlives<'a>(_: impl Sized + 'a) {}
   |                                 ^^
```

When encountering a `ConstraintCategory::Predicate` in a funtion call, point at the `Span` for that `Predicate` to explain where the lifetime obligation originates from.

CC rust-lang/rust#55307.
2025-09-30 22:25:16 +10:00
Stuart Cook
97e2d3c579
Rollup merge of #140916 - moatom:140578, r=chenyukang
Fix unuseful span in type error in some format_args!() invocations

Fixed https://github.com/rust-lang/rust/issues/140578.

r? ``@m-ou-se``
2025-09-30 22:25:15 +10:00
Zalathar
cc6329a9bc Replace MetadataType with the MetadataKindId constants 2025-09-30 20:10:30 +10:00
Zalathar
906bf49ade Declare all "fixed" metadata kinds as MetadataKindId 2025-09-30 20:10:10 +10:00
Zalathar
cd40bbfe29 Move MetadataKindId into its own submodule 2025-09-30 20:07:54 +10:00
Tomoaki Kobayashi
b13b87a1c3 Fix unuseful span in type error in some format_args!() invocations 2025-09-30 17:20:51 +09:00
Tomoaki Kobayashi
0fd6f1113b Add test for unuseful span in type error in some format_args!() invocations 2025-09-30 15:50:30 +09:00
bors
a2db928053 Auto merge of #147143 - estebank:verbose-ret-type, r=fee1-dead
Make replacement suggestion `_` in type verbose

```
error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
  --> $DIR/in-signature.rs:6:21
   |
LL | fn arr_fn() -> [u8; _] {
   |                     ^ not allowed in type signatures
   |
help: replace with the correct return type
   |
LL - fn arr_fn() -> [u8; _] {
LL + fn arr_fn() -> [u8; 3] {
   |
```
2025-09-30 05:48:32 +00:00
bors
c5dc558e6c Auto merge of #147169 - jhpratt:rollup-65ooei8, r=jhpratt
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#145883 (Make macOS dist build configuration match where reasonable)
 - rust-lang/rust#146457 (Skip cleanups on unsupported targets)
 - rust-lang/rust#147152 (builtin `Fn`-trait impls: instantiate binder before the return type `Sized` check)
 - rust-lang/rust#147153 ([rustdoc] Move doc cfg propagation pass before items stripping passes)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-30 02:34:18 +00:00
Jacob Pratt
745b8f6b74
Rollup merge of #147153 - GuillaumeGomez:doc-propagation-before-stripping-items, r=lolbinarycat
[rustdoc] Move doc cfg propagation pass before items stripping passes

Follow-up of https://github.com/rust-lang/rust/pull/138907.

r? lolbinarycat
2025-09-29 21:37:52 -04:00
Jacob Pratt
afd620f548
Rollup merge of #147152 - lcnr:instantiate-pre-sized-check, r=BoxyUwU
builtin `Fn`-trait impls: instantiate binder before the return type `Sized` check

fixes
- https://github.com/rust-lang/trait-system-refactor-initiative/issues/220
- https://github.com/rust-lang/trait-system-refactor-initiative/issues/204

r? `@BoxyUwU`
2025-09-29 21:37:51 -04:00
Jacob Pratt
b310eb91ab
Rollup merge of #146457 - alexcrichton:wasm-no-exn-instructions, r=bjorn3
Skip cleanups on unsupported targets

This commit is an update to the `AbortUnwindingCalls` MIR pass in the compiler. Specifically a new boolean is added for "can this target possibly unwind" and if that's `false` then terminators are all adjusted to be unreachable/not present. The end result is that this fixes rust-lang/rust#140293 for wasm targets.

The motivation for this PR is that currently on WebAssembly targets the usage of the `C-unwind` ABI can lead LLVM to either (a) emit exception-handling instructions or (b) hit a LLVM-ICE-style codegen error. WebAssembly as a base instruction set does not support unwinding at all, and a later proposal to WebAssembly, the exception-handling proposal, was what enabled this. This means that the current intent of WebAssembly targets is that they maintain the baseline of "don't emit exception-handling instructions unless enabled". The commit here is intended to restore this behavior by skipping these instructions even when `C-unwind` is present.

Exception-handling is a relatively tricky and also murky topic in WebAssembly, however. There are two sets of instructions LLVM can emit for WebAssembly exceptions, Rust's Emscripten target supports exceptions, WASI targets do not, the LLVM flags to enable this are not always obvious, and additionally this all touches on "changing exception-handling behavior should be a target-level concern, not a feature". Effectively WebAssembly's exception-handling integration into Rust is not finalized at this time. The best idea at this time is that a parallel set of targets will eventually be added which support exceptions, but it's not clear if/when to do this. In the meantime the goal is to keep existing targets working while still enabling experimentation with exception-handling with `-Zbuild-std` and various permutations of LLVM flags.

To that extent this commit does not blanket disable these landing pads and cleanup routines for WebAssembly but instead checks to see if panic=unwind is enabled or if `+exception-handling` is enabled. Tests are updated here as well to account for this where, by default, using a `C-unwind` ABI won't affect Rust codegen at all. If `+exception-handling` is enabled, however, then Rust codegen will look like native platforms where exceptions are caught and the program aborts. More-or-less I've done my best to keep exceptions working on wasm where it's possible to have them work, but turned them off where they're not supposed to be emitted.

Closes rust-lang/rust#140293
2025-09-29 21:37:50 -04:00
Jacob Pratt
c3e118b4db
Rollup merge of #145883 - shepmaster:unify-macos-ci, r=madsmtm
Make macOS dist build configuration match where reasonable

r? `@madsmtm`
2025-09-29 21:37:50 -04:00
Jynn Nelson
73f6b08022 Don't condition RUSTDOC_LIBDIR on --no-doc
In d94e7ff065, `rustdoc_path` was changed
to ignore `want_rustdoc` (which is just whether `--no-doc` was passed).
But RUSTDOC_LIBDIR wasn't kept in sync. Rather than trying to keep
`rustdoc_path` in sync with `RUSTDOC_LIBDIR`, just pass LIBDIR to the
rustc shim unconditionally.

This fix allows calling `ensure(doc::Step)` from a non-doc top-level
Step, even if `--no-doc` was present in the command line.
2025-09-29 16:02:22 -07:00
bors
29b7717de2 Auto merge of #147162 - matthiaskrgr:rollup-4bv1xzb, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#146937 (std: implement `hostname`)
 - rust-lang/rust#147040 (mbe: macro_check: Fix function comments referencing non-existent parameters)
 - rust-lang/rust#147131 (Use MirPatch in simplify_branches.)
 - rust-lang/rust#147133 (Remove one loop in `extract_cfg_from_attrs`)
 - rust-lang/rust#147150 (Emit allocator attributes for allocator shim)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-29 22:21:32 +00:00
cyrgani
d7773f6b1c explicitly implement !Send and !Sync 2025-09-30 00:09:12 +02:00
cyrgani
23f3400613 remove unused #![feature(stmt_expr_attributes)] 2025-09-30 00:01:17 +02:00
cyrgani
9bb4081fb0 remove reverse_{encode, decode}! 2025-09-29 23:42:01 +02:00
Matthias Krüger
379979951e
Rollup merge of #147150 - nikic:alloc-shim-attributes, r=bjorn3
Emit allocator attributes for allocator shim

This emits the same attributes we place on allocator declarations on the definitions in the allocator shim as well. This complements https://github.com/rust-lang/rust/pull/146766, which added the attribute for `#[global_allocator]` definitions. Emitting the attributes on the definitions ensures that they cannot be lost of the allocator shim participates in LTO.

See https://github.com/rust-lang/rust/issues/145995 for context, though that one was about `#[global_allocator]`. I'm not sure whether this can occur with the allocator shim as well or not, but better safe than sorry.

I'm not sure whether there is any good way to test this, as the allocator shim is not part of `--emit=llvm-ir`. I've verified this locally by inspecting the bitcode produced by `-C save-temps`.

r? ``@bjorn3``
2025-09-29 21:42:44 +02:00
Matthias Krüger
967e64279a
Rollup merge of #147133 - GuillaumeGomez:rm-loop-extract_cfg_from_attrs, r=lolbinarycat
Remove one loop in `extract_cfg_from_attrs`

Follow-up of https://github.com/rust-lang/rust/pull/138907.

r? lolbinarycat
2025-09-29 21:42:43 +02:00
Matthias Krüger
fdb965f3f7
Rollup merge of #147131 - cjgillot:patch-branches, r=davidtwco
Use MirPatch in simplify_branches.

This allows to avoid clearing the CFG cache if we don't perform any change.

r? ``@ghost`` for perf
2025-09-29 21:42:43 +02:00
Matthias Krüger
618942b86f
Rollup merge of #147040 - joshtriplett:mbe-fix-comments, r=petrochenkov
mbe: macro_check: Fix function comments referencing non-existent parameters

Several functions had comments referencing a non-existent `valid`
parameter. Remove those. The `guar` parameter that handles errors is
already documented.

In the process, remove another duplicate reference to an
already-documented parameter (`binders`).
2025-09-29 21:42:42 +02:00
Matthias Krüger
8223831942
Rollup merge of #146937 - joboet:gethostname, r=Mark-Simulacrum
std: implement `hostname`

Resolves https://github.com/rust-lang/libs-team/issues/330
Tracking issue: https://github.com/rust-lang/rust/issues/135142

This is based on rust-lang/rust#135141, but I've reimplemented the UNIX version, which now:
* uses `sysconf(_SC_HOST_NAME_MAX)` as an initial buffer length
* returns `OutOfMemory` if the `Vec` allocation fails
* retries the operation if it detects that the name returned by `gethostname` was truncated

Additionally, as part of the rebase, I had to move some WinSock abstractions (initialisation and error access) to `sys::pal` so that they can be accessed from `sys::net::hostname`.

CC ``@orowith2os`` (and thank you for your work!)
2025-09-29 21:42:41 +02:00
Guillaume Gomez
9119eba24d Add regression test for doc cfg applied on public items inside private items 2025-09-29 18:08:51 +02:00
Guillaume Gomez
06a6dcd4d2 Move doc cfg propagation pass before items stripping passes 2025-09-29 18:08:51 +02:00
bors
dc2c3564d2 Auto merge of #146376 - durin42:dwo-specify-path, r=davidtwco
debuginfo: add an unstable flag to write split DWARF to an explicit directory

Bazel requires knowledge of outputs from actions at analysis time, including file or directory name. In order to work around the lack of predictable output name for dwo files, we group the dwo files in a subdirectory of --out-dir as a post-processing step before returning control to bazel. Unfortunately some debugging workflows rely on directly opening the dwo file rather than loading the merged dwp file, and our trick of moving the files breaks those users. We can't just hardlink the file or copy it, because with remote build execution we wouldn't end up with the un-moved file copied back to the developer's workstation. As a fix, we add this unstable flag that causes dwo files to be written to a build-system-controllable location, which then lets bazel hoover up the dwo files, but the objects also have the correct path for the dwo files.

r? `@davidtwco`
2025-09-29 15:06:55 +00:00