about summary refs log tree commit diff
path: root/compiler/rustc_hir
AgeCommit message (Collapse)AuthorLines
2025-08-18Rollup merge of #145206 - scrabsha:push-uxovoqzrxnlx, r=jdonszelmannStuart Cook-0/+20
Port `#[custom_mir(..)]` to the new attribute system r? ``````````@jdonszelmann``````````
2025-08-16Auto merge of #145304 - m-ou-se:simplify-panic, r=oli-obkbors-0/+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-15Port `#[custom_mir(..)]` to the new attribute systemSasha Pourcelot-0/+20
2025-08-14Remove the old target checking logicJonathan Brouwer-6/+8
2025-08-14Allow attribute parsers to specify a list of allowed targetsJonathan Brouwer-2/+3
Every acceptor gets an `ALLOWED_TARGETS` specification which can specify per target whether it is allowed, warned, or errored.
2025-08-14Improved `Target` typeJonathan Brouwer-10/+142
- Added a few more variants which are needed for various attributes - Previously a trait method with default block had the same target representation as a method in a `impl trait for` block, this has been changed (See `MethodKind`) - Added `plural_name` for more precision on the form of the name
2025-08-14Rollup merge of #145323 - scrabsha:push-pqwvmznzzmpr, r=jdonszelmannGuillaume Gomez-0/+23
Port the `#[linkage]` attribute to the new attribute system r? `@jdonszelmann`
2025-08-13Port the `#[linkage]` attribute to the new attribute systemSasha Pourcelot-0/+23
2025-08-13Rollup merge of #145153 - joshtriplett:macro-kinds-plural, r=petrochenkovGuillaume Gomez-10/+57
Handle macros with multiple kinds, and improve errors (I recommend reviewing this commit-by-commit.) Switch to a bitflags `MacroKinds` to support macros with more than one kind Review everything that uses `MacroKind`, and switch anything that could refer to more than one kind to use `MacroKinds`. Add a new `SyntaxExtensionKind::MacroRules` for `macro_rules!` macros, using the concrete `MacroRulesMacroExpander` type, and have it track which kinds it can handle. Eliminate the separate optional `attr_ext`, now that a `SyntaxExtension` can handle multiple macro kinds. This also avoids the need to downcast when calling methods on `MacroRulesMacroExpander`, such as `get_unused_rule`. Integrate macro kind checking into name resolution's `sub_namespace_match`, so that we only find a macro if it's the right type, and eliminate the special-case hack for attributes. This allows detecting and report macro kind mismatches early, and more precisely, improving various error messages. In particular, this eliminates the case in `failed_to_match_macro` to check for a function-like invocation of a macro with no function-like rules. Instead, macro kind mismatches now result in an unresolved macro, and we detect this case in `unresolved_macro_suggestions`, which now carefully distinguishes between a kind mismatch and other errors. This also handles cases of forward-referenced attributes and cyclic attributes. ---- In this PR, I've minimally fixed up `rustdoc` so that it compiles and passes tests. This is just the minimal necessary fixes to handle the switch to `MacroKinds`, and it only works for macros that don't actually have multiple kinds. This will panic (with a `todo!`) if it encounters a macro with multiple kinds. rustdoc needs further fixes to handle macros with multiple kinds, and to handle attributes and derive macros that aren't proc macros. I'd appreciate some help from a rustdoc expert on that. ---- r? ````````@petrochenkov````````
2025-08-12Switch to a bitflags `MacroKinds` to support macros with more than one kindJosh Triplett-10/+57
Review everything that uses `MacroKind`, and switch anything that could refer to more than one kind to use `MacroKinds`. Add a new `SyntaxExtensionKind::MacroRules` for `macro_rules!` macros, using the concrete `MacroRulesMacroExpander` type, and have it track which kinds it can handle. Eliminate the separate optional `attr_ext`, now that a `SyntaxExtension` can handle multiple macro kinds. This also avoids the need to downcast when calling methods on `MacroRulesMacroExpander`, such as `get_unused_rule`. Integrate macro kind checking into name resolution's `sub_namespace_match`, so that we only find a macro if it's the right type, and eliminate the special-case hack for attributes.
2025-08-12Revert "Partially outline code inside the panic! macro".Mara Bos-0/+1
Without any tests/benchmarks that show some improvement, it's hard to know whether the change had any positive effect at all. (And if it did, whether that effect is still achieved today.)
2025-08-12Rollup merge of #145155 - scrabsha:push-tkvwkolzooyq, r=jdonszelmannStuart Cook-0/+5
Port `#[allow_internal_unsafe]` to the new attribute system (attempt 2) This is a slightly modified version of ae1487aa9922de7642c448cc0908584026699e1c, which caused a performance regression (reverted in https://github.com/rust-lang/rust/pull/145086#issue-3303428759). The diff between this PR and the previous one can be seen in 027a1def. r? ```````@jdonszelmann``````` :sparkling_heart:
2025-08-11Propagate TraitImplHeader to hirCameron Steffen-25/+28
2025-08-11Port `#[allow_internal_unsafe]` to the new attribute system (attempt 2)Sasha Pourcelot-0/+5
2025-08-10Auto merge of #144873 - cjgillot:implications, r=lqdbors-0/+42
Implement `stability_implications` without a visitor. Since https://github.com/rust-lang/rust/pull/143845, the `Annotator` visitor was a no-op when the crate is not staged_api. This PR avoids using a visitor altogether, making `stability_implications` truly a no-op in most cases.
2025-08-08Revert "Port `#[allow_internal_unsafe]` to the new attribute system"Jana Dönszelmann-4/+0
This reverts commit 4f7a6ace9e2f2192af7b5d32f4b1664189e0e143.
2025-08-07Rollup merge of #144857 - scrabsha:push-pwtyrnmqkrtr, r=jdonszelmannTrevor Gross-0/+4
Port `#[allow_internal_unsafe]` to the new attribute system Related to https://github.com/rust-lang/rust/issues/131229#issue-2565886367. r? ````@jdonszelmann````
2025-08-07Port `#[allow_internal_unsafe]` to the new attribute systemSasha Pourcelot-0/+4
2025-08-07Rollup merge of #143808 - JonathanBrouwer:should_panic_parser, r=jdonszelmannStuart Cook-0/+5
Port `#[should_panic]` to the new attribute parsing infrastructure Ports `#[should_panic]` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971351163 r? ```@jdonszelmann```
2025-08-06Port `#[should_panic]` to the new attribute parsing infrastructureJonathan Brouwer-0/+5
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-04Add doc-comment.Camille GILLOT-0/+1
2025-08-04Port `#[coroutine]` to the new attribute systemSasha Pourcelot-0/+4
Related to https://github.com/rust-lang/rust/issues/131229#issue-2565886367.
2025-08-03Implement `stability_implications` without a visitor.Camille GILLOT-0/+41
2025-08-03Rollup merge of #144738 - bjorn3:remove_omit_gdb_pretty_printer_section, ↵Samuel Tardieu-4/+0
r=jieyouxu Remove the omit_gdb_pretty_printer_section attribute Disabling loading of pretty printers in the debugger itself is more reliable. Before this commit the .gdb_debug_scripts section couldn't be included in dylibs or rlibs as otherwise there is no way to disable the section anymore without recompiling the entire standard library.
2025-08-03Rollup merge of #142678 - BoxyUwU:gai_cleanup, r=nnethercoteSamuel Tardieu-24/+15
Misc cleanups of `generic_arg_infer` related HIR logic r? ````@nnethercote````
2025-08-02Rollup merge of #144478 - joshtriplett:doc-code-formatting-prep, r=AmanieuSamuel Tardieu-2/+2
Improve formatting of doc code blocks We don't currently apply automatic formatting to doc comment code blocks. As a result, it has built up various idiosyncracies, which make such automatic formatting difficult. Some of those idiosyncracies also make things harder for human readers or other tools. This PR makes a few improvements to doc code formatting, in the hopes of making future automatic formatting easier, as well as in many cases providing net readability improvements. I would suggest reading each commit separately, as each commit contains one class of changes.
2025-08-01Remove the omit_gdb_pretty_printer_section attributebjorn3-4/+0
Disabling loading of pretty printers in the debugger itself is more reliable. Before this commit the .gdb_debug_scripts section couldn't be included in dylibs or rlibs as otherwise there is no way to disable the section anymore without recompiling the entire standard library.
2025-08-01loop match: error on `#[const_continue]` outside `#[loop_match]`Folkert de Vries-1/+1
2025-07-31remove rustc_attr_data_structuresJana Dönszelmann-13/+1044
2025-07-29Rollup merge of #144578 - FractalFir:m68k_fix, r=compiler-errorsStuart Cook-0/+5
Ensure correct aligement of rustc_hir::Lifetime on platforms with lower default alignments. The compiler relies on `hir::Lifetime` being aligned to at least 4 bytes(for the purposes of pointer tagging). However, on some systems(like m68k) with lower alignment requirements(eg. usize / u32 aligned to 2 bytes),`hir::Lifetime` will be aligned to only 2 bytes. This causes the compilation to fail on those systems - a const assert in the compiler fails. This PR makes the aligement requriement of hir::Lifetime explict. This has no effect on platforms where that already is the case(repr align can only raise alignment), but ensures the alignment will stay correct no matter what.
2025-07-28Introduce assoc_parentCameron Steffen-0/+4
2025-07-27Ensure correct aligement of rustc_hir::Lifetime on platforms with lower ↵FractalFir-0/+5
default alignments.
2025-07-26Use the new attributes throughout the codebaseJonathan Brouwer-0/+11
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-25Improve and regularize comment placement in doc codeJosh Triplett-1/+1
Because doc code does not get automatically formatted, some doc code has creative placements of comments that automatic formatting can't handle. Reformat those comments to make the resulting code support standard Rust formatting without breaking; this is generally an improvement to readability as well. Some comments are not indented to the prevailing indent, and are instead aligned under some bit of code. Indent them to the prevailing indent, and put spaces *inside* the comments to align them with code. Some comments span several lines of code (which aren't the line the comment is about) and expect alignment. Reformat them into one comment not broken up by unrelated intervening code. Some comments are placed on the same line as an opening brace, placing them effectively inside the subsequent block, such that formatting would typically format them like a line of that block. Move those comments to attach them to what they apply to. Some comments are placed on the same line as a one-line braced block, effectively attaching them to the closing brace, even though they're about the code inside the block. Reformat to make sure the comment will stay on the same line as the code it's commenting.
2025-07-25Skip formatting for some compiler documentation codeJosh Triplett-1/+1
These examples feature Rust code that's presented primarily to illustrate how its compilation would be handled, and these examples are formatted to highlight those aspects in ways that rustfmt wouldn't preserve. Turn formatting off in those examples. (Doc code isn't formatted yet, but this will make it easier to enable doc code formatting in the future.)
2025-07-23Ports `#[macro_use]` and `#[macro_escape]` to the new attribute parsing ↵Jonathan Brouwer-0/+1
infrastructure
2025-07-20Remove the ptr_unique lang itembjorn3-3/+0
Miri no longer uses it.
2025-07-17Warn useless deprecation in check_attr.Camille GILLOT-6/+12
2025-07-17Specify of_trait in Target::Impl.Camille GILLOT-5/+6
2025-07-17Auto merge of #143879 - fee1-dead-contrib:push-lrlpoouyqqry, r=fmeasebors-6/+23
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-6/+23
2025-07-17Auto merge of #142903 - cjgillot:local-def-path-hash, r=compiler-errorsbors-4/+15
Only inherit local hash for paths `DefPathHash`, as the counterpart of `DefId` that is stable across compiler invocations, is comprised of 2 parts. The first one is the `StableCrateId`, stable form of `CrateNum`. The second is 64 complementary bits to identify the crate-local definition. The current implementation always hashes the full 128 bits when (1) trying to create a new child `DefPathHash` or (2) hashing a `CrateNum` or a `LocalDefId`. But we only need half that information: `LocalDefId` means that the `StableCrateId` is always the current crate's ; `CrateNum` means that we do not care about the local part. As stable hashing is very hot in the query system, in particular hashing definitions, this is a big deal. We still want the local part to change when the `StableCrateId` changes, to make incr-compilation errors less painful, ie. increase the likelihood that if will magically disappear by changing some code. This PR sprinkles some `#[inline]` attributes on small functions that appeared in profiles.
2025-07-17Use `join_path_syms` in one more place.Nicholas Nethercote-13/+7
This one is a bit marginal, because the segments are a mix of symbols and strings.
2025-07-17Improve path segment joining.Nicholas Nethercote-2/+2
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-16resolve: Merge `NameBindingKind::Module` into `NameBindingKind::Res`Vadim Petrochenkov-0/+15
2025-07-14Auto merge of #143779 - JonathanBrouwer:automatically_derived_parser, r=oli-obkbors-0/+6
Port `#[automatically_derived]` to the new attribute parsing infrastructure Ports `#[automatically_derived]` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971351163 r? `@oli-obk` cc `@jdonszelmann`
2025-07-13Retire hir::*ItemRef.Camille GILLOT-47/+11
2025-07-13Retire hir::ForeignItemRef.Camille GILLOT-24/+6
2025-07-13Remove hir::AssocItemKind.Camille GILLOT-25/+4
2025-07-13Move trait_item_def_id from ImplItemRef to ImplItem.Camille GILLOT-4/+5