about summary refs log tree commit diff
path: root/compiler/rustc_span/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2025-09-28Add LSX accelerated implementation for source file analysisWANG Rui-0/+1
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-26Apply cfg(bootstrap) replacementMark Rousskov-1/+0
2025-09-05Some hygiene doc improvementsCameron Steffen-2/+2
2025-08-22Stabilize `round_char_boundary` featureokaneco-1/+1
2025-08-06Introduce ModernIdent type to unify macro 2.0 hygiene handlingxizheyin-1/+2
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-29Create two methods to fix `find_oldest_ancestor_in_same_ctxt`xizheyin-36/+46
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-24Inline some methods in rustc_span hygienexizheyin-0/+1
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-1/+1
2025-07-01Update `cfg(bootstrap)`Josh Stone-2/+1
2025-06-30Introduce `ByteSymbol`.Nicholas Nethercote-6/+30
It's like `Symbol` but for byte strings. The interner is now used for both `Symbol` and `ByteSymbol`. E.g. if you intern `"dog"` and `b"dog"` you'll get a `Symbol` and a `ByteSymbol` with the same index and the characters will only be stored once. The motivation for this is to eliminate the `Arc`s in `ast::LitKind`, to make `ast::LitKind` impl `Copy`, and to avoid the need to arena-allocate `ast::LitKind` in HIR. The latter change reduces peak memory by a non-trivial amount on literal-heavy benchmarks such as `deep-vector` and `tuple-stress`. `Encoder`, `Decoder`, `SpanEncoder`, and `SpanDecoder` all get some changes so that they can handle normal strings and byte strings. This change does slow down compilation of programs that use `include_bytes!` on large files, because the contents of those files are now interned (hashed). This makes `include_bytes!` more similar to `include_str!`, though `include_bytes!` contents still aren't escaped, and hashing is still much cheaper than escaping.
2025-06-11Do not clone Arc when hashing span.Camille GILLOT-2/+2
2025-06-08Remove all unused feature gates from the compilerbjorn3-1/+0
2025-05-30handle cfg bootstrap on compiler and mirionur-ozkan-1/+2
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-05-20Rename `cfg_match!` to `cfg_select!`Trevor Gross-1/+1
At [1] it was pointed out that `cfg_match!` syntax does not actually align well with match syntax, which is a possible source of confusion. The comment points out that usage is instead more similar to ecosystem `select!` macros. Rename `cfg_match!` to `cfg_select!` to match this. Tracking issue: https://github.com/rust-lang/rust/issues/115585 [1]: https://github.com/rust-lang/rust/issues/115585#issuecomment-2346307605
2025-05-12update cfg(bootstrap)Pietro Albini-1/+0
2025-05-07Rollup merge of #140419 - Jarcho:ctxt_external, r=NadrierilJacob Pratt-18/+3
Move `in_external_macro` to `SyntaxContext` There are a few places in clippy where spans are passed solely to use the context, but we can't pass just the context around because of this function.
2025-05-05Take into-account `-Zremap-path-scope` when embedding filenamesUrgau-23/+11
2025-04-28Move `in_external_macro` to `SyntaxContext`Jason Newcomb-18/+3
2025-04-28Rollup merge of #139656 - scottmcm:stabilize-slice-as-chunks, r=dtolnayChris Denton-1/+0
Stabilize `slice_as_chunks` library feature ~~Draft as this needs #139163 to land first.~~ FCP: https://github.com/rust-lang/rust/issues/74985#issuecomment-2769963395 Methods being stabilized are: ```rust impl [T] { const fn as_chunks<const N: usize>(&self) -> (&[[T; N]], &[T]); const fn as_rchunks<const N: usize>(&self) -> (&[T], &[[T; N]]); const unsafe fn as_chunks_unchecked<const N: usize>(&self) -> &[[T; N]]; const fn as_chunks_mut<const N: usize>(&mut self) -> (&mut [[T; N]], &mut [T]); const fn as_rchunks_mut<const N: usize>(&mut self) -> (&mut [T], &mut [[T; N]]); const unsafe fn as_chunks_unchecked_mut<const N: usize>(&mut self) -> &mut [[T; N]]; } ``` ~~(FCP's not done quite yet, but will in another day if I'm counting right.)~~ FCP Complete: https://github.com/rust-lang/rust/issues/74985#issuecomment-2797951535
2025-04-23Make #![feature(let_chains)] bootstrap conditional in compiler/est31-1/+1
2025-04-17Rollup merge of #139084 - petrochenkov:transpaque, r=davidtwcoMatthias Krüger-1/+1
hygiene: Rename semi-transparent to semi-opaque "Semi-transparent" is just too damn long for a name, especially when used multiple times on a single line, it bothered me when working on #139083. An optimist sees a macro as semi-opaque, a pessimist sees it as semi-transparent. Or is it the other way round?
2025-04-10Stabilize `slice_as_chunks` library featureScott McMurray-1/+0
2025-04-11Rollup merge of #138682 - Alexendoo:extra-symbols, r=fee1-deadStuart Cook-5/+10
Allow drivers to supply a list of extra symbols to intern Allows adding new symbols as `const`s in external drivers, desirable in Clippy so we can use them in patterns to replace code like https://github.com/rust-lang/rust/blob/75530e9f72a1990ed2305e16fd51d02f47048f12/src/tools/clippy/clippy_lints/src/casts/cast_ptr_alignment.rs#L66 The Clippy change adds a couple symbols as a demo, the exact `clippy_utils` API and replacing other usages can be done on the Clippy side to minimise sync conflicts --- try-job: aarch64-gnu
2025-04-10Allow drivers to supply a list of extra symbols to internAlex Macleod-5/+10
2025-03-31hygiene: Rename semi-transparent to semi-opaqueVadim Petrochenkov-1/+1
The former is just too long, see the examples in `hygiene.rs`
2025-03-28use `slice::contains` where applicableYotam Ofek-1/+1
2025-03-11Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
It's no longer necessary now that `-Wunreachable_pub` is being passed.
2025-03-10Revert "Use workspace lints for crates in `compiler/` #138084"许杰友 Jieyou Xu (Joe)-0/+1
Revert <https://github.com/rust-lang/rust/pull/138084> to buy time to consider options that avoids breaking downstream usages of cargo on distributed `rustc-src` artifacts, where such cargo invocations fail due to inability to inherit `lints` from workspace root manifest's `workspace.lints` (this is only valid for the source rust-lang/rust workspace, but not really the distributed `rustc-src` artifacts). This breakage was reported in <https://github.com/rust-lang/rust/issues/138304>. This reverts commit 48caf81484b50dca5a5cebb614899a3df81ca898, reversing changes made to c6662879b27f5161e95f39395e3c9513a7b97028.
2025-03-08Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
(Except for `rustc_codegen_cranelift`.) It's no longer necessary now that `unreachable_pub` is in the workspace lints.
2025-03-04Also note struct access, and fix macro expansion from foreign cratesMichael Goulet-2/+10
2025-03-03Point of macro expansion from call expr if it involves macro varMichael Goulet-0/+23
2025-02-23Use `as_chunks` in `analyze_source_file_sse2`real-eren-0/+1
2025-02-22Fix binding mode problemsMichael Goulet-2/+2
2025-02-16Move hashes from rustc_data_structure to rustc_hashes so they can be shared ↵Ben Kimock-1/+2
with rust-analyzer
2025-02-03tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc`Askar Safin-12/+13
2025-02-02Convert two `rustc_middle::lint` functions to `Span` methods.Nicholas Nethercote-0/+32
`rustc_middle` is a huge crate and it's always good to move stuff out of it. There are lots of similar methods already on `Span`, so these two functions, `in_external_macro` and `is_from_async_await`, fit right in. The diff is big because `in_external_macro` is used a lot by clippy lints.
2025-01-22Auto merge of #134478 - compiler-errors:attr-span, r=oli-obkbors-6/+39
Properly record metavar spans for other expansions other than TT This properly records metavar spans for nonterminals other than tokentree. This means that we operations like `span.to(other_span)` work correctly for macros. As you can see, other diagnostics involving metavars have improved as a result. Fixes #132908 Alternative to #133270 cc `@ehuss` cc `@petrochenkov`
2025-01-19Rename FileName::QuoteExpansion to CfgSpecEric Huss-5/+5
I believe this variant name was used incorrectly. The timeline is roughly: * `FileName::cfg_spec_source_code` was added in https://github.com/rust-lang/rust/pull/54517. However, it used `FileName::Quote` instead of `FileName::CfgSpec` which I believe was a mistake. * Quote stuff was removed in https://github.com/rust-lang/rust/pull/51285, but did not remove `FileName::Quote`. * `FileName::CfgSpec` was removed in https://github.com/rust-lang/rust/pull/116474 because it was unused. This restores it so that the `--cfg` variant uses a name that makes more sense with how it is used, and restores what I think is the original intent.
2025-01-08Add a list of symbols for stable standard library cratesTrevor Gross-1/+1
There are a few locations where the crate name is checked against an enumerated list of `std`, `core`, `alloc`, and `proc_macro`, or some subset thereof. In most of these cases, all four crates should likely be treated the same. Change this so the crates are listed in one place, and that list is used wherever a list of `std` crates is needed. `test` could be considered relevant in some of these cases, but generally treating it separate from the others seems preferable while it is unstable. There are also a few places that Clippy will be able to use this.
2024-12-21Hash only the spans that we care ended up reading in Span::try_metavarsMichael Goulet-14/+35
2024-12-21Hash the untracked macro variable expansionsMichael Goulet-5/+17
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-1/+1
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-12-13Remove support for specializing ToString outside the standard librarybjorn3-1/+0
This is the only trait specializable outside of the standard library. Before stabilizing specialization we will probably want to remove support for this. It was originally made specializable to allow a more efficient ToString in libproc_macro back when this way the only way to get any data out of a TokenStream. We now support getting individual tokens, so proc macros no longer need to call it as often.
2024-12-12Auto merge of #129181 - beetrees:asm-spans, r=pnkfelix,compiler-errorsbors-0/+6
Pass end position of span through inline ASM cookie Before this PR, only the start position of the span was passed though the inline ASM cookie to diagnostics. LLVM 19 has full support for 64-bit inline ASM cookies; this PR uses that to pass the end position of the span in the upper 32 bits, meaning inline ASM diagnostics now point at the entire line the error occurred on, not just the first character of it.
2024-12-06Remove all threading through of ErrorGuaranteed from the driverbjorn3-0/+5
It was inconsistently done (sometimes even within a single function) and most of the rest of the compiler uses fatal errors instead, which need to be caught using catch_with_exit_code anyway. Using fatal errors instead of ErrorGuaranteed everywhere in the driver simplifies things a bit.
2024-11-27rustc_span: Replace a `HashMap<_, ()>` with `HashSet`Josh Stone-0/+1
Now that `HashSet::entry()` exists, we don't need to fake it with a map.
2024-11-26Pass end position of span through inline ASM cookiebeetrees-0/+6
2024-11-24Auto merge of #132791 - tyilo:big-file-fail-fast, r=compiler-errorsbors-0/+5
rustc: Fail fast when compiling a source file larger than 4 GiB Currently if you try to compile a file that is larger than 4 GiB, `rustc` will first read the whole into memory before failing. If we can read the metadata of the file, we can fail before reading the file.
2024-11-23rustc: Fail fast when compiling a source file larger than 4 GiB - 1 BAsger Hautop Drewsen-0/+5
Fixes #132862
2024-11-14Rollup merge of #128197 - Alexendoo:span-ctxt, r=davidtwcoMatthias Krüger-6/+0
Skip locking span interner for some syntax context checks - `from_expansion` now never needs to consult the interner - `eq_ctxt` now only needs the interner when both spans are fully interned