Commit Graph

47073 Commits

Author SHA1 Message Date
bors
cf423712b9 Auto merge of #140872 - bjorn3:elf_use_used_linker, r=nikic
Make #[used(linker)] the default on ELF too

`#[used]` currently is an alias for `#[used(linker)]` on all platforms except ELF based ones where it is an alias for `#[used(compiler)]`. The latter has surprising behavior and the LLVM LangRef explicitly states that it "should only be used in rare circumstances, and should not be exposed to source languages." [^2]

The reason `#[used]` still was an alias to `#[used(compiler)]` on ELF is because the gold linker has issues with it. Luckily gold has been deprecated with GCC 15 [^1] and seems to be unable to bootstrap rustc anyway [^3]. As such we shouldn't really care about supporting gold.

This would also allow re-enabling start-stop-gc with lld.

cc https://github.com/rust-lang/rust/issues/93798
Likely fixes https://github.com/rust-lang/rust/issues/85045

[^1]: https://lists.gnu.org/archive/html/info-gnu/2025-02/msg00001.html
[^2]: https://llvm.org/docs/LangRef.html#the-llvm-compiler-used-global-variable
[^3]: https://github.com/rust-lang/rust/issues/139425
2025-06-05 22:52:17 +00:00
bors
ccf3198de3 Auto merge of #138677 - shepmaster:consistent-elided-lifetime-syntax, r=traviscross,jieyouxu
Add a new `mismatched-lifetime-syntaxes` lint

The lang-team [discussed this](https://hackmd.io/nf4ZUYd7Rp6rq-1svJZSaQ) and I attempted to [summarize](https://github.com/rust-lang/rust/pull/120808#issuecomment-2701863833) their decision. The summary-of-the-summary is:

- Using two different kinds of syntax for elided lifetimes is confusing. In rare cases, it may even [lead to unsound code](https://github.com/rust-lang/rust/issues/48686)! Some examples:

    ```rust
    // Lint will warn about these
    fn(v: ContainsLifetime) -> ContainsLifetime<'_>;
    fn(&'static u8) -> &u8;
    ```

- Matching up references with no lifetime syntax, references with anonymous lifetime syntax, and paths with anonymous lifetime syntax is an exception to the simplest possible rule:

    ```rust
    // Lint will not warn about these
    fn(&u8) -> &'_ u8;
    fn(&'_ u8) -> &u8;
    fn(&u8) -> ContainsLifetime<'_>;
    ```

- Having a lint for consistent syntax of elided lifetimes will make the [future goal](https://github.com/rust-lang/rust/issues/91639) of warning-by-default for paths participating in elision much simpler.

---

This new lint attempts to accomplish the goal of enforcing consistent syntax. In the process, it supersedes and replaces the existing `elided-named-lifetimes` lint, which means it starts out life as warn-by-default.
2025-06-05 19:49:30 +00:00
Matthias Krüger
e80eadafa5
Rollup merge of #142032 - matthewjasper:frontmatter-lexing, r=fee1-dead
Fix parsing of frontmatters with inner hyphens

closes rust-lang/rust#141483

r? fee1-dead
2025-06-05 16:02:04 +02:00
Matthias Krüger
0820dd0bc2
Rollup merge of #142015 - oli-obk:wrong-instance, r=RalfJung
Report the actual item that evaluation failed for

instead of id of the last frame in the evaluation stack

r? ``@RalfJung``

fixes rust-lang/rust#142010
2025-06-05 16:02:03 +02:00
bjorn3
f8e9778eb1 Make #[used(linker)] the default on ELF too
#[used] currently is an alias for #[used(linker)] on all platforms
except ELF based ones where it is an alias for #[used(compiler)]. The
latter has surprising behavior and the LLVM LangRef explicitly states
that it "should only be used in rare circumstances, and should not be
exposed to source languages."

The reason #[used] still was an alias to #[used(compiler)] on ELF is
because the gold linker has issues with it. Luckily gold has been
deprecated with GCC 15 and seems to be unable to bootstrap rustc anyway.
As such we shouldn't really care about supporting gold.
2025-06-05 11:35:15 +00:00
bors
c360e219f5 Auto merge of #135054 - cramertj:file-cstr, r=m-ou-se
Add Location::file_with_nul

This is useful for C/C++ APIs which expect the const char* returned from __FILE__ or std::source_location::file_name.

ACP: https://github.com/rust-lang/libs-team/issues/466
Tracking issue: https://github.com/rust-lang/rust/issues/141727
2025-06-05 10:21:20 +00:00
bors
425e142686 Auto merge of #140466 - amandasystems:move-to-preprocessing-step, r=lcnr
Move placeholder handling to a proper preprocessing step

This commit breaks out the logic of placheolder rewriting into its own preprocessing step. It's one of the more boring
parts of #130227.

The only functional change from this is that the preprocessing step (where extra `r: 'static` constraints are added) is performed upstream of Polonius legacy, finally affecting Polonius. That is mostly a by-product, though.

This should be reviewable by anyone in the compiler team, so
r? rust-lang/compiler
2025-06-05 05:27:41 +00:00
bors
81a964c23e Auto merge of #142033 - matthiaskrgr:rollup-99lvg0j, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#141890 (Add link to correct documentation in htmldocck.py)
 - rust-lang/rust#141932 (Fix for async drop inside async gen fn)
 - rust-lang/rust#141960 (Use non-2015 edition paths in tests that do not test for their resolution)
 - rust-lang/rust#141968 (Run wfcheck in one big loop instead of per module)
 - rust-lang/rust#141969 (Triagebot: Remove `assign.users_on_vacation`)
 - rust-lang/rust#141985 (Ensure query keys are printed with reduced queries)
 - rust-lang/rust#141999 (Visit the ident in `PreciseCapturingNonLifetimeArg`.)
 - rust-lang/rust#142005 (Change `tag_field` to `FieldIdx` in `Variants::Multiple`)
 - rust-lang/rust#142017 (Fix incorrect use of "recommend" over "recommended")
 - rust-lang/rust#142024 (Don't refer to 'this tail expression' in expansion.)
 - rust-lang/rust#142025 (Don't refer to 'local binding' in extern macro.)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-05 00:30:08 +00:00
bors
ff223d35cd Auto merge of #141309 - RalfJung:x86-simd-abi, r=tgross35,nikic,workingjubilee
x86 (32/64): go back to passing SIMD vectors by-ptr

Fixes https://github.com/rust-lang/rust/issues/139029 by partially reverting https://github.com/rust-lang/rust/pull/135408 and going back to passing SIMD vectors by-ptr on x86. Sadly, by-val confuses the LLVM inliner so much that it's not worth it...

Also fixes https://github.com/rust-lang/rust/issues/141848 by no longer actually using vector registers with the "Rust" ABI.

r? `@tgross35`
Cc `@nikic`

try-job: `test-various*`
try-job: dist-i586-gnu-i586-i686-musl
try-job: x86_64-gnu-nopt
try-job: `x86_64-msvc*`
try-job: `i686-msvc*`
2025-06-04 21:05:52 +00:00
Matthias Krüger
4959ee314d
Rollup merge of #142025 - m-ou-se:which-local-binding, r=jdonszelmann
Don't refer to 'local binding' in extern macro.

When it comes from a macro expansion, the user has no clue what 'local binding' the compiler is talking about, if they don't know the expansion of the macro. Better to just say 'temporary value'.
2025-06-04 19:50:27 +02:00
Matthias Krüger
e0815883cf
Rollup merge of #142024 - m-ou-se:what-tail-expression, r=petrochenkov
Don't refer to 'this tail expression' in expansion.

The user has no clue what the compiler is talking about when it says "this tail expression". It is an implementation detail of the macro that it uses a block with tail expression.
2025-06-04 19:50:27 +02:00
Matthias Krüger
98da8e60eb
Rollup merge of #142005 - scottmcm:fieldidx-in-variantsmultiple, r=workingjubilee
Change `tag_field` to `FieldIdx` in `Variants::Multiple`

It was already available as a generic parameter anyway, and it's not like we'll ever put a tag in the 5-billionth field.

This is a first part of pulling smaller pieces out of rust-lang/rust#138759, so
r? workingjubilee
2025-06-04 19:50:26 +02:00
Matthias Krüger
87969ff151
Rollup merge of #141999 - nnethercote:precise-ident, r=compiler-errors
Visit the ident in `PreciseCapturingNonLifetimeArg`.

It's currently skipped, presumably by accident.

r? `@BoxyUwU`
2025-06-04 19:50:25 +02:00
Matthias Krüger
23ba088502
Rollup merge of #141985 - compiler-errors:cycle-in-dep-graph-print, r=oli-obk
Ensure query keys are printed with reduced queries

Using `-Z query-dep-graph` and debug assertions leads to an ICE that was originally discovered in rust-lang/rust#141700:

> This isn't an incremental bug per se, but instead a bug that has to do with debug printing query keys when debug assertions and `-Z query-dep-graph` is enabled. We end up printing a const (b/c we're using generic const args here) whose debug printing for -Z query-dep-graph requires invoking the same query cyclically 😃
>
> I've pushed a commit which should fix this.

This isn't related to the standard library changes, but instead b/c it seems to be the first usage of `feature(adt_const_params)` in the standard library that ends up being triggered in incremental tests.

r? oli-obk
2025-06-04 19:50:24 +02:00
Matthias Krüger
8492c14170
Rollup merge of #141968 - oli-obk:wfck-everything-at-once, r=wesleywiser
Run wfcheck in one big loop instead of per module

Maybe we can merge this big loop in the future with the `par_hir_body_owners` call below and run typeck only on items that didn't fail wfcheck. For now let's just see if perf likes it, as it by itself should be beneficial to parallel rustc
2025-06-04 19:50:22 +02:00
Matthias Krüger
9ec41bcf72
Rollup merge of #141932 - azhogin:azhogin/async-drop-inside-asyncgen-fix, r=oli-obk
Fix for async drop inside async gen fn

Return value (for yield) is corrected for async drop inside async gen function.
In CFG, when internal async drop future is polled and returned `Poll<()>::Pending`, then async gen resume function returns `Poll<(OptRet)>::Pending`.

Fixes rust-lang/rust#140530
2025-06-04 19:50:21 +02:00
Taylor Cramer
b541f93372 Add Location::file_with_nul
This is useful for C/C++ APIs which expect the const char* returned
from __FILE__ or std::source_location::file_name.
2025-06-04 09:23:05 -07:00
Matthew Jasper
55f59fb0e3 Fix parsing of frontmatters with inner hyphens 2025-06-04 15:51:36 +00:00
Oli Scherer
64172481da Report the actual item that evaluation failed for 2025-06-04 15:13:25 +00:00
Jake Goulding
d35ad94849 Replace elided_named_lifetimes with mismatched_lifetime_syntaxes 2025-06-04 10:40:04 -04:00
Jake Goulding
9a50cb4a0c Introduce the mismatched_lifetime_syntaxes lint 2025-06-04 10:40:04 -04:00
Matthias Krüger
a06160d9a8
Rollup merge of #142007 - nnethercote:visitor-comments, r=chenyukang
Improve some `Visitor` comments.

For AST/HIR/THIR visitors, explain the use of deconstruction.

r? ``@BoxyUwU``
2025-06-04 16:24:12 +02:00
Matthias Krüger
0736a03a78
Rollup merge of #141570 - chenyukang:yukang-fix-eq_unspanned, r=workingjubilee
Fix incorrect eq_unspanned in TokenStream

Fixes rust-lang/rust#141522

r? ``@workingjubilee``

should we remove this function?
since it's used in several places, i'd prefer to keep it.
2025-06-04 16:24:07 +02:00
Matthias Krüger
c1e8fe760b
Rollup merge of #141271 - nnethercote:attr-streamline, r=jdonszelmann
Streamline some attr parsing APIs

r? ``@jdonszelmann``
2025-06-04 16:24:06 +02:00
Mara Bos
da2e33b406 Don't refer to 'this tail expression' in expansion.
The user has no clue what tail expression the compiler is talking
about: it is an implementation detail of the macro that it uses a block
with tail expression.
2025-06-04 15:42:58 +02:00
Mara Bos
fcfa9b0ba0 Don't refer to 'local binding' in extern macro.
The user has no clue what 'local binding' the compiler is talking about,
if they don't know the expansion of the macro.
2025-06-04 15:07:47 +02:00
Andrew Zhogin
d5a9a00518 Fix for async drop inside async gen fn 2025-06-04 18:45:34 +07:00
Amanda Stjerna
f455c4fc39 Use an enum for SCC representatives, plus other code review
Co-authored-by: lcnr <rust@lcnr.de>
2025-06-04 13:26:08 +02:00
bors
61413aea93 Auto merge of #142003 - matthiaskrgr:rollup-ad8l9ns, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#136687 (Improve the documentation of `Display` and `FromStr`, and their interactions)
 - rust-lang/rust#137306 (Remove `i128` and `u128` from `improper_ctypes_definitions`)
 - rust-lang/rust#138699 (build dist for x86_64-pc-solaris and sparcv9-sun-solaris)
 - rust-lang/rust#141250 (add s390x z17 target features)
 - rust-lang/rust#141467 (make `OsString::new` and `PathBuf::new` unstably const)
 - rust-lang/rust#141871 (index: add method for checking range on DenseBitSet)
 - rust-lang/rust#141888 (Use non-2015 edition paths in tests that do not test for their resolution)
 - rust-lang/rust#142000 (bootstrap: don't symlink source dir into stage0 sysroot)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-04 08:17:06 +00:00
Scott McMurray
ee9901e65c Change tag_field to FieldIdx in Variants::Multiple
It was already available as a generic parameter anyway, and it's not like we'll ever put a tag in the 5-billionth field.
2025-06-03 23:42:21 -07:00
Nicholas Nethercote
ed300d8ad8 Improve some Visitor comments.
For AST/HIR/THIR visitors, explain the use of deconstruction.
2025-06-04 16:40:00 +10:00
Ralf Jung
f01bbfc5e7 abi_check: tweak some comments 2025-06-04 08:38:50 +02:00
Ralf Jung
321db85fb4 x86 (32/64): go back to passing SIMD vectors by-ptr 2025-06-04 08:38:49 +02:00
Matthias Krüger
e63e53a3f6
Rollup merge of #141871 - nia-e:fix-bitset, r=eholk
index: add method for checking range on DenseBitSet

Micro-optimisation that Miri benefits from with the new isolated allocator for native-libs mode. Also possibly just a useful method to have on `DenseBitSet`
2025-06-04 07:54:34 +02:00
Matthias Krüger
59bdb5c3cf
Rollup merge of #141250 - folkertdev:s390x-z17-target-features, r=workingjubilee
add s390x z17 target features

tracking issue: https://github.com/rust-lang/rust/issues/130869

earlier target features were added in https://github.com/rust-lang/rust/pull/135630, and https://github.com/rust-lang/rust/issues/135413#issuecomment-2886439455 has some extra context on these new features.

r? ``@ghost``
cc ``@uweigand``
2025-06-04 07:54:33 +02:00
Matthias Krüger
c5efc6aada
Rollup merge of #137306 - tgross35:remove-i128-u128-improper-ctypes, r=traviscross,workingjubilee
Remove `i128` and `u128` from `improper_ctypes_definitions`

Rust's 128-bit integers have historically been incompatible with C [1]. However, there have been a number of changes in Rust and LLVM that mean this is no longer the case:

* Incorrect alignment of `i128` on x86 [1]: adjusting Rust's alignment proposed at https://github.com/rust-lang/compiler-team/issues/683, implemented at https://github.com/rust-lang/rust/pull/116672.
* LLVM version of the above: resolved in LLVM, including ABI fix. Present in LLVM18 (our minimum supported version).
* Incorrect alignment of `i128` on 64-bit PowerPC, SPARC, and MIPS [2]: Rust's data layouts adjusted at https://github.com/rust-lang/rust/pull/132422, https://github.com/rust-lang/rust/pull/132741, https://github.com/rust-lang/rust/pull/134115.
* LLVM version of the above: done in LLVM 20 https://github.com/llvm/llvm-project/issues/102783.
* Incorrect return convention of `i128` on Windows: adjusted to match GCC and Clang at https://github.com/rust-lang/rust/pull/134290.

At https://github.com/rust-lang/lang-team/issues/255#issuecomment-2088855084, the lang team considered it acceptable to remove `i128` from `improper_ctypes_definitions` if the LLVM version is known to be compatible. Time has elapsed since then and we have dropped support for LLVM versions that do not have the x86 fixes, meaning a per-llvm-version lint should no longer be necessary. The PowerPC, SPARC, and MIPS changes only came in LLVM 20 but since Rust's datalayouts have also been updated to match, we will be using the correct alignment regardless of LLVM version.

`repr(i128)` was added to this lint in https://github.com/rust-lang/rust/pull/138282, but is also removed here.

Part of the decision is that `i128` should match `__int128` in C on platforms that provide it, which documentation is updated to indicate. We will not guarantee that `i128` matches `_BitInt(128)` since that can be different from `__int128`. Some platforms (usually 32-bit) do not provide `__int128`; if any ABIs are extended in the future to define it, we will need to make sure that our ABI matches.

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

[1]: https://github.com/rust-lang/rust/issues/54341
[2]: https://github.com/rust-lang/rust/issues/128950
2025-06-04 07:54:31 +02:00
bors
d9a7393638 Auto merge of #141652 - compiler-errors:more-collect-and-apply, r=lqd
Rework `collect_and_apply` to not rely on size hint for optimization

I saw that we have quite a few `collect_and_apply` calls for N=3-7 (N=7 corresponding to cumulative 99% of nalgebra's calls). Didn't perf locally, but also this is super low-pri, so let's see what rust-timer says.
2025-06-04 04:52:58 +00:00
Nicholas Nethercote
f9c2a454fd Visit the ident in PreciseCapturingNonLifetimeArg.
It's currently skipped, presumably by accident.
2025-06-04 12:33:49 +10:00
bors
792fc2b033 Auto merge of #141984 - matthiaskrgr:rollup-wy6j9ca, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#137725 (Add `iter` macro)
 - rust-lang/rust#141455 (std: abort the process on failure to allocate a TLS key)
 - rust-lang/rust#141569 (Replace ad-hoc ABI "adjustments" with an `AbiMap` to `CanonAbi`)
 - rust-lang/rust#141698 (Use the informative error as the main const eval error message)
 - rust-lang/rust#141925 (Remove bootstrap cfgs from library/)
 - rust-lang/rust#141943 (Remove pre-expansion AST stats.)
 - rust-lang/rust#141945 (Remove `Path::is_ident`.)
 - rust-lang/rust#141957 (Add missing `dyn` keywords to tests that do not test for them Part 2)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-03 23:15:53 +00:00
Nia Espera
a0c19ee577
index: add method for checking range on DenseBitSet 2025-06-04 00:47:12 +02:00
Michael Goulet
cbb3a847d2 Ensure query keys are printed with reduced queries 2025-06-03 20:56:52 +00:00
Matthias Krüger
96531418f8
Rollup merge of #141945 - nnethercote:rm-Path-is_ident, r=compiler-errors
Remove `Path::is_ident`.

It checks that a path has a single segment that matches the given symbol, and that there are zero generic arguments. It has a single use.

We also have `impl PartialEq<Symbol> for Path` which does exactly the same thing *except* it doesn't check for zero generic arguments, which seems like an oversight. It has numerous uses.

This commit removes `Path::is_ident`, adds a test for zero generic arguments to `PartialEq<Symbol> for Path`, and changes the single use of `is_ident` to instead use `==`.

r? `@wesleywiser`
2025-06-03 21:53:38 +02:00
Matthias Krüger
b7150d4e63
Rollup merge of #141943 - nnethercote:rm-pre-expansion-ast-stats, r=compiler-errors
Remove pre-expansion AST stats.

They're very little value, because they only measure the top-level `main.rs` or `lib.rs` file. (Other `.rs` files don't get read and parsed until expansion occurs.)

I saw an example recently where the pre-expansion AST was 3KB in size and the post-expansion AST was 66MB.

I kept the "POST EXPANSION" in the output header, I think that's useful information to avoid possible confusion about when the measurement happens.

r? `@davidtwco`
2025-06-03 21:53:38 +02:00
Matthias Krüger
f574c0edb5
Rollup merge of #141698 - oli-obk:ctfe-err-flip, r=RalfJung
Use the informative error as the main const eval error message

r? `@RalfJung`

I only did the minimal changes necessary to the const eval error machinery. I'd prefer not to mix test changes with refactorings 😆
2025-06-03 21:53:37 +02:00
Matthias Krüger
644f06ec1f
Rollup merge of #141569 - workingjubilee:canonicalize-abi, r=bjorn3
Replace ad-hoc ABI "adjustments" with an `AbiMap` to `CanonAbi`

Our `conv_from_spec_abi`, `adjust_abi`, and `is_abi_supported` combine to give us a very confusing way of reasoning about what _actual_ calling convention we want to lower our code to and whether we want to compile the resulting code at all. Instead of leaving this code as a miniature adventure game in which someone tries to combine stateful mutations into a Rube Goldberg machine that will let them escape the maze and arrive at the promised land of codegen, we let `AbiMap` devour this complexity. Once you have an `AbiMap`, you can answer which `ExternAbi`s will lower to what `CanonAbi`s (and whether they will lower at all).

Removed:
- `conv_from_spec_abi` replaced by `AbiMap::canonize_abi`
- `adjust_abi` replaced by same
- `Conv::PreserveAll` as unused
- `Conv::Cold` as unused
- `enum Conv` replaced by `enum CanonAbi`

target-spec.json changes:
- If you have a target-spec.json then now your "entry-abi" key will be specified in terms of one of the `"{abi}"` strings Rust recognizes, e.g.
```json
    "entry-abi": "C",
    "entry-abi": "win64",
    "entry-abi": "aapcs",
```
2025-06-03 21:53:36 +02:00
Matthias Krüger
27a894f86f
Rollup merge of #137725 - oli-obk:i-want-to-move-it-move-it, r=compiler-errors,traviscross
Add `iter` macro

See related discussion in https://rust-lang.zulipchat.com/#narrow/channel/481571-t-lang.2Fgen/topic/iter!.20macro/near/500784563

very little error case testing so far, but the success path works.

There is also no `IterFn` trait yet, as T-lang didn't consider it something urgently needed I think we can implement it in follow-up PRs.

r? lang for the tests, `@compiler-errors` for the impl
2025-06-03 21:53:35 +02:00
bors
59aa1e8730 Auto merge of #141229 - tgross35:builtins-josh-subtree, r=Kobzol
Merge `compiler-builtins` as a Josh subtree

Use the Josh [1] utility to add `compiler-builtins` as a subtree, which
will allow us to stop using crates.io for updates. This is intended to
help resolve some problems when unstable features change and require
code changes in `compiler-builtins`, which sometimes gets trapped in a
bootstrap cycle.

This was done using `josh-filter` built from the r24.10.04 tag:

    git fetch https://github.com/rust-lang/compiler-builtins.git 233434412fe7eced8f1ddbfeddabef1d55e493bd
    josh-filter ":prefix=library/compiler-builtins" FETCH_HEAD
    git merge --allow-unrelated FILTERED_HEAD

The HEAD in the `compiler-builtins` repository is 233434412f ("fix an if
statement that can be collapsed").

[1]: https://github.com/josh-project/josh
2025-06-03 19:52:05 +00:00
Oli Scherer
5fbdfc3e10
Add iter macro
This adds an `iter!` macro that can be used to create movable
generators.

This also adds a yield_expr feature so the `yield` keyword can be used
within iter! macro bodies. This was needed because several unstable
features each need `yield` expressions, so this allows us to stabilize
them separately from any individual feature.

Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
Co-authored-by: Jieyou Xu <jieyouxu@outlook.com>
Co-authored-by: Travis Cross <tc@traviscross.com>
2025-06-03 10:52:32 -07:00
Michael Goulet
0479e745fb Rework collect_and_apply to not rely on size hint for optimization 2025-06-03 17:29:08 +00:00
Jubilee Young
307a18dc53 compiler: actually remove Conv now that it is irrelevant 2025-06-03 10:08:11 -07:00