about summary refs log tree commit diff
path: root/compiler/rustc_hir
AgeCommit message (Collapse)AuthorLines
2025-09-13Rollup merge of #146389 - jdonszelmann:no-std, r=oli-obkJana Dönszelmann-1/+9
Convert `no_std` and `no_core` to the new attribute infrastructure r? ```@oli-obk``` Also added a test for these, since we didn't have any and I was kind of surprised new diagnostics didn't break anything hehe
2025-09-12Auto merge of #146328 - zetanumbers:fix-141951, r=lcnrbors-0/+37
Skip typeck for items w/o their own typeck context Skip items which forward typeck to their ancestor. Should remove some potential but unnecessary typeck query waits, hence might improve performance for the parallel frontend. Thanks to `@ywxt` for a fix suggestion Fixes rust-lang/rust#141951
2025-09-10Rollup merge of #144765 - Qelxiros:range-inclusive-last, r=jhprattMatthias Krüger-1/+15
inclusive `Range`s: change `end` to `last` Tracking issue: rust-lang/rust#125687 ACP: rust-lang/libs-team#511
2025-09-09port `#[no_std]` to the new attribute parsing infrastructureJana Dönszelmann-1/+5
2025-09-09port `#[no_core]` to the new attribute parsing infrastructureJana Dönszelmann-0/+4
2025-09-08change end to lastJeremy Smart-1/+15
2025-09-08fixup limit handling codeJana Dönszelmann-6/+73
2025-09-08port `#[pattern_complexity_limit]` to the new attribute parsing infrastructureJana Dönszelmann-0/+4
2025-09-08port `#[type_length_limit]` to the new attribute parsing infrastructureJana Dönszelmann-0/+4
2025-09-08port `#[move_size_limit]` to the new attribute parsing infrastructureJana Dönszelmann-0/+4
2025-09-08port `#[recursion_limit]` to the new attribute parsing infrastructureJana Dönszelmann-1/+5
2025-09-08Make `is_typeck_child` match exhaustiveDaria Sukhonina-1/+31
2025-09-08Skip typeck for items w/o their own typeck contextDaria Sukhonina-0/+7
More details on about this fix: https://rust-lang.zulipchat.com/#narrow/channel/187679-t-compiler.2Fparallel-rustc/topic/ICE.3A.20typecks.20AnonConst.20under.20parallel.20rustc.28.23141951.29/with/538200980 Co-authored-by: ywxt <ywxtcwh@gmail.com>
2025-09-02Rollup merge of #146102 - fmease:rm-dead-eff-code-iii, r=fee1-deadGuillaume Gomez-2/+1
Remove dead code stemming from an old effects desugaring CC https://github.com/rust-lang/rust/pull/132374, https://github.com/rust-lang/rust/pull/133443. r? fee1-dead
2025-09-02Rollup merge of #145783 - Erk-:et-cetera-span, r=compiler-errorsGuillaume Gomez-4/+4
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-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-09-01Remove dead code stemming from an old effects desugaringLeón Orell Valerian Liehr-2/+1
2025-08-29Rollup merge of #145947 - nnethercote:workspace-members-2, r=KobzolStuart Cook-1/+1
Add more to the `[workspace.dependencies]` section in the top-level `Cargo.toml` Following on from rust-lang/rust#145740. r? `@Kobzol`
2025-08-28Add `odht` to `[workspace.dependencies]`.Nicholas Nethercote-1/+1
2025-08-27Port the `#[link]` attribute to the new parserJonathan Brouwer-0/+15
2025-08-27Move `NativeLibKind` from `rustc_session` to `rustc_hir`Jonathan Brouwer-0/+103
2025-08-27Add `tracing` to `[workspace.dependencies]`.Nicholas Nethercote-1/+1
2025-08-27Add `bitflags` to `[workspace.dependencies]`.Nicholas Nethercote-1/+1
2025-08-27Add `thin-vec` to newly added `[workspace.dependencies]`.Nicholas Nethercote-1/+1
2025-08-25Use attribute name in message for "outer attr used as inner attr" errorsSasha Pourcelot-0/+1
2025-08-25add span to struct pattern rest (..)Valdemar Erk-4/+4
2025-08-24Port crate name to the new attribute systemJana Dönszelmann-0/+9
2025-08-23port attribute to the new parsing infrastructureJana Dönszelmann-1/+20
2025-08-22Rollup merge of #145726 - aapoalas:reborrow-lang-experiment, r=petrochenkovJacob Pratt-0/+3
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-3/+4
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-22Add an experimental unsafe(force_target_feature) attribute.Luca Versari-3/+4
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/+3
2025-08-21refactor target checking, move out of context.rs and rename MaybeWarn to PolicyJana Dönszelmann-3/+3
2025-08-21impl IntoDiagArg for AttrPathJana Dönszelmann-0/+6
2025-08-20Split `rustc_hir_id` out of `rustc_hir`Josh Triplett-198/+3
Some crates depend on `rustc_hir` but only want `HirId` and similar id types. `rustc_hir` is a heavy dependency, since it pulls in `rustc_target`. Split these types out into their own crate `rustc_hir_id`. This allows `rustc_errors` to drop its direct dependency on `rustc_hir`. (`rustc_errors` still depends on `rustc_hir` indirectly through `rustc_lint_defs`; a subsequent commit will fix that.)
2025-08-20Move `IntoDiagArg` earlier in the dependency chainsJosh Triplett-2/+62
`rustc_errors` depends on numerous crates, solely to implement its `IntoDiagArg` trait on types from those crates. Many crates depend on `rustc_errors`, and it's on the critical path. We can't swap things around to make all of those crates depend on `rustc_errors` instead, because `rustc_errors` would end up in dependency cycles. Instead, move `IntoDiagArg` into `rustc_error_messages`, which has far fewer dependencies, and then have most of these crates depend on `rustc_error_messages`. This allows `rustc_errors` to drop dependencies on several crates, including the large `rustc_target`. (This doesn't fully reduce dependency chains yet, as `rustc_errors` still depends on `rustc_hir` which depends on `rustc_target`. That will get fixed in a subsequent commit.)
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