about summary refs log tree commit diff
path: root/compiler/rustc_ast/src
AgeCommit message (Collapse)AuthorLines
2025-09-29Use `Iterator::eq` and (dogfood) `eq_by` in compiler and libraryYotam Ofek-5/+3
2025-09-19Add TypeTree metadata attachment for autodiffKaran Janthe-0/+1
- Add F128 support to TypeTree Kind enum - Implement TypeTree FFI bindings and conversion functions - Add typetree.rs module for metadata attachment to LLVM functions - Integrate TypeTree generation with autodiff intrinsic pipeline - Support scalar types: f32, f64, integers, f16, f128 - Attach enzyme_type attributes as LLVM string metadata for Enzyme Signed-off-by: Karan Janthe <karanjanthe@gmail.com>
2025-09-19autodiff: Add basic TypeTree with NoTT flagKaran Janthe-3/+14
Signed-off-by: Karan Janthe <karanjanthe@gmail.com>
2025-09-09c-variadic: reject functions with unsupported extern ABIFolkert de Vries-0/+5
2025-09-09c-variadic: reject non-unsafe functionsFolkert de Vries-0/+23
2025-09-08Refactor how to get the span of a function headerFolkert de Vries-36/+31
2025-09-04Rollup merge of #146090 - Kobzol:invisible-origin-eq, r=petrochenkovStuart Cook-17/+3
Derive `PartialEq` for `InvisibleOrigin` For https://github.com/rust-lang/rust/pull/145354, we need `PartialEq` for `TokenStream` to "just work". However, due to the special comparison implementation that was used for `InvisibleOrigin`, this wasn't the case. So I derived `PartialEq` for `InvisibleOrigin`, and used the previous special comparison logic only on the single place where it was actually required. r? `````````@petrochenkov`````````
2025-09-02Rollup merge of #145783 - Erk-:et-cetera-span, r=compiler-errorsGuillaume Gomez-3/+3
add span to struct pattern rest (..) Struct pattern rest (`..`) did not retain span information compared to normal fields. This patch adds span information for it. The motivation of this patch comes from when I implemented this PR for Clippy: https://github.com/rust-lang/rust-clippy/pull/15000#discussion_r2134145163 It is possible to get the span of the Et cetera in a bit roundabout way, but I thought this would be nicer.
2025-09-02Remove special implementation of `PartialEq` for `InvisibleOrigin` outside ↵Jakub Beránek-17/+3
macro matching
2025-08-29Put `TokenStream` stuff in a sensible order.Nicholas Nethercote-67/+65
I.e. the type definition, then a single inherent `impl` block, then the trait `impl` blocks. The lack of sensible ordering here has bugged me for some time.
2025-08-29Remove very outdated comment about token streams.Nicholas Nethercote-9/+0
They're now just an `Arc<Vec<TokenTree>>`. No ropes, no views, nothing like that.
2025-08-25add span to struct pattern rest (..)Valdemar Erk-3/+3
2025-08-22print raw lifetime idents with `r#`Deadbeef-6/+16
2025-08-21Rollup merge of #145590 - nnethercote:ModKind-Inline, r=petrochenkovJacob Pratt-2/+2
Prevent impossible combinations in `ast::ModKind`. `ModKind::Loaded` has an `inline` field and a `had_parse_error` field. If the `inline` field is `Inline::Yes` then `had_parse_error` must be `Ok(())`. This commit moves the `had_parse_error` field into the `Inline::No` variant. This makes it impossible to create the nonsensical combination of `inline == Inline::Yes` and `had_parse_error = Err(_)`. r? ```@Urgau```
2025-08-20Auto merge of #145348 - nnethercote:parse_token_tree-speedup-for-uom, ↵bors-0/+6
r=petrochenkov Sometimes skip over tokens in `parse_token_tree`. r? `@petrochenkov`
2025-08-19Prevent impossible combinations in `ast::ModKind`.Nicholas Nethercote-2/+2
`ModKind::Loaded` has an `inline` field and a `had_parse_error` field. If the `inline` field is `Inline::Yes` then `had_parse_error` must be `Ok(())`. This commit moves the `had_parse_error` field into the `Inline::No` variant. This makes it impossible to create the nonsensical combination of `inline == Inline::Yes` and `had_parse_error = Err(_)`.
2025-08-14Sometimes skip over tokens in `parse_token_tree`.Nicholas Nethercote-0/+6
This sometimes avoids a lot of `bump` calls.
2025-08-11Extract ast TraitImplHeaderCameron Steffen-10/+20
2025-08-09remove `P`Deadbeef-216/+197
2025-07-31Deduplicate `IntTy`/`UintTy`/`FloatTy`.Nicholas Nethercote-103/+4
There are identical definitions in `rustc_type_ir` and `rustc_ast`. This commit removes them and places a single definition in `rustc_ast_ir`. This requires adding `rust_span` as a dependency of `rustc_ast_ir`, but means a bunch of silly conversion functions can be removed. The one annoying wrinkle is that the old version had differences in their `Debug` impls, e.g. one printed `u32` while the other printed `U32`. Some compiler error messages rely on the former (yuk), and some clippy output depends on the latter. So the commit also changes clippy to not rely on `Debug` and just implement what it needs itself.
2025-07-26Don't lint against named labels in `naked_asm!`Amanieu d'Antras-1/+1
Naked functions are allowed to define global labels, just like `global_asm!`.
2025-07-22Implement AST visitors using a derive macro.Camille GILLOT-1676/+1127
2025-07-17Auto merge of #143879 - fee1-dead-contrib:push-lrlpoouyqqry, r=fmeasebors-1/+3
parse `const trait Trait` r? oli-obk or anyone from project-const-traits cc `@rust-lang/project-const-traits`
2025-07-17parse `const trait Trait`Deadbeef-1/+3
2025-07-17Rollup merge of #143631 - hkBst:update-escaper-2, r=compiler-errorsMatthias Krüger-3/+3
update to literal-escaper-0.0.5 Quoting from the changelog, this version brings: - Use `NonZero<char/u8>` in `unescape_c_str` and `check_raw_c_str` to statically exclude nuls - Add `#[inline]` to small functions for improved performance
2025-07-17Improve path segment joining.Nicholas Nethercote-1/+54
There are many places that join path segments with `::` to produce a string. A lot of these use `join("::")`. Many in rustdoc use `join_with_double_colon`, and a few use `.joined("..")`. One in Clippy uses `itertools::join`. A couple of them look for `kw::PathRoot` in the first segment, which can be important. This commit introduces `rustc_ast::join_path_{syms,ident}` to do the joining for everyone. `rustc_ast` is as good a location for these as any, being the earliest-running of the several crates with a `Path` type. Two functions are needed because `Ident` printing is more complex than simple `Symbol` printing. The commit also removes `join_with_double_colon`, and `estimate_item_path_byte_length` with it. There are still a handful of places that join strings with "::" that are unchanged. They are not that important: some of them are in tests, and some of them first split a path around "::" and then rejoin with "::". This fixes one test case where `{{root}}` shows up in an error message.
2025-07-15Define datastructures for `#[cfg]` attribute, move StrippedCfgItemJonathan Brouwer-17/+0
2025-07-12Port `#[automatically_derived]` to the new attribute parsing infrastructureJonathan Brouwer-0/+5
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-08update to literal-escaper-0.0.5Marijn Schouten-3/+3
2025-07-06compiler: rename {ast,hir}::BareFn* to FnPtr*Jubilee Young-6/+6
Fix some comments and related types and locals where it is obvious, e.g. - bare_fn -> fn_ptr - LifetimeBinderKind::BareFnType -> LifetimeBinderKind::FnPtrType Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
2025-07-05Complete mut_visit.Camille GILLOT-11/+79
2025-07-04Rollup merge of #143380 - cjgillot:kw_span, r=compiler-errorsJacob Pratt-7/+5
Replace kw_span by full span for generic const parameters. Small simplification extracted from https://github.com/rust-lang/rust/pull/127241
2025-07-03Replace kw_span by full span.Camille GILLOT-7/+5
2025-07-03Rollup merge of #134006 - klensy:typos, r=nnethercoteJana Dönszelmann-2/+2
setup typos check in CI This allows to check typos in CI, currently for compiler only (to reduce commit size with fixes). With current setup, exclude list is quite short, so it worth trying? Also includes commits with actual typo fixes. MCP: https://github.com/rust-lang/compiler-team/issues/817 typos check currently turned for: * ./compiler * ./library * ./src/bootstrap * ./src/librustdoc After merging, PRs which enables checks for other crates (tools) can be implemented too. Found typos will **not break** other jobs immediately: (tests, building compiler for perf run). Job will be marked as red on completion in ~ 20 secs, so you will not forget to fix it whenever you want, before merging pr. Check typos: `python x.py test tidy --extra-checks=spellcheck` Apply typo fixes: `python x.py test tidy --extra-checks=spellcheck:fix` (in case if there only 1 suggestion of each typo) Current fail in this pr is expected and shows how typo errors emitted. Commit with error will be removed after r+.
2025-07-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-2/+2
2025-07-02Rollup merge of #142237 - benschulz:unused-parens-fn, r=fee1-deadMatthias Krüger-1/+15
Detect more cases of unused_parens around types With this change, more unused parentheses around bounds and types nested within bounds are detected.
2025-07-01Remove support for dyn*Michael Goulet-4/+2
2025-07-01Detect more cases of unused_parens around typesBenjamin Schulz-1/+15
2025-06-30Introduce `ByteSymbol`.Nicholas Nethercote-23/+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-28Remove unused feature gatesYotam Ofek-3/+0
2025-06-27Rollup merge of #139858 - oli-obk:new-const-traits-syntax, r=fee1-deadMatthias Krüger-3/+3
New const traits syntax This PR only affects the AST and doesn't actually change anything semantically. All occurrences of `~const` outside of libcore have been replaced by `[const]`. Within libcore we have to wait for rustfmt to be bumped in the bootstrap compiler. This will happen "automatically" (when rustfmt is run) during the bootstrap bump, as rustfmt converts `~const` into `[const]`. After this we can remove the `~const` support from the parser Caveat discovered during impl: there is no legacy bare trait object recovery for `[const] Trait` as that snippet in type position goes down the slice /array parsing code and will error r? ``@fee1-dead`` cc ``@nikomatsakis`` ``@traviscross`` ``@compiler-errors``
2025-06-27Rollup merge of #143065 - compiler-errors:enum-recovery, r=oli-obkGuillaume Gomez-5/+7
Improve recovery when users write `where:` Improve recovery of `where:`. Fixes https://github.com/rust-lang/rust/issues/143023 The erroneous suggestion was because we were seeing `:` then a type, which the original impl thought must be a struct field. Make this a bit more accurate by checking for a non-reserved ident (which should be a field name). Also, make a custom parser error for `where:` so we can continue parsing after the colon.
2025-06-26Add Ident::is_non_reserved_identMichael Goulet-5/+7
2025-06-26Change const trait bound syntax from ~const to [const]Oli Scherer-3/+3
2025-06-25make `tidy-alphabetical` use a natural sortFolkert de Vries-1/+1
2025-06-25Auto merge of #142997 - workingjubilee:rollup-6lxec87, r=workingjubileebors-0/+4
Rollup of 15 pull requests Successful merges: - rust-lang/rust#135731 (Implement parsing of pinned borrows) - rust-lang/rust#138780 (Add `#[loop_match]` for improved DFA codegen) - rust-lang/rust#142453 (Windows: make `read_dir` stop iterating after the first error is encountered) - rust-lang/rust#142633 (Error on invalid signatures for interrupt ABIs) - rust-lang/rust#142768 (Avoid a bitcast FFI call in transmuting) - rust-lang/rust#142825 (Port `#[track_caller]` to the new attribute system) - rust-lang/rust#142844 (Enable short-ice for Windows) - rust-lang/rust#142934 (Tweak `-Zmacro-stats` measurement.) - rust-lang/rust#142955 (Couple of test suite fixes for cg_clif) - rust-lang/rust#142977 (rustdoc: Don't mark `#[target_feature]` functions as ⚠) - rust-lang/rust#142980 (Reduce mismatched-lifetime-syntaxes suggestions to MaybeIncorrect) - rust-lang/rust#142982 (Corrected spelling mistake in c_str.rs) - rust-lang/rust#142983 (Taint body on invalid call ABI) - rust-lang/rust#142988 (Update wasm-component-ld to 0.5.14) - rust-lang/rust#142993 (Update cargo) r? `@ghost` `@rustbot` modify labels: rollup
2025-06-24Rollup merge of #135731 - frank-king:feature/pin-borrow, r=eholk,traviscrossJubilee-0/+4
Implement parsing of pinned borrows This PR implements part of #130494. EDIT: It introduces `&pin mut $place` and `&pin const $place` as sugars for `std::pin::pin!($place)` and its shared reference equivalent, except that `$place` will not be moved when borrowing. The borrow check will be in charge of enforcing places cannot be moved or mutably borrowed since being pinned till dropped. ### Implementation steps: - [x] parse the `&pin mut $place` and `&pin const $place` syntaxes - [ ] borrowck of `&pin mut|const` - [ ] support autoref of `&pin mut|const` when needed
2025-06-25Auto merge of #140999 - hkBst:update-escaper, r=nnethercotebors-8/+7
update to literal-escaper 0.0.4 for better API without `unreachable` and faster string parsing This is the replacement for just the part of https://github.com/rust-lang/rust/pull/138163 dealing with the changed API of unescape functionality, since that got moved into its own crate. <del>This uses an unpublished version of literal-escaper (https://github.com/rust-lang/literal-escaper/pull/8).</del> r? `@nnethercote`
2025-06-24Rollup merge of #142657 - tgross35:nonoptional-fragment-specifiers-cleanup, ↵Matthias Krüger-0/+1
r=petrochenkov mbe: Clean up code with non-optional `NonterminalKind` Since [rust-lang/rust#128425], the fragment specifier is unconditionally required in all editions. This means `NonTerminalKind` no longer needs to be optional, as we can reject this code during the expansion of `macro_rules!` rather than handling it throughout the code. Do this cleanup here. [rust-lang/rust#128425]: https://github.com/rust-lang/rust/pull/128425
2025-06-24mbe: Clean up code with non-optional `NonterminalKind`Trevor Gross-0/+1
Since [1], the fragment specifier is unconditionally required in all editions. This means `NonTerminalKind` no longer needs to be optional, as we can reject this code during the expansion of `macro_rules!` rather than handling it throughout the code. Do this cleanup here. [1]: https://github.com/rust-lang/rust/pull/128425