306861 Commits

Author SHA1 Message Date
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
Boxy Uwu
66b664c996 more rename 2025-09-29 16:06:25 +01:00
bjorn3
adf9cbd69c 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-29 14:34:58 +00:00
Jules Bertholet
9f667cdd24
Add overlapping_assoc_constraints param to lower_bounds 2025-09-29 10:34:19 -04:00
lcnr
07806a1132 cleanup try_evaluate_added_goals 2025-09-29 15:28:33 +02:00
lcnr
0f2b79c36d add tests 2025-09-29 15:28:33 +02:00
lcnr
098a56890f Fn-trait goals, eagerly instantiate binder
to avoid overflow from proving `for<'a> opaque<'a>: Sized`
2025-09-29 15:28:33 +02:00
Jake Goulding
5df0be3988 Make macOS dist build configuration match where reasonable 2025-09-29 08:52:09 -04:00
bors
21a13b8864 Auto merge of #147151 - Zalathar:rollup-w81rn0j, r=Zalathar
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#146653 (improve diagnostics for empty attributes)
 - rust-lang/rust#146987 (impl Ord for params and use unstable sort)
 - rust-lang/rust#147101 (Use `Iterator::eq` and (dogfood) `eq_by` in compiler and library )
 - rust-lang/rust#147123 (Fix removed version numbers of `doc_auto_cfg` and `doc_cfg_hide`)
 - rust-lang/rust#147149 (add joboet to library review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-29 11:52:07 +00:00
Guillaume Gomez
2e63708d39 Improve code comments 2025-09-29 13:43:25 +02:00
Stuart Cook
82db672ed5
Rollup merge of #147149 - joboet:rerotating-joboet, r=joboet
add joboet to library review rotation

Reviewing feels like fun again...
2025-09-29 21:06:46 +10:00
Stuart Cook
f2306f3729
Rollup merge of #147123 - DJMcNab:doc_cfg_merge_version, r=fmease
Fix removed version numbers of `doc_auto_cfg` and `doc_cfg_hide`

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

The `doc_auto_cfg` and `doc_cfg_hide` features were removed in a recent nightly (by https://github.com/rust-lang/rust/pull/138907).
I believe that the rustc version numbers at which the features were declared to be removed were incorrect, however, and should both be "1.92" (±1). As evidence in favour of this, the error we get from using this was:

```text
error[E0557]: feature has been removed
  --> src/lib.rs:22:29
   |
22 | #![cfg_attr(docsrs, feature(doc_auto_cfg))]
   |                             ^^^^^^^^^^^^ feature has been removed
   |
   = note: removed in 1.58.0; see <https://github.com/rust-lang/rust/pull/138907> for more information
   = note: merged into `doc_cfg`
```

Note especially the "removed in 1.58" claim. Further evidence is found in the comment further up this file: 4ffeda10e1/compiler/rustc_feature/src/removed.rs (L49-L53)

I've chosen 1.92 as that was the milestone which https://github.com/rust-lang/rust/pull/138907 was added to.

cc `@GuillaumeGomez`
2025-09-29 21:06:46 +10:00
Stuart Cook
08616a1745
Rollup merge of #147101 - yotamofek:pr/iter-eq-and-eq-by, r=jdonszelmann
Use `Iterator::eq` and (dogfood) `eq_by` in compiler and library

Now that rust-lang/rust#137122 has landed, we can replace stuff that looks like:
```rust
let a: &[T];
let b: &[T];
let eq = a.len() == b.len() && a.iter().zip(b).all(|(a,b)| a == b)
```
with the much simpler `a.iter().eq(b)`, without losing the perf benefit of the different-length-fast-path.
Also dogfooded `Iterator::eq_by` (cc rust-lang/rust#64295 ) while I'm at it.

First commit (4d1b6fad230f8a5ccceccc7562eadc4ea50059da) should be very straightforward to review, second one (049a4606cb3906787aedf508ee8eea09c2bb3b9a) is slightly more creative, but IMHO a nice cleanup.
2025-09-29 21:06:45 +10:00
Stuart Cook
acd91e2fe1
Rollup merge of #146987 - hkBst:sort-params-1, r=nnethercote
impl Ord for params and use unstable sort

AFAICT we are only sorting to find duplicates, so unstable sort should work fine, and maybe is a tiny bit faster?
2025-09-29 21:06:45 +10:00
Stuart Cook
cf07cce1fb
Rollup merge of #146653 - jdonszelmann:empty-attr-diags, r=nnethercote
improve diagnostics for empty attributes

Adds a note about them not having any effect. This was previously done for `feature` attributes but no other attributes. In [converting the `feature` parser](https://github.com/rust-lang/rust/pull/146652) I removed that note. This PR adds it back in and makes it so all attributes benefit from it.

Not blocked on rust-lang/rust#146652, either can merge first
2025-09-29 21:06:44 +10:00
Nikita Popov
af8fd78142 Emit allocator attributes for allocator shim
This emits the same attributes we place on allocator declarations
(and allocator definitions using `#[global_allocator]`) on the
definitions in the allocator shim as well, making sure that the
attributes are not lost if the allocator shim participates in LTO.
2025-09-29 11:29:59 +02:00
joboet
9c97ba700e
add joboet to library review rotation 2025-09-29 11:20:40 +02:00
Daniel McNab
04ee991589 Fix removed version of doc_auto_cfg, doc_cfg_hide 2025-09-29 09:45:27 +01:00
bors
128b36a4a4 Auto merge of #147145 - Zalathar:rollup-s7kcs3w, r=Zalathar
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#147100 (tests: Remove ignore-android directive for fixed issue)
 - rust-lang/rust#147116 (compiler: remove AbiAlign inside TargetDataLayout)
 - rust-lang/rust#147134 (remove explicit deref of AbiAlign for most methods)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-29 08:43:49 +00:00
joboet
97333f8c9a
std: implement hostname 2025-09-29 10:24:54 +02:00
Stuart Cook
cd6f32a4eb
Rollup merge of #147134 - workingjubilee:remove-explicit-abialign-deref, r=Zalathar
remove explicit deref of AbiAlign for most methods

Much of the compiler calls functions on Align projected from AbiAlign. AbiAlign impls Deref to its inner Align, so we can simplify these away. Also, it will minimize disruption when AbiAlign is removed.

For now, preserve usages that might resolve to PartialOrd or PartialEq, as those have odd inference.
2025-09-29 15:44:55 +10:00
Stuart Cook
6c40c16d83
Rollup merge of #147116 - workingjubilee:remove-tdl-abialign, r=Zalathar
compiler: remove AbiAlign inside TargetDataLayout

AbiAlign is a thin wrapper around Align, extant mostly because we used to track a separate quasi-notion of alignment that was never a real notion of alignment and removing all of it at once was too churny. This PR maintains AbiAlign usage in public API and most of the compiler, but direct access of these fields for TargetDataLayout is now in terms of Align only.
2025-09-29 15:44:54 +10:00
Stuart Cook
d9e3e192ff
Rollup merge of #147100 - Enselic:ignore-less, r=jieyouxu
tests: Remove ignore-android directive for fixed issue

rust-lang/rust#120567 is marked as fixed, so let's see if we can remove the ignore directives tied to that issue.

<!-- Note to self: wait for https://github.com/rust-lang/team/pull/2002 -->

try-job: arm-android
2025-09-29 15:44:54 +10:00
bors
7af913fc90 Auto merge of #147140 - Zalathar:rollup-rtnqek7, r=Zalathar
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#133477 (Detect tuple structs that are unconstructable due to re-export)
 - rust-lang/rust#146929 (compiletest: Remove old-output-capture and become a stage0 bootstrap tool)
 - rust-lang/rust#146979 (constify Default on Nanoseconds)
 - rust-lang/rust#147092 (Do not compute optimized MIR if code does not type-check.)
 - rust-lang/rust#147112 (all 48 keywords in just 300 characters)
 - rust-lang/rust#147122 (Fix some crash-test directives)
 - rust-lang/rust#147127 (Add a leading dash to linker plugin arguments in the gcc codegen)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-29 05:37:18 +00:00
Yotam Ofek
68a7c25078 Use Iterator::eq and (dogfood) eq_by in compiler and library 2025-09-29 08:08:05 +03:00
Esteban Küber
eceb48534a 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-29 03:28:52 +00:00
Stuart Cook
af8af6cc6a
Rollup merge of #147127 - antoyo:fix/gcc-linker-plugin, r=bjorn3
Add a leading dash to linker plugin arguments in the gcc codegen

Fix rust-lang/rust#130583

r? ``@bjorn3``
2025-09-29 11:56:44 +10:00
Stuart Cook
1ef1d3bc28
Rollup merge of #147122 - Zalathar:crash-directives, r=cjgillot
Fix some crash-test directives

- 120175 fails to crash for non-ELF targets; presumably this wasn't noticed because the CI jobs don't enable rustc assertions for non-ELF hosts.
- 34127, 125722, and 131292 have `only-x86_64`, which is overly specific.
  - Unnecessary x86 directives cause friction for contributors using aarch64, especially now that many PR CI jobs also use aarch64.

r? ghost
2025-09-29 11:56:44 +10:00
Stuart Cook
f74aa5aa6f
Rollup merge of #147112 - nik-contrib:keyword-soup, r=jieyouxu
all 48 keywords in just 300 characters

new test case in, all 48 keywords in just 300 characters

https://doc.rust-lang.org/reference/keywords.html
2025-09-29 11:56:43 +10:00
Stuart Cook
01b172ef33
Rollup merge of #147092 - cjgillot:late-validate-mir, r=compiler-errors
Do not compute optimized MIR if code does not type-check.

Since https://github.com/rust-lang/rust/pull/128612, we compute optimized MIR when `-Zvalidate-mir` is present.

This is done as part of required analyses, even if type-checking fails. This causes ICEs, as most of the mir-opt pipeline expects well-formed code.

Fixes rust-lang/rust#129095
Fixes rust-lang/rust#134174
Fixes rust-lang/rust#134654
Fixes rust-lang/rust#135570
Fixes rust-lang/rust#136381
Fixes rust-lang/rust#137468
Fixes rust-lang/rust#144491
Fixes rust-lang/rust#147011

This does not fix issue rust-lang/rust#137190, as it ICEs without `-Zvalidate-mir`.

r? ``@compiler-errors``
2025-09-29 11:56:42 +10:00
Stuart Cook
5373eb1268
Rollup merge of #146979 - npmccallum:nanosecs, r=Mark-Simulacrum
constify Default on Nanoseconds
2025-09-29 11:56:42 +10:00
Stuart Cook
3ea1bab982
Rollup merge of #146929 - Zalathar:capture, r=Kobzol,jieyouxu
compiletest: Remove old-output-capture and become a stage0 bootstrap tool

The new compiletest output-capture system became the default in rust-lang/rust#146574, and no problems have been reported since.

This PR therefore removes the old output-capture implementation from compiletest, and adjusts bootstrap to always build and test compiletest as a stage0 bootstrap tool.

In other words, compiletest no longer relies on any unstable features (such as `libtest` or `internal_output_capture`), and is now written entirely in stable Rust!

The compiletest self-tests still need access to an in-tree rustc, in order to obtain information via `rustc --print`, so we interpret `--stage` as indicating the stage of that secondary compiler, but always use the stage0 compiler to build compiletest itself.

r? Kobzol
2025-09-29 11:56:41 +10:00
Stuart Cook
e7760fa499
Rollup merge of #133477 - estebank:issue-133343, r=davidtwco
Detect tuple structs that are unconstructable due to re-export

When a tuple-struct is re-exported that has inaccessible fields at the `use` scope, the type's constructor cannot be accessed through that re-export. We now account for this case and extend the resulting resolution error. We also check if the constructor would be accessible directly, not through the re-export, and if so, we suggest using the full path instead.

```
error[E0423]: cannot initialize a tuple struct which contains private fields
  --> $DIR/ctor-not-accessible-due-to-inaccessible-field-in-reexport.rs:12:33
   |
LL |             let crate::Foo(x) = crate::Foo(42);
   |                                 ^^^^^^^^^^
   |
note: the type is accessed through this re-export, but the type's constructor is not visible in this import's scope due to private fields
  --> $DIR/ctor-not-accessible-due-to-inaccessible-field-in-reexport.rs:3:9
   |
LL | pub use my_mod::Foo;
   |         ^^^^^^^^^^^
help: the type can be constructed directly, because its fields are available from the current scope
   |
LL |             let crate::Foo(x) = crate::my_mod::Foo(42);
   |                                 ~~~~~~~~~~~~~~~~~~
```

Fix #133343.
2025-09-29 11:56:41 +10:00
bors
772f380092 Auto merge of #147090 - Noratrieb:immediate-abort-stack-overflow, r=joboet
Skip stack overflow handler for panic=immediate-abort

std installs guard pages and a signal handler to ensure that stackoverflows 1) terminate abruptly and 2) print an nice message. Even for panic=immediate-abort, 1) is desirable, we don't want silent data corruption there. But 2) is completely unnecessary, as users deliberately *don't* want nice messages, they want minimum binary size.

Therefore, skip the entire guard signal handler setup, which saves a lot of bytes.

I tested this with a hello world binary using fat LTO, build-std, panic=immediate-abort, opt-level=s, strip=debuginfo.

`size` reports significant savings:

```
   text	   data	    bss	    dec	    hex	filename
  15252	   1032	    104	  16388	   4004	tiny-before
   6881	    964	     48	   7893	   1ed5	tiny-after2
```

`nm -U` goes from 71 to 56, getting rid of a bunch of stack overflow related symbols. The disk size goes from `31k` to `24k`.

The impact on the error message is minimal, as the message was already
missing.

before:
```
fish: Job 1, './tiny-so-before' terminated by signal SIGABRT (Abort)
```

after:
```
fish: Job 1, './tiny-so-after' terminated by signal SIGSEGV (Address boundary error)
```

I didn't test the Windows part, but it likely also has savings.
2025-09-29 01:32:14 +00:00
Zalathar
b71c469040 Fix some crash-test directives 2025-09-29 11:04:50 +10:00
Jubilee Young
0c9d0dfe04 remove explicit deref of AbiAlign for most methods
Much of the compiler calls functions on Align projected from AbiAlign.
AbiAlign impls Deref to its inner Align, so we can simplify these away.
Also, it will minimize disruption when AbiAlign is removed.

For now, preserve usages that might resolve to PartialOrd or PartialEq,
as those have odd inference.
2025-09-28 15:02:14 -07:00
bors
f957826bff Auto merge of #146513 - madsmtm:apple-reenable-assertions, r=Mark-Simulacrum
Re-enable assertions on macOS alt builds

These were previously disabled, in part for performance reasons, in part due to needing availability symbols `__isPlatformVersionAtLeast` and `__isOSVersionAtLeast` that `compiler-builtins` did not provide, see https://github.com/rust-lang/rust/pull/62592#issuecomment-510670657 and https://github.com/rust-lang/rust/pull/134275#issuecomment-2543067830 for failed checks.

Since https://github.com/rust-lang/rust/pull/138944 though, `std` now provides these symbols, so we should be able to re-enable LLVM assertions, debug assertions and overflow checks.

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

try-job: `*apple*`
2025-09-28 21:40:04 +00:00
Esteban Küber
8f7d61b9ef Detect unconstructable re-exported tuple structs
When a tuple-struct is re-exported that has inaccessible fields at the `use` scope, the type's constructor cannot be accessed through that re-export. We now account for this case and extend the resulting resolution error. We also check if the constructor would be accessible directly, not through the re-export, and if so, we suggest using the full path instead.

```
error[E0423]: cannot initialize a tuple struct which contains private fields
  --> $DIR/ctor-not-accessible-due-to-inaccessible-field-in-reexport.rs:12:33
   |
LL |             let crate::Foo(x) = crate::Foo(42);
   |                                 ^^^^^^^^^^
   |
note: the type is accessed through this re-export, but the type's constructor is not visible in this import's scope due to private fields
  --> $DIR/ctor-not-accessible-due-to-inaccessible-field-in-reexport.rs:3:9
   |
LL | pub use my_mod::Foo;
   |         ^^^^^^^^^^^
help: the type can be constructed directly, because its fields are available from the current scope
   |
LL |             let crate::Foo(x) = crate::my_mod::Foo(42);
   |                                 ~~~~~~~~~~~~~~~~~~
```

Fix #133343.
2025-09-28 21:33:34 +00:00
Esteban Küber
c5313fed76 Point at multiple outlives requirements instead of just the first one
```
error[E0716]: temporary value dropped while borrowed
  --> $DIR/multiple-sources-for-outlives-requirement.rs:5:38
   |
LL | fn foo<'b>() {
   |        -- lifetime `'b` defined here
LL |     outlives_indir::<'_, 'b, _>(&mut 1u32);
   |     ---------------------------------^^^^-- temporary value is freed at the end of this statement
   |     |                                |
   |     |                                creates a temporary value which is freed while still in use
   |     argument requires that borrow lasts for `'b`
   |
note: requirements that the value outlives `'b` introduced here
  --> $DIR/multiple-sources-for-outlives-requirement.rs:1:23
   |
LL | fn outlives_indir<'a: 'b, 'b, T: 'a>(_x: T) {}
   |                       ^^         ^^
```
2025-09-28 21:13:53 +00:00