3158 Commits

Author SHA1 Message Date
bjorn3
7f7b3488c0 Introduce InlineAsmError type 2025-11-21 14:16:12 +00:00
Manuel Drehwald
0dfdb6c3da rlib handling 2025-11-19 00:17:37 -05:00
bors
cc328c1238 Auto merge of #149013 - Zalathar:rollup-io1ddhc, r=Zalathar
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#148505 (add larger test for `proc_macro` `FromStr` implementations)
 - rust-lang/rust#148752 (Constify `ManuallyDrop::take`)
 - rust-lang/rust#148757 (Constify `mem::take`)
 - rust-lang/rust#148855 (Error if an autodiff user does not set lto=fat)
 - rust-lang/rust#148912 (add note to `lines` docs about empty str behavior)
 - rust-lang/rust#148958 (Run codegen tests on a 32-bit target in PR CI)
 - rust-lang/rust#148994 (Abi compatibility test cleanup)
 - rust-lang/rust#148999 (Tweak Motor OS linker preset, fix `remote-test-server` for Motor OS)
 - rust-lang/rust#149004 (compiletest: Avoid race condition in file deletion)
 - rust-lang/rust#149008 (triagebot: remove jsha from notifications for rustdoc HTML)
 - rust-lang/rust#149010 (compiletest: Remove the "wasm32-bare" alias for `wasm32-unknown-unknown`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-17 07:49:48 +00:00
Stuart Cook
e34ef247cc
Rollup merge of #148855 - ZuseZ4:autodiff-lto-error, r=bjorn3
Error if an autodiff user does not set lto=fat

Based on your feedback, I started to provide a nice error message for a lack of `lto=fat`, instead of us forcing it.

In a next step, we should replace  `RUSTFLAGS="-Zautodiff=Enable"` with another Cargo.toml setting, as discussed here: https://github.com/rust-lang/rust/issues/147487#issuecomment-3446558644

As another improvement, we should also figure out why rlib builds do not properly obey the fat=lto setting.

```````@bjorn3```````
2025-11-17 16:41:02 +11:00
bors
89fe96197d Auto merge of #148478 - RalfJung:rotating-funnel, r=Mark-Simulacrum
use funnel shift as fallback impl for rotating shifts

That lets us remove this gnarly implementation from Miri and const-eval.

However, `rotate_left`/`rotate_right` are stable as const fn, so to do this we have to `rustc_allow_const_fn_unstable` a bunch of const trait stuff. Is that a bad idea? Cc `@oli-obk` `@fee1-dead`
2025-11-17 04:36:16 +00:00
bors
c880acdd31 Auto merge of #148931 - Zalathar:rollup-yfyhpcw, r=Zalathar
Rollup of 15 pull requests

Successful merges:

 - rust-lang/rust#148543 (Correctly link to associated trait items in reexports)
 - rust-lang/rust#148808 (Some resolve cleanups)
 - rust-lang/rust#148812 (coverage: Associate hole spans with expansion tree nodes )
 - rust-lang/rust#148826 (CStr docs: Fix CStr vs &CStr confusion)
 - rust-lang/rust#148850 (Implement `Read::read_array`)
 - rust-lang/rust#148867 (Refactor `Box::take`)
 - rust-lang/rust#148870 (Remove unused LLVMModuleRef argument)
 - rust-lang/rust#148878 (error when ABI does not support guaranteed tail calls)
 - rust-lang/rust#148901 (Disable rustdoc-test-builder test partially for SGX target.)
 - rust-lang/rust#148902 (add missing s390x target feature to std detect test)
 - rust-lang/rust#148904 (waffle: stop watching codegen ssa)
 - rust-lang/rust#148906 (Expose fmt::Arguments::from_str as unstable.)
 - rust-lang/rust#148907 (add assembly test for infinite recursion with `become`)
 - rust-lang/rust#148928 (Move & adjust some `!`-adjacent tests)
 - rust-lang/rust#148929 (ignore `build-rust-analyzer` even if it's a symlink)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-14 05:29:52 +00:00
Martin Nordholts
5ad2f434dc rustc_codegen_llvm: Require opt-level >= 1 for index-based loop
To make debugger stepping intuitive with `-Copt-level=0`. See the
adjusted `basic-stepping.rs` test.

This is kind of a revert of bd0aae92dc76d9, except we don't revert it,
we just make it conditional on `opt-level`. That commit regressed
`basic-stepping.rs`, but it was not noticed since that test did not
exist back then. I have retroactively bisected to find that out.

It seems messy to sprinkle if-cases inside of the
`write_operand_repeatedly()` so make the whole function conditional.

The test that bd0aae92dc76d9 added in
`tests/codegen/issues/issue-111603.rs` already use `-Copt-level=3`, so
we don't need to adjust the compiler flags for it to keep passing.
2025-11-13 06:29:55 +01:00
Quinn Okabayashi
c7e50d0f37 Remove unused LLVMModuleRef argument 2025-11-12 15:46:08 +00:00
Manuel Drehwald
63f4b36406 provide an error if an autodiff user does not set in their Cargo.toml 2025-11-11 23:44:06 -05:00
Tamir Duberstein
fcf6809b05
rustc_target: introduce Os
Improve type safety by using an enum rather than strings.
2025-11-11 18:55:40 -05:00
Tamir Duberstein
ddd7596400
rustc_target: introduce Env
Improve type safety by using an enum rather than strings.
2025-11-11 18:34:47 -05:00
Tamir Duberstein
86c74a4d16
rustc_target: introduce Abi
Improve type safety by using an enum rather than strings.
2025-11-11 18:22:38 -05:00
bors
acda5e9f9a Auto merge of #148692 - matthiaskrgr:rollup-hryk71f, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#145656 (Stabilize s390x `vector` target feature and `is_s390x_feature_detected!` macro)
 - rust-lang/rust#147024 (std_detect: Support run-time detection on OpenBSD using elf_aux_info)
 - rust-lang/rust#147534 (Implement SIMD funnel shifts in const-eval/Miri)
 - rust-lang/rust#147540 (Stabilise `as_array` in `[_]` and `*const [_]`; stabilise `as_mut_array` in `[_]` and `*mut [_]`.)
 - rust-lang/rust#147686 (update isolate_highest_one for NonZero<T>)
 - rust-lang/rust#148230 (rustdoc: Properly highlight shebang, frontmatter & weak keywords in source code pages and code blocks)
 - rust-lang/rust#148555 (Fix rust-by-example spanish translation)
 - rust-lang/rust#148556 (Fix suggestion for returning async closures)
 - rust-lang/rust#148585 ([rustdoc] Replace `print` methods with functions to improve code readability)
 - rust-lang/rust#148600 (re-use `self.get_all_attrs` result for pass indirectly attribute)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-09 01:40:19 +00:00
Matthias Krüger
da2e3aabca
Rollup merge of #147540 - bjoernager:slice-as-array, r=Amanieu
Stabilise `as_array` in `[_]` and `*const [_]`; stabilise `as_mut_array` in `[_]` and `*mut [_]`.

Tracking issue: rust-lang/rust#133508

Closes: rust-lang/rust#133508

This PR stabilises the `as_array` and `as_mut_array` associated functions from the `core_slice_as_array` feature gate:

```rust
// core::slice

impl<T> [T] {
    pub const fn as_array<const N: usize>(&self) -> Option<&[T; N]>;

    pub const fn as_mut_array<const N: usize>(&mut self) -> Option<&mut [T; N]>;
}

// core::ptr

impl<T> *const [T] {
    pub const fn as_array<const N: usize>(self) -> Option<*const [T; N]>;
}

impl<T> *mut [T] {
    pub const fn as_mut_array<const N: usize>(self) -> Option<*mut [T; N]>;
}
```

It also updates the feature gates and tracking issues for all items associated with the previous `slice_as_array` tracking issue (including these four that are being stabilised).

~~FCP missing.~~
2025-11-08 15:42:22 +01:00
bors
87f9dcd5e2 Auto merge of #147935 - luca3s:add-rtsan, r=petrochenkov
Add LLVM realtime sanitizer

This is a new attempt at adding the [LLVM real-time sanitizer](https://clang.llvm.org/docs/RealtimeSanitizer.html) to rust.

Previously this was attempted in https://github.com/rust-lang/rfcs/pull/3766.

Since then the `sanitize` attribute was introduced in https://github.com/rust-lang/rust/pull/142681 and it is a lot more flexible than the old `no_santize` attribute. This allows adding real-time sanitizer without the need for a new attribute, like it was proposed in the RFC. Because i only add a new value to a existing command line flag and to a attribute i don't think an MCP is necessary.

Currently real-time santizer is usable in rust code with the [rtsan-standalone](https://crates.io/crates/rtsan-standalone) crate. This downloads or builds the sanitizer runtime and then links it into the rust binary.

The first commit adds support for more detailed sanitizer information.
The second commit then actually adds real-time sanitizer.
The third adds a warning against using real-time sanitizer with async functions, cloures and blocks because it doesn't behave as expected when used with async functions. I am not sure if this is actually wanted, so i kept it in a seperate commit.
The fourth commit adds the documentation for real-time sanitizer.
2025-11-08 12:24:15 +00:00
bors
bbb6f68e28 Auto merge of #147803 - jsgf:move-copy-codegen, r=madsmtm,saethlin
Add -Zannotate-moves for profiler visibility of move/copy operations (codegen)

**Note:** this is an alternative implementation of https://github.com/rust-lang/rust/pull/147206; rather than being a MIR transform, it adds the annotations closer to codegen. It's functionally the same but the implementation is lower impact and it could be more correct.

---

This implements a new unstable compiler flag `-Zannotate-moves` that makes move and copy operations visible in profilers by creating synthetic debug information. This is achieved with zero runtime cost by manipulating debug info scopes to make moves/copies appear as calls to `compiler_move<T, SIZE>` and `compiler_copy<T, SIZE>` marker functions in profiling tools.

This allows developers to identify expensive move/copy operations in their code using standard profiling tools, without requiring specialized tooling or runtime instrumentation.

The implementation works at codegen time. When processing MIR operands (`Operand::Move` and `Operand::Copy`), the codegen creates an `OperandRef` with an optional `move_annotation` field containing an `Instance` of the appropriate profiling marker function. When storing the operand, `store_with_annotation()` wraps the store operation in a synthetic debug scope that makes it appear inlined from the marker.

Two marker functions (`compiler_move` and `compiler_copy`) are defined in `library/core/src/profiling.rs`. These are never actually called - they exist solely as debug info anchors.

Operations are only annotated if:
   - We're generating debug info and the feature is enabled.
   - Meets the size threshold (default: 65 bytes, configurable via `-Zannotate-moves=SIZE`), and is non-zero
   - Has a memory representation

This has a very small size impact on object file size. With the default limit it's well under 0.1%, and even with a very small limit of 8 bytes it's still ~1.5%. This could be enabled by default.
2025-11-08 07:57:14 +00:00
Gabriel Bjørnager Jensen
fa8e8649ad
Stabilise 'as_array' in '[_]' and '*const [_]'; Stabilise 'as_mut_array' in '[_]' and '*mut [_]'; Update feature gate and tracking issue for 'alloc_slice_into_array' items; 2025-11-07 15:14:41 +01:00
Jacob Pratt
c63793952e
Rollup merge of #145768 - ZuseZ4:offload-device, r=oli-obk
Offload device

LLVM's offload functionality usually expects an extra dyn_ptr argument. We could avoid it,b ut likely gonna need it very soon in one of the follow-up PRs (e.g. to request shared memory). So we might as well already add it.

This PR adds a %dyn_ptr ptr to GPUKernel ABI functions, if the offload feature is enabled.

WIP

r? ```@ghost```
2025-11-07 00:21:17 -05:00
Jeremy Fitzhardinge
5f29f11a4d Add -Zannotate-moves for profiler visibility of move/copy operations
This implements a new unstable compiler flag `-Zannotate-moves` that makes
move and copy operations visible in profilers by creating synthetic debug
information. This is achieved with zero runtime cost by manipulating debug
info scopes to make moves/copies appear as calls to `compiler_move<T, SIZE>`
and `compiler_copy<T, SIZE>` marker functions in profiling tools.

This allows developers to identify expensive move/copy operations in their
code using standard profiling tools, without requiring specialized tooling
or runtime instrumentation.

The implementation works at codegen time. When processing MIR operands
(`Operand::Move` and `Operand::Copy`), the codegen creates an `OperandRef`
with an optional `move_annotation` field containing an `Instance` of the
appropriate profiling marker function. When storing the operand,
`store_with_annotation()` wraps the store operation in a synthetic debug
scope that makes it appear inlined from the marker.

Two marker functions (`compiler_move` and `compiler_copy`) are defined
in `library/core/src/profiling.rs`. These are never actually called -
they exist solely as debug info anchors.

Operations are only annotated if the type:
   - Meets the size threshold (default: 65 bytes, configurable via
     `-Zannotate-moves=SIZE`)
   - Has a non-scalar backend representation (scalars use registers,
     not memcpy)

This has a very small size impact on object file size. With the default
limit it's well under 0.1%, and even with a very small limit of 8 bytes
it's still ~1.5%. This could be enabled by default.
2025-11-06 15:39:45 -08:00
Lucas Baumann
d198633b95 add realtime sanitizer 2025-11-06 13:20:12 +01:00
Lucas Baumann
bc883e24b8 replace SanitizerSet in CodegenFnAttrs by new type 2025-11-06 13:19:08 +01:00
Manuel Drehwald
360b38cceb Fix device code generation, to account for an implicit dyn_ptr argument. 2025-11-06 03:34:38 -05:00
Ralf Jung
a00db66b00 use fallback impl in LLVM backend 2025-11-06 08:02:10 +01:00
Stuart Cook
efdc8aca3e
Rollup merge of #147043 - ilovepi:default-sanitizers, r=petrochenkov
Add default sanitizers to TargetOptions

Some sanitizers are part of a system's ABI, like the shadow call stack on Aarch64 and RISC-V Fuchsia. Typically ABI options have other spellings, but LLVM has, for historical reasons, marked this as a sanitizer instead of an alternate ABI option. As a result, Fuchsia targets may not be compiled against the correct ABI unless this option is set. This hasn't caused correctness problems, since the backend reserves the SCS register, and thus preserves its value. But this is an issue for unwinding, as the SCS will not be an array of PCs describing the call complete call chain, and will have gaps from callers that don't use the correct ABI.

In the long term, I'd like to see all the sanitizer configs that all frontends copy from clang moved into llvm's libFrontend, and exposed so that frontend consumers can use a small set of simple APIs to use sanitizers in a consistent way across the LLVM ecosystem, but that work is not yet ready today.
2025-11-06 14:07:16 +11:00
bors
401ae55427 Auto merge of #148544 - matthiaskrgr:rollup-n9dqgwc, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#147994 (Deduplicate deprecation warning when using unit or tuple structs)
 - rust-lang/rust#148440 ([rustdoc search] Simplify itemTypes and filter "dependencies")
 - rust-lang/rust#148501 (triagebot: Create Zulip topics for libs backports)
 - rust-lang/rust#148517 (Remove no longer necessary lint allow)
 - rust-lang/rust#148518 (Unify the configuration of the compiler docs)
 - rust-lang/rust#148523 (miri subtree update)
 - rust-lang/rust#148525 (Fix ICE from lit_to_mir_constant caused by type error)
 - rust-lang/rust#148534 (Merge `Vec::push{,_mut}_within_capacity`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-05 21:07:24 +00:00
bors
b01cc1cf01 Auto merge of #148516 - bjorn3:target_feature_parsing_improvements, r=WaffleLapkin
Move warning reporting from flag_to_backend_features to cfg_target_feature

This way warnings are emitted even in a check build.
2025-11-05 17:56:16 +00:00
bjorn3
973c7527b4 Unify the configuration of the compiler docs
Previously it was rather inconsistent which crates got the rust logo and
which didn't and setting html_root_url was forgotten in many cases.
2025-11-05 11:25:27 +00:00
bjorn3
1d34478147 Move warning reporting from flag_to_backend_features to cfg_target_feature
This way warnings are emitted even in a check build.
2025-11-05 10:48:29 +00:00
bors
8e0b68e63c Auto merge of #148507 - Zalathar:rollup-vvz4knr, r=Zalathar
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#147355 (Add alignment parameter to `simd_masked_{load,store}`)
 - rust-lang/rust#147925 (Fix tests for big-endian)
 - rust-lang/rust#148341 (compiler: Fix a couple issues around cargo feature unification)
 - rust-lang/rust#148371 (Dogfood `trim_{suffix|prefix}` in compiler)
 - rust-lang/rust#148495 (Implement Path::is_empty)
 - rust-lang/rust#148502 (rustc-dev-guide subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-05 07:25:39 +00:00
Tamir Duberstein
26b0560b6d
rustc_target: allow unenumerated architectures 2025-11-04 21:28:28 -05:00
Tamir Duberstein
270e49b307
rustc_target: introduce Arch
Improve type safety by using an enum rather than strings.
2025-11-04 21:27:22 -05:00
Stuart Cook
21da1760da
Rollup merge of #148371 - yotamofek:pr/dogfood-trim-prefix-suffix, r=fee1-dead
Dogfood `trim_{suffix|prefix}` in compiler

cc rust-lang/rust#142312
2025-11-05 10:59:19 +11:00
Stuart Cook
c33d51b9d8
Rollup merge of #147355 - sayantn:masked-loads, r=RalfJung,bjorn3
Add alignment parameter to `simd_masked_{load,store}`

This PR adds an alignment parameter in `simd_masked_load` and `simd_masked_store`, in the form of a const-generic enum `core::intrinsics::simd::SimdAlign`. This represents the alignment of the `ptr` argument in these intrinsics as follows

 - `SimdAlign::Unaligned` - `ptr` is unaligned/1-byte aligned
 - `SimdAlign::Element` - `ptr` is aligned to the element type of the SIMD vector (default behavior in the old signature)
 - `SimdAlign::Vector` - `ptr` is aligned to the SIMD vector type

The main motive for this is stdarch - most vector loads are either fully aligned (to the vector size) or unaligned (byte-aligned), so the previous signature doesn't cut it.

Now, stdarch will mostly use `SimdAlign::Unaligned` and `SimdAlign::Vector`, whereas portable-simd will use `SimdAlign::Element`.

 - [x] `cg_llvm`
 - [x] `cg_clif`
 - [x] `miri`/`const_eval`

## Alternatives

Using a const-generic/"const" `u32` parameter as alignment (and we error during codegen if this argument is not a power of two). This, although more flexible than this, has a few drawbacks

 - If we use an const-generic argument, then portable-simd somehow needs to pass `align_of::<T>()` as the alignment, which isn't possible without GCE
 - "const" function parameters are just an ugly hack, and a pain to deal with in non-LLVM backends

We can remedy the problem with the const-generic `u32` parameter by adding a special rule for the element alignment case (e.g. `0` can mean "use the alignment of the element type), but I feel like this is not as expressive as the enum approach, although I am open to suggestions

cc `@workingjubilee` `@RalfJung` `@BoxyUwU`
2025-11-05 10:59:18 +11:00
Stuart Cook
b618119fa9
Rollup merge of #145974 - pmur:murp/stabilize-zno-jump-tables, r=wesleywiser
Stabilize -Zno-jump-tables into -Cjump-tables=bool

I propose stabilizing the -Zno-jump-tables option into -Cjump-tables=<bool>.

# `-Zno-jump-tables` stabilization report
## What is the RFC for this feature and what changes have occurred to the user-facing design since the RFC was finalized?
No RFC was created for this option. This was a narrowly scoped option introduced in rust-lang/rust#105812 to support code generation requirements of the x86-64 linux kernel, and eventually other targets as Rust For Linux grows.

The tracking is rust-lang/rust#116592.

##  What behavior are we committing to that has been controversial? Summarize the major arguments pro/con.

The behavior of this flag is well defined, and mimics the existing `-fno-jump-tables` option currently available with LLVM and GCC with some caveats:

* Unlike clang or gcc, this option may be ignored by the code generation backend. Rust can support multiple code-generation backends. For stabilization, only the LLVM backend honors this option.
* The usage of this option will not guarantee a library or binary is free of jump tables. To ensure a jump-table free binary, all crates in the build graph must be compiled with this option. This includes implicitly linked crates such as std or core.
* This option only enforces the crate being compiled is free of jump tables.
* No verification is done to ensure other crates are compiled with this option. Enforcing code generation options are applied across the crate graph is out of scope for this option.

What should the flag name be?
* As introduced, this option was named `-Zno-jump-tables`. However, other major toolchains allow both positive and negative variants of this option to toggle this feature. Renaming the option to `-Cjump-tables=<bool>` makes this option consistent, and if for some reason, expandable to other arguments in the future. Notably, many LLVM targets have a configurable and different thresholds for when to lower into a jump table.

## Are there extensions to this feature that remain unstable? How do we know that we are not accidentally committing to those.
No. This option is used exclusively to gate a very specific class of optimization.

## Summarize the major parts of the implementation and provide links into the code (or to PRs)
* The original PR rust-lang/rust#105812 by ```@ojeda```
* The stabilized CLI option is parsed as a bool:
68bfda9025/compiler/rustc_session/src/options.rs (L2025-L2026)
* This options adds an attribute to each llvm function via:
68bfda9025/compiler/rustc_codegen_llvm/src/attributes.rs (L210-L215)
* Finally, the rustc book is updated with the new option:
68bfda9025/src/doc/rustc/src/codegen-options/index.md (L212-L223)

## Has a call-for-testing period been conducted? If so, what feedback was received?
No. The option has originally created is being used by Rust For Linux to build the x86-64 kernel without issue.

## What outstanding bugs in the issue tracker involve this feature? Are they stabilization-blocking?
There are no outstanding issues.

## Summarize contributors to the feature by name for recognition and assuredness that people involved in the feature agree with stabilization

* ```@ojeda``` implemented this feature in rust-lang/rust#105815 as  `-Zno-jump-tables`.
* ```@tgross35``` created and maintained the tracking issue rust-lang/rust#116592, and provided feedback about the naming of the cli option.

## What FIXMEs are still in the code for that feature and why is it ok to leave them there?
There are none.

## What static checks are done that are needed to prevent undefined behavior?
This option cannot cause undefined behavior. It is a boolean option with well defined behavior in both cases.

## In what way does this feature interact with the reference/specification, and are those edits prepared?
This adds a new cli option to `rustc`. The documentation is updated, and the unstable documentation cleaned up in this PR.

## Does this feature introduce new expressions and can they produce temporaries? What are the lifetimes of those temporaries?
No.

## What other unstable features may be exposed by this feature?
None.

## What is tooling support like for this feature, w.r.t rustdoc, clippy, rust-analzyer, rustfmt, etc.?
No support is required from other rust tooling.

## Open Items

- [x] Are there objections renaming `-Zno-jump-tables` to `-Cjump-tables=<bool>`? The consensus is no.
- [x] Is it desirable to keep `-Zno-jump-tables` for a period of time? The consensus is no.

---

Closes rust-lang/rust#116592
2025-11-04 13:44:48 +11:00
Paul Kirth
e207006ad3 Add default sanitizers to TargetOptions
Some sanitizers are part of a system's ABI, like the shadow call stack
on Aarch64 and RISC-V Fuchsia. Typically ABI options have other
spellings, but LLVM has, for historical reasons, marked this as a
sanitizer instead of an alternate ABI option. As a result, Fuchsia
targets may not be compiled against the correct ABI unless this option
is set. This hasn't caused correctness problems, since the backend
reserves the SCS register, and thus preserves its value. But this is an
issue for unwinding, as the SCS will not be an array of PCs describing
the call complete call chain, and will have gaps from callers that don't
use the correct ABI.

In the long term, I'd like to see all the sanitizer configs that all
frontends copy from clang moved into llvm's libFrontend, and exposed so
that frontend consumers can use a small set of simple APIs to use
sanitizers in a consistent way across the LLVM ecosystem, but that work
is not yet ready today.
2025-11-03 17:36:32 -06:00
sayantn
75de619159
Add alignment parameter to simd_masked_{load,store} 2025-11-04 02:30:59 +05:30
bors
20383c9f1d Auto merge of #148350 - scottmcm:slice-range-attributes, r=JonathanBrouwer,davidtwco
Add LLVM range attributes to slice length parameters

It'll take a bunch more work to do this in layout -- because of cycles in `struct Foo<'a>(&'a Foo<'a>);` -- so until we figure out how to do that well, just look for slices specifically and add the proper range for the length.
2025-11-03 19:36:42 +00:00
Paul Murphy
bb9d800b78 Stabilize -Zjump-tables=<bool> into -Cjump-table=<bool> 2025-11-03 08:12:16 -06:00
Paul Murphy
4959d18a97 Rename -Zno-jump-tables to -Zjump-tables=<bool>
Both gcc and llvm accept -fjump-tables as well as -fno-jump-tables. For
consistency, allow rustc to accept -Zjump-tables=yes too.
2025-11-03 08:12:13 -06:00
bors
7878a91944 Auto merge of #148420 - Zalathar:rollup-1rrbzk7, r=Zalathar
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#144194 (Provide additional context to errors involving const traits)
 - rust-lang/rust#148232 (ci: add runners for vanilla LLVM 21)
 - rust-lang/rust#148240 (rustc_codegen: fix musttail returns for cast/indirect ABIs)
 - rust-lang/rust#148247 (Remove a special case and move another one out of reachable_non_generics)
 - rust-lang/rust#148370 (Point at inner item when it uses generic type param from outer item or `Self`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-03 02:52:00 +00:00
Stuart Cook
4b28573ad1
Rollup merge of #148247 - bjorn3:minor_symbol_export_cleanup, r=WaffleLapkin
Remove a special case and move another one out of reachable_non_generics

One is no longer necessary, the other is best placed in cg_llvm as it works around a cg_llvm bug.
2025-11-03 11:52:40 +11:00
Stuart Cook
f8ff304f87
Rollup merge of #148240 - InvalidPathException:master, r=WaffleLapkin
rustc_codegen: fix musttail returns for cast/indirect ABIs

Fixes rust-lang/rust#148239 https://github.com/rust-lang/rust/issues/144986

Explicit tail calls trigger `bug!` for any callee whose ABI returns via `PassMode::Cast`, and we forgot to to forward the hidden `sret` out-pointer when the ABI requested an indirect return. The former causes ICE, the latter produced malformed IR (wrong codegen) if the return value is large enough to need `sret`.

Updated the musttail helper to accept cast-mode returns, made it so that we pass the return pointer through the tail-call path.

Added two UI tests to demonstrate each case.

This is my first time contributing, please do check if I did it right.

r? theemathas
2025-11-03 11:52:40 +11:00
Yotam Ofek
d28dcc7e79 Dogfood trim_{suffix|prefix} in compiler 2025-11-02 16:55:18 +02:00
bjorn3
964d3af793 Move a special case for rust_eh_personality from reachable_non_generics to cg_llvm
This is a workaround for an LLVM bug, so put it in cg_llvm.
2025-11-02 10:46:13 +00:00
Jakub Beránek
d3473f0741
Generalize branch references to HEAD 2025-11-02 11:15:55 +01:00
Scott McMurray
0ba7bcfc44 Add LLVM range attributes to slice length parameters 2025-10-31 16:12:30 -07:00
Matthias Krüger
3d671c0d54
Rollup merge of #148103 - Zalathar:compression, r=wesleywiser
cg_llvm: Pass `debuginfo_compression` through FFI as an enum

There are only three possible values, making an enum more appropriate.

This avoids string allocation on the Rust side, and avoids ad-hoc `!strcmp` to convert back to an enum on the C++ side.
2025-10-31 18:41:51 +01:00
Mark Z. Ding
52959a85cc Fix musttail returns for cast/indirect ABIs 2025-10-29 11:58:47 -04:00
Stuart Cook
a383fe8f20
Rollup merge of #148139 - Urgau:add-coverage-scope, r=Zalathar
Add `coverage` scope for controlling paths in code coverage

This PR adds a `coverage` scope (for `-Zremap-path-scope`) for controlling if the paths that ends up in code coverage output should be remapped or not.

Currently code coverage use the `macro` scope which is not a appropriate scope for them.

Found during the stabilization of `-Zremap-path-scope` https://github.com/rust-lang/rust/pull/147611#issuecomment-3396210043 and was asked to be in a separate PR in https://github.com/rust-lang/rust/pull/147611#issuecomment-3448455252.

r? compiler
2025-10-28 20:39:37 +11:00
Urgau
94c893ee2e Add coverage scope for controlling paths in code coverage 2025-10-27 12:54:24 +01:00