about summary refs log tree commit diff
path: root/compiler/rustc_span
AgeCommit message (Collapse)AuthorLines
2025-09-11Rollup merge of #146347 - folkertdev:duplicate-symbol-panic, r=fee1-deadStuart Cook-6/+15
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-10Rollup merge of #146311 - nnethercote:symbol-comments, r=petrochenkovMatthias Krüger-7/+6
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-10Rollup merge of #146178 - folkertdev:static-align, ↵Matthias Krüger-0/+2
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-10Rollup merge of #144765 - Qelxiros:range-inclusive-last, r=jhprattMatthias Krüger-0/+2
inclusive `Range`s: change `end` to `last` Tracking issue: rust-lang/rust#125687 ACP: rust-lang/libs-team#511
2025-09-09allow `#[rustc_align_static(N)]` on `static`sFolkert de Vries-0/+2
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-08change end to lastJeremy Smart-0/+2
2025-09-08report duplicate symbol added by the driverFolkert de Vries-6/+15
2025-09-08Minor symbol comment fixes.Nicholas Nethercote-7/+6
- 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-07Revert "Add LSX accelerated implementation for source file analysis"WANG Rui-107/+3
This reverts commit 5b43244ac59119870c9e0f6b642340ab88355b23 to fix native build failures on LoongArch.
2025-09-04Rollup merge of #145690 - sayantn:integer-funnel-shift, r=tgross35Jacob Pratt-0/+2
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-04Rollup merge of #145963 - heiher:src-analysis-lsx, r=lqdStuart Cook-3/+107
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-04Rollup merge of #145932 - JamieCunliffe:target-feature-inlining, r=jackh726Stuart Cook-0/+1
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-03Add `funnel_sh{l,r}` functions and intrinsicssayantn-0/+2
- Add a fallback implementation for the intrinsics - Add LLVM backend support for funnel shifts Co-Authored-By: folkertdev <folkert@folkertdev.nl>
2025-09-02Add LSX accelerated implementation for source file analysisWANG Rui-3/+107
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-02Revert introduction of `[workspace.dependencies]`.Nicholas Nethercote-4/+4
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-08-29Rollup merge of #145756 - okaneco:stabilize_char_boundary, r=scottmcmTrevor Gross-1/+1
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-29Rollup merge of #145947 - nnethercote:workspace-members-2, r=KobzolStuart Cook-3/+3
Add more to the `[workspace.dependencies]` section in the top-level `Cargo.toml` Following on from rust-lang/rust#145740. r? `@Kobzol`
2025-08-28Rollup merge of #142472 - GuillaumeGomez:doc-attribute-attribute, r=fmeaseGuillaume Gomez-0/+1
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-28Add new `doc(attribute = "...")` attributeGuillaume Gomez-0/+1
2025-08-28Add `scoped-tls` to `[workspace.dependencies]`.Nicholas Nethercote-1/+1
2025-08-28Add `derive-where` to `[workspace.dependencies]`.Nicholas Nethercote-1/+1
2025-08-28Add `indexmap` to `[workspace.dependencies]`.Nicholas Nethercote-1/+1
2025-08-27Port the `#[link]` attribute to the new parserJonathan Brouwer-0/+10
2025-08-27inline at the callsite & warn when target features mismatchJames Barford-Evans-0/+1
Co-authored-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
2025-08-27Add `tracing` to `[workspace.dependencies]`.Nicholas Nethercote-1/+1
2025-08-26Rollup merge of #145840 - a4lg:riscv-elf-flags-for-internal-objs, r=WaffleLapkinSamuel Tardieu-0/+2
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-26rustc_codegen_ssa: More comprehensive RISC-V ELF flagsTsukasa OI-0/+2
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-25Do not open every source file twice when reading itJakub Beránek-2/+8
2025-08-22Rollup merge of #145726 - aapoalas:reborrow-lang-experiment, r=petrochenkovJacob Pratt-0/+1
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-22Rollup merge of #145573 - veluca93:unsafe-force-target-feature, r=davidtwcoJacob Pratt-0/+2
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-22Rollup merge of #144897 - fee1-dead-contrib:raw_lifetimes_printing, r=fmeaseJacob Pratt-13/+61
print raw lifetime idents with r# This replaces rust-lang/rust#143185 and fixes rust-lang/rust#143150 cc ``@fmease``
2025-08-22Auto merge of #145494 - cjgillot:span-decode-once, r=lqdbors-10/+9
Only unpack span data once to compute end_point and next_point. Split from https://github.com/rust-lang/rust/pull/144930
2025-08-22Stabilize `round_char_boundary` featureokaneco-1/+1
2025-08-22address review commentsDeadbeef-4/+8
2025-08-22print raw lifetime idents with `r#`Deadbeef-13/+57
2025-08-22Add an experimental unsafe(force_target_feature) attribute.Luca Versari-0/+2
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-21Introduce Reborrow lang item and traitAapo Alasuutari-0/+1
2025-08-20Auto merge of #144086 - clubby789:alloc-zeroed, r=nikicbors-0/+1
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-20Pass `alloc-variant-zeroed` to LLVMclubby789-0/+1
2025-08-19Rollup merge of #145505 - cjgillot:tweak-span-cache, r=petrochenkov许杰友 Jieyou Xu (Joe)-16/+14
Simplify span caches Split from https://github.com/rust-lang/rust/pull/143882 r? `@petrochenkov`
2025-08-19Rollup merge of #142681 - 1c3t3a:sanitize-off-on, r=rcvalleStuart Cook-0/+1
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-18Remove the no_sanitize attribute in favor of sanitizeBastian Kersting-0/+1
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-18Rollup merge of #145208 - joshtriplett:mbe-derive, r=petrochenkovStuart Cook-0/+1
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-18Rollup merge of #145206 - scrabsha:push-uxovoqzrxnlx, r=jdonszelmannStuart Cook-0/+8
Port `#[custom_mir(..)]` to the new attribute system r? ``````````@jdonszelmann``````````
2025-08-16Only unpack span data once.Camille Gillot-7/+7
2025-08-16Simplify span_data_to_lines_and_cols.Camille Gillot-16/+14
2025-08-16Auto merge of #145304 - m-ou-se:simplify-panic, r=oli-obkbors-1/+1
Revert "Partially outline code inside the panic! macro". This reverts https://github.com/rust-lang/rust/pull/115670 Without any tests/benchmarks that show some improvement, it's hard to know whether the change had any positive effect. (And if it did, whether that effect is still achieved today.)
2025-08-15Rollup merge of #144922 - Kobzol:derive-from, r=nnethercoteJacob Pratt-0/+4
Implement `#[derive(From)]` Implements the `#[derive(From)]` feature ([tracking issue](https://github.com/rust-lang/rust/issues/144889), [RFC](https://github.com/rust-lang/rfcs/pull/3809)). It allows deriving the `From` impl on structs and tuple structs with exactly one field. Some implementation notes: - I wasn't exactly sure which spans to use in the derive generating code, so I just used `span` everywhere. I don't know if it's the Right Thing To Do. In particular the errors when `#[derive(From)]` is used on a struct with an unsized field are weirdly duplicated. - I had to solve an import stability problem, where if I just added the unstable `macro From` to `core::convert`, previously working code like `use std::convert::From` would suddenly require an unstable feature gate, because rustc would think that you're trying to import the unstable macro. `@petrochenkov` suggested that I add the macro the the core prelude instead. This has worked well, although it only works in edition 2021+. Not sure if I botched the prelude somehow and it should live elsewhere (?). - I had to add `Ty::AstTy`, because the `from` function receives an argument with the type of the single field, and the existing variants of the `Ty` enum couldn't represent an arbitrary type.
2025-08-15Implement `#[derive(From)]`Jakub Beránek-0/+3
2025-08-15Add `derive_from` unstable featureJakub Beránek-0/+1