2164 Commits

Author SHA1 Message Date
Stuart Cook
6473a0f02d
Rollup merge of #146564 - cjgillot:mir-nolen, r=scottmcm
Remove Rvalue::Len again.

Now that we have `RawPtrKind::FakeForPtrMetadata`, we can reimplement `Rvalue::Len` using `PtrMetadata(&raw const (fake) place)`.

r? ``@scottmcm``
2025-09-17 14:56:48 +10:00
Stuart Cook
6ad98750e0
Rollup merge of #145660 - jbatez:darwin_objc, r=jdonszelmann,madsmtm,tmandry
initial implementation of the darwin_objc unstable feature

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

This feature makes it possible to reference Objective-C classes and selectors using the same ABI used by native Objective-C on Apple/Darwin platforms. Without it, Rust code interacting with Objective-C must resort to loading classes and selectors using costly string-based lookups at runtime. With it, these references can be loaded efficiently at dynamic load time.

r? ```@tmandry```

try-job: `*apple*`
try-job: `x86_64-gnu-nopt`
2025-09-17 14:56:44 +10:00
Camille Gillot
53b91ea87f Remove Rvalue::Len. 2025-09-16 22:23:19 +00:00
Jo Bates
1ebf69d1b1 initial implementation of the darwin_objc unstable feature 2025-09-13 16:06:22 -07:00
Jacob Pratt
4ee860f6b8
Rollup merge of #146159 - camsteffen:hygiene-docs, r=petrochenkov
Some hygiene doc improvements

Improve some doc comments around SyntaxContext, outer_expn and friends.

Based on discussion at https://github.com/rust-lang/rust/pull/146100.

r? petrochenkov
2025-09-13 18:55:16 -04:00
Stuart Cook
f38c788d84
Rollup merge of #146347 - folkertdev:duplicate-symbol-panic, r=fee1-dead
report duplicate symbols added by the driver

The panic message did not mention what symbols were duplicates, which made the panic hard to debug. This came up in [#t-compiler/help > Easiest way to find offending duplicate symbols](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/Easiest.20way.20to.20find.20offending.20duplicate.20symbols/with/538295740).

This behavior was introduced in https://github.com/rust-lang/rust/pull/138682.

r? ```@fee1-dead```
2025-09-11 14:06:28 +10:00
Matthias Krüger
4a834b54d4
Rollup merge of #146311 - nnethercote:symbol-comments, r=petrochenkov
Minor symbol comment fixes.

- The empty symbol is no longer a keyword.
- I don't think any of the special reserved identifiers are used for error recovery.

r? ```@petrochenkov```
2025-09-10 20:29:06 +02:00
Matthias Krüger
422c76adae
Rollup merge of #146178 - folkertdev:static-align, r=jdonszelmann,ralfjung,traviscross
Implement `#[rustc_align_static(N)]` on `static`s

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

```rust
#![feature(static_align)]

#[rustc_align_static(64)]
static SO_ALIGNED: u64 = 0;
```

We need a different attribute than `rustc_align` because unstable attributes are tied to their feature (we can't have two unstable features use the same unstable attribute). Otherwise this uses all of the same infrastructure as `#[rustc_align]`.

r? `@traviscross`
2025-09-10 14:17:38 +02:00
Matthias Krüger
d0ba5e33ff
Rollup merge of #144765 - Qelxiros:range-inclusive-last, r=jhpratt
inclusive `Range`s: change `end` to `last`

Tracking issue: rust-lang/rust#125687
ACP: rust-lang/libs-team#511
2025-09-10 14:17:37 +02:00
Folkert de Vries
cbacd00f10
allow #[rustc_align_static(N)] on statics
We need a different attribute than `rustc_align` because unstable attributes are
tied to their feature (we can't have two unstable features use the same
unstable attribute). Otherwise this uses all of the same infrastructure
as `#[rustc_align]`.
2025-09-09 21:54:54 +02:00
Jeremy Smart
8d0c07f1a1
change end to last 2025-09-08 22:07:43 -04:00
Folkert de Vries
eba09340e0
report duplicate symbol added by the driver 2025-09-08 21:13:04 +02:00
Nicholas Nethercote
380c906beb Minor symbol comment fixes.
- The empty symbol is no longer a keyword.
- I don't think any of the special reserved identifiers are used for
  error recovery.
2025-09-08 06:07:20 +10:00
WANG Rui
58e2cd4263 Revert "Add LSX accelerated implementation for source file analysis"
This reverts commit 5b43244ac59119870c9e0f6b642340ab88355b23 to fix
native build failures on LoongArch.
2025-09-07 11:27:20 +08:00
Cameron Steffen
31b39150c7 Some hygiene doc improvements 2025-09-05 20:22:12 -05:00
Jacob Pratt
00d5dc5c9d
Rollup merge of #145690 - sayantn:integer-funnel-shift, r=tgross35
Implement Integer funnel shifts

Tracking issue: rust-lang/rust#145686
ACP: https://github.com/rust-lang/libs-team/issues/642

This implements funnel shifts on primitive integer types. Implements this for cg_llvm, with a fallback impl for everything else

Thanks `@folkertdev` for the fixes and tests

cc `@rust-lang/libs-api`
2025-09-04 01:43:21 -04:00
Stuart Cook
2952b99dca
Rollup merge of #145963 - heiher:src-analysis-lsx, r=lqd
Add LSX accelerated implementation for source file analysis

This patch introduces an LSX-optimized version of `analyze_source_file` for the `loongarch64` target. Similar to existing SSE2 implementation for x86, this version:

- Processes 16-byte chunks at a time using LSX vector intrinsics.
- Quickly identifies newlines in ASCII-only chunks.
- Falls back to the generic implementation when multi-byte UTF-8 characters are detected or in the tail portion.
2025-09-04 10:01:57 +10:00
Stuart Cook
f90cc353b8
Rollup merge of #145932 - JamieCunliffe:target-feature-inlining, r=jackh726
Allow `inline(always)` with a target feature behind a unstable feature `target_feature_inline_always`.

Rather than adding the inline always attribute to the function definition, we add it to the callsite. We can then check that the target features match and that the call would be safe to inline. If the function isn't inlined due to a mismatch, we emit a warning informing the user that the function can't be inlined due to the target feature mismatch.

See tracking issue rust-lang/rust#145574
2025-09-04 10:01:55 +10:00
sayantn
62b4347e80
Add funnel_sh{l,r} functions and intrinsics
- Add a fallback implementation for the intrinsics
 - Add LLVM backend support for funnel shifts

Co-Authored-By: folkertdev <folkert@folkertdev.nl>
2025-09-03 14:13:24 +05:30
WANG Rui
5b43244ac5 Add LSX accelerated implementation for source file analysis
This patch introduces an LSX-optimized version of `analyze_source_file`
for the `loongarch64` target. Similar to existing SSE2 implementation
for x86, this version:

- Processes 16-byte chunks at a time using LSX vector intrinsics.
- Quickly identifies newlines in ASCII-only chunks.
- Falls back to the generic implementation when multi-byte UTF-8
  characters are detected or in the tail portion.
2025-09-02 21:00:32 +08:00
Nicholas Nethercote
301655eafe Revert introduction of [workspace.dependencies].
This was done in #145740 and #145947. It is causing problems for people
using r-a on anything that uses the rustc-dev rustup package, e.g. Miri,
clippy.

This repository has lots of submodules and subtrees and various
different projects are carved out of pieces of it. It seems like
`[workspace.dependencies]` will just be more trouble than it's worth.
2025-09-02 19:12:54 +10:00
Trevor Gross
751a9ad2e2
Rollup merge of #145756 - okaneco:stabilize_char_boundary, r=scottmcm
str: Stabilize `round_char_boundary` feature

Closes https://github.com/rust-lang/rust/issues/93743
FCP completed https://github.com/rust-lang/rust/issues/93743#issuecomment-3168382171
2025-08-29 19:33:03 -05:00
Stuart Cook
2246dda682
Rollup merge of #145947 - nnethercote:workspace-members-2, r=Kobzol
Add more to the `[workspace.dependencies]` section in the top-level `Cargo.toml`

Following on from rust-lang/rust#145740.

r? `@Kobzol`
2025-08-29 12:54:12 +10:00
Guillaume Gomez
f948c79911
Rollup merge of #142472 - GuillaumeGomez:doc-attribute-attribute, r=fmease
Add new `doc(attribute = "...")` attribute

Fixes rust-lang/rust#141123.

The implementation and purpose of this new `#[doc(attribute = "...")]` attribute is very close to `#[doc(keyword = "...")]`. Which means that luckily for us, most of the code needed was already in place and `@Noratrieb` nicely wrote a first draft that helped me implement this new attribute very fast.

Now with all this said, there is one thing I didn't do yet: adding a `rustdoc-js-std` test. I added GUI tests with search results for attributes so should be fine but I still plan on adding one for it once documentation for builtin attributes will be written into the core/std libs.

You can test it [here](https://rustdoc.crud.net/imperio/doc-attribute-attribute/foo/index.html).

cc `@Noratrieb` `@Veykril`
2025-08-28 21:41:00 +02:00
Guillaume Gomez
ab0ee84eac Add new doc(attribute = "...") attribute 2025-08-28 15:56:29 +02:00
Nicholas Nethercote
42359b7026 Add scoped-tls to [workspace.dependencies]. 2025-08-28 20:12:16 +10:00
Nicholas Nethercote
e692c97ad3 Add derive-where to [workspace.dependencies]. 2025-08-28 20:11:52 +10:00
Nicholas Nethercote
77b047aaab Add indexmap to [workspace.dependencies]. 2025-08-28 20:10:55 +10:00
Jonathan Brouwer
e8d08b5416
Port the #[link] attribute to the new parser 2025-08-27 20:25:16 +02:00
James Barford-Evans
bcfc9b5073 inline at the callsite & warn when target features mismatch
Co-authored-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
2025-08-27 14:45:01 +01:00
Nicholas Nethercote
c50d2cc807 Add tracing to [workspace.dependencies]. 2025-08-27 14:21:19 +10:00
Samuel Tardieu
ac7f423d52
Rollup merge of #145840 - a4lg:riscv-elf-flags-for-internal-objs, r=WaffleLapkin
rustc_codegen_ssa: More comprehensive RISC-V ELF flags

This change implements more conformant, more comprehensive RISC-V ELF flags handling when generating certain object files directly from rustc.

*   Use `"zca"` instead of `"c"`
    The "Zca" extension (a subset of "C") is the minimal configuration for compressed instructions to set `EF_RISCV_RVC` flag.
*   Set TSO flag from `"ztso"`
    The "Ztso" extension denotes that the program depends on the RVTSO (Total Store Ordering) memory consistency model, which is stronger than the standard RVWMO (Weak Memory Ordering) consistency model and on ELF targets, we need to set `EF_RISCV_TSO` flag.
2025-08-26 23:25:02 +02:00
Tsukasa OI
cb8c905c47 rustc_codegen_ssa: More comprehensive RISC-V ELF flags
This commit implements more conformant, more comprehensive RISC-V ELF
flags handling when generating certain object files directly from rustc.

*   Use "zca" instead of "c"
    The "Zca" extension (a subset of "C") is the minimal configuration
    for compressed instructions to set `EF_RISCV_RVC` flag.
*   Set TSO flag from "ztso"
    The "Ztso" extension denotes that the program depends on the RVTSO
    (Total Store Ordering) memory consistency model, which is stronger
    than the standard RVWMO (Weak Memory Ordering) consistency model and
    on ELF targets, we need to set `EF_RISCV_TSO` flag.
2025-08-26 03:42:37 +00:00
Jakub Beránek
3145c06431
Do not open every source file twice when reading it 2025-08-25 20:40:11 +02:00
Jacob Pratt
566c13c88e
Rollup merge of #145726 - aapoalas:reborrow-lang-experiment, r=petrochenkov
Experiment: Reborrow trait

Tracking issue: rust-lang/rust#145612

Starting off really small here: just introduce the unstable feature and the feature gate, and one of the two traits that the Reborrow experiment deals with.

### Cliff-notes explanation

The `Reborrow` trait is conceptually a close cousin of `Copy` with the exception that it disables the source (`self`) for the lifetime of the target / result of the reborrow action. It can be viewed as a method of `fn reborrow(self: Self<'a>) -> Self<'a>` with the compiler adding tracking of the resulting `Self<'a>` (or any value derived from it that retains the `'a` lifetime) to keep the `self` disabled for reads and writes.

No method is planned to be surfaced to the user, however, as reborrowing cannot be seen in code (except for method calls [`a.foo()` reborrows `a`] and explicit reborrows [`&*a`]) and thus triggering user-code in it could be viewed as "spooky action at a distance". Furthermore, the added compiler tracking cannot be seen on the method itself, violating the Golden Rule. Note that the userland "reborrow" method is not True Reborrowing, but rather a form of a "Fancy Deref":
```rust
fn reborrow(&'short self: Self<'long>) -> Self<'short>;
```
The lifetime shortening is the issue here: a reborrowed `Self` or any value derived from it is bound to the method that called `reborrow`, since `&'short` is effectively a local variable. True Reborrowing does not shorten the lifetime of the result.

To avoid having to introduce new kinds of references, new kinds of lifetime annotations, or a blessed trait method, no method will be introduced at all. Instead, the `Reborrow` trait is intended to be a derived trait that effectively reborrows each field individually; `Copy` fields end up just copying, while fields that themselves `Reborrow` get disabled in the source, usually leading to the source itself being disabled (some differences may appear with structs that contain multiple reborrowable fields). The goal of the experiment is to determine how the actual implementation here will shape out, and what the "bottom case" for the recursive / deriving `Reborrow` is.

`Reborrow` has a friend trait, `CoerceShared`, which is equivalent to a `&'a mut T -> &'a T` conversion. This is needed as a different trait and different operation due to the different semantics it enforces on the source: a `CoerceShared` operation only disables the source for writes / exclusive access for the lifetime of the result. That trait is not yet introduced in this PR, though there is no particular reason why it could not be introduced.
2025-08-22 22:00:55 -04:00
Jacob Pratt
45d5109ad8
Rollup merge of #145573 - veluca93:unsafe-force-target-feature, r=davidtwco
Add an experimental unsafe(force_target_feature) attribute.

This uses the feature gate for https://github.com/rust-lang/rust/issues/143352, but is described in https://github.com/rust-lang/rfcs/pull/3820 which is strongly tied to the experiment.
2025-08-22 22:00:51 -04:00
Jacob Pratt
2dbd411d22
Rollup merge of #144897 - fee1-dead-contrib:raw_lifetimes_printing, r=fmease
print raw lifetime idents with r#

This replaces rust-lang/rust#143185 and fixes rust-lang/rust#143150

cc ``@fmease``
2025-08-22 22:00:47 -04:00
bors
6545b05638 Auto merge of #145494 - cjgillot:span-decode-once, r=lqd
Only unpack span data once to compute end_point and next_point.

Split from https://github.com/rust-lang/rust/pull/144930
2025-08-22 21:43:06 +00:00
okaneco
e42c1b1296 Stabilize round_char_boundary feature 2025-08-22 13:42:38 -04:00
Deadbeef
4970127c33 address review comments 2025-08-22 13:16:44 +08:00
Deadbeef
1e5b5ba1e7 print raw lifetime idents with r# 2025-08-22 12:58:37 +08:00
Luca Versari
291da71b2a Add an experimental unsafe(force_target_feature) attribute.
This uses the feature gate for
https://github.com/rust-lang/rust/issues/143352, but is described in
https://github.com/rust-lang/rfcs/pull/3820 which is strongly tied to
the experiment.
2025-08-22 01:26:26 +02:00
Aapo Alasuutari
5af359162e Introduce Reborrow lang item and trait 2025-08-21 23:53:25 +03:00
bors
040a98af70 Auto merge of #144086 - clubby789:alloc-zeroed, r=nikic
Pass `alloc-variant-zeroed` to LLVM

Makes use of https://github.com/llvm/llvm-project/pull/138299 (once we pull in a version of LLVM with this attribute). ~~Unfortunately also requires https://github.com/llvm/llvm-project/pull/149336 to work.~~

Closes rust-lang/rust#104847
2025-08-20 17:16:34 +00:00
clubby789
8ea3b09381 Pass alloc-variant-zeroed to LLVM 2025-08-20 17:08:46 +01:00
许杰友 Jieyou Xu (Joe)
3134f22d8b
Rollup merge of #145505 - cjgillot:tweak-span-cache, r=petrochenkov
Simplify span caches

Split from https://github.com/rust-lang/rust/pull/143882

r? `@petrochenkov`
2025-08-19 19:45:37 +08:00
Stuart Cook
633cc0cc6c
Rollup merge of #142681 - 1c3t3a:sanitize-off-on, r=rcvalle
Remove the `#[no_sanitize]` attribute in favor of `#[sanitize(xyz = "on|off")]`

This came up during the sanitizer stabilization (rust-lang/rust#123617). Instead of a `#[no_sanitize(xyz)]` attribute, we would like to have a `#[sanitize(xyz = "on|off")]` attribute, which is more powerful and allows to be extended in the future (instead
of just focusing on turning sanitizers off). The implementation is done according to what was [discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/343119-project-exploit-mitigations/topic/Stabilize.20the.20.60no_sanitize.60.20attribute/with/495377292)).

The new attribute also works on modules, traits and impl items and thus enables usage as the following:
```rust
#[sanitize(address = "off")]
mod foo {
    fn unsanitized(..) {}

    #[sanitize(address = "on")]
    fn sanitized(..) {}
}

trait MyTrait {
  #[sanitize(address = "off")]
  fn unsanitized_default(..) {}
}

#[sanitize(thread = "off")]
impl MyTrait for () {
    ...
}
```

r? ```@rcvalle```
2025-08-19 14:18:16 +10:00
Bastian Kersting
95bdb34494 Remove the no_sanitize attribute in favor of sanitize
This removes the #[no_sanitize] attribute, which was behind an unstable
feature named no_sanitize. Instead, we introduce the sanitize attribute
which is more powerful and allows to be extended in the future (instead
of just focusing on turning sanitizers off).

This also makes sanitize(kernel_address = ..) attribute work with
-Zsanitize=address

To do it the same as how clang disables address sanitizer, we now
disable ASAN on sanitize(kernel_address = "off") and KASAN on
sanitize(address = "off").

The same was added to clang in https://reviews.llvm.org/D44981.
2025-08-18 08:45:28 +00:00
Stuart Cook
152b43c7cb
Rollup merge of #145208 - joshtriplett:mbe-derive, r=petrochenkov
Implement declarative (`macro_rules!`) derive macros (RFC 3698)

This is a draft for review, and should not be merged yet.

This is layered atop https://github.com/rust-lang/rust/pull/145153 , and has
only two additional commits atop that. The first handles parsing and provides a
test for various parse errors. The second implements expansion and handles
application.

This implements RFC 3698, "Declarative (`macro_rules!`) derive macros".
Tracking issue: https://github.com/rust-lang/rust/issues/143549

This has one remaining issue, which I could use some help debugging: in
`tests/ui/macros/macro-rules-derive-error.rs`, the diagnostics for
`derive(fn_only)` (for a `fn_only` with no `derive` rules) and
`derive(ForwardReferencedDerive)` both get emitted twice, as a duplicate
diagnostic.

From what I can tell via adding some debugging code,
`unresolved_macro_suggestions` is getting called twice from
`finalize_macro_resolutions` for each of them, because
`self.single_segment_macro_resolutions` has two entries for the macro, with two
different `parent_scope` values. I'm not clear on why that happened; it doesn't
happen with the equivalent code using attrs.

I'd welcome any suggestions for fixing this.
2025-08-18 15:31:10 +10:00
Stuart Cook
d92e1fe8d7
Rollup merge of #145206 - scrabsha:push-uxovoqzrxnlx, r=jdonszelmann
Port `#[custom_mir(..)]` to the new attribute system

r? ``````````@jdonszelmann``````````
2025-08-18 15:31:10 +10:00