about summary refs log tree commit diff
path: root/compiler/rustc_passes/src
AgeCommit message (Collapse)AuthorLines
2025-08-16Only scan each definition once.Camille GILLOT-13/+16
2025-08-15Port `#[custom_mir(..)]` to the new attribute systemSasha Pourcelot-4/+70
2025-08-14Remove the old target checking logicJonathan Brouwer-1132/+109
2025-08-14Improved `Target` typeJonathan Brouwer-1/+1
- 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-3/+5
Port the `#[linkage]` attribute to the new attribute system r? `@jdonszelmann`
2025-08-14Rollup merge of #145266 - camsteffen:reduce-queries, r=petrochenkovGuillaume Gomez-1/+1
Reduce some queries around associated items
2025-08-13Port the `#[linkage]` attribute to the new attribute systemSasha Pourcelot-3/+5
2025-08-13Cleanup assoc parent utilsCameron Steffen-1/+1
2025-08-13Rollup merge of #145274 - compiler-errors:unused-must-use, r=fmeaseJakub Beránek-1/+3
Remove unused `#[must_use]` Self-explanatory Fixes https://github.com/rust-lang/rust/issues/145257
2025-08-12Remove unused must_useMichael Goulet-1/+3
2025-08-12Auto merge of #144678 - jdonszelmann:no-mangle-extern, r=bjorn3bors-21/+22
Make no_mangle on foreign items explicit instead of implicit for a followup PR I'm working on I need some foreign items to mangle. I could add a new attribute: `no_no_mangle` or something silly like that but by explicitly putting `no_mangle` in the codegen fn attrs of foreign items we can default it to `no_mangle` and then easily remove it when we don't want it. I guess you'd know about this r? `@bjorn3.` Shouldn't be too hard to review :) Builds on rust-lang/rust#144655 which should merge first.
2025-08-12Rollup merge of #145251 - tiif:support_trait, r=BoxyUwUStuart Cook-2/+1
Support using #[unstable_feature_bound] on trait This is needed to unblock https://github.com/rust-lang/rust/pull/145095 r? ```````@BoxyUwU```````
2025-08-12Rollup merge of #145214 - notJoon:fix/enable-self-assignment, r=petrochenkovStuart Cook-2/+4
fix: re-enable self-assignment ## Description Re-enables the self-assignment detection that was previously disabled due to unrelated regressions. The fix detects useless assignments like `x = x` and `foo.field = foo.field`. ## History The original regressions (rust-lang/rust#81626, rust-lang/rust#81658) were specifically about false positives in write-only field detection, not self-assignment detection. Belows are brief history for the rule that I understand. - Self-assignment detection was originally implemented in rust-lang/rust#87129 to address rust-lang/rust#75356 - The implementation was disabled alongside the revert of rust-lang/rust#81473's "write-only fields" detection - rust-lang/rust#81473 was reverted via rust-lang/rust#86212 and rust-lang/rust#83171 due to false positives in write-only field detection (rust-lang/rust#81626, rust-lang/rust#81658) - The self-assignment detection feature got removed, even though it wasn't the reason for the problems This PR only re-enables the self-assignment checks, which are orthogonal to the problematic write-only field analysis. ## Changes - Removed `#[allow(dead_code)]` from `compiler/rustc_passes/src/dead.rs` file - `handle_assign` and - `check_for_self_assign` - Added `ExprKind::Assign` handling in `visit_expr` to call both methods - Updated test expectations in `tests/ui/lint/dead-code/self-assign.rs`
2025-08-12Rollup merge of #145155 - scrabsha:push-tkvwkolzooyq, r=jdonszelmannStuart Cook-10/+43
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-12make no_mangle explicit on foreign itemsJana Dönszelmann-21/+22
2025-08-11Propagate TraitImplHeader to hirCameron Steffen-15/+16
2025-08-11Support using #[unstable_feature_bound] on traittiif-2/+1
2025-08-11Port `#[allow_internal_unsafe]` to the new attribute system (attempt 2)Sasha Pourcelot-10/+43
2025-08-10fix: re-enable self-assignmentLee ByeongJun-2/+4
2025-08-10Auto merge of #144873 - cjgillot:implications, r=lqdbors-80/+31
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-09remove `P`Deadbeef-2/+2
2025-08-08Revert "Port `#[allow_internal_unsafe]` to the new attribute system"Jana Dönszelmann-43/+10
This reverts commit 4f7a6ace9e2f2192af7b5d32f4b1664189e0e143.
2025-08-07Rollup merge of #144857 - scrabsha:push-pwtyrnmqkrtr, r=jdonszelmannTrevor Gross-10/+43
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-10/+43
2025-08-07Rollup merge of #143808 - JonathanBrouwer:should_panic_parser, r=jdonszelmannStuart Cook-3/+2
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-3/+2
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-06Rollup merge of #144794 - scrabsha:push-noqrrttovmwy, r=jdonszelmannGuillaume Gomez-5/+5
Port `#[coroutine]` to the new attribute system Related to https://github.com/rust-lang/rust/issues/131229#issue-2565886367. r? `````@jdonszelmann`````
2025-08-05Auto merge of #144863 - cjgillot:live-or-dead, r=Urgaubors-271/+197
Simplify dead code lint This PR scratches a few itches I had when looking at that code. The perf improvement comes from keeping the `scanned` set through several marking phases. This pretty much divides by 2 the number of HIR traversals.
2025-08-04Update doc-comment.Camille GILLOT-4/+3
2025-08-04Simplify maybe_record_as_seed.Camille GILLOT-3/+4
2025-08-04Port `#[coroutine]` to the new attribute systemSasha Pourcelot-5/+5
Related to https://github.com/rust-lang/rust/issues/131229#issue-2565886367.
2025-08-03Implement `stability_implications` without a visitor.Camille GILLOT-80/+31
2025-08-03Simplify lint emission.Camille GILLOT-74/+56
2025-08-03Keep scanned set across calls to mark_live_symbols.Camille GILLOT-2/+3
2025-08-03Use less HIR when seeding work list.Camille GILLOT-90/+50
2025-08-03Simplify handling of unsolved items.Camille GILLOT-52/+38
2025-08-03Remove struct_constructors.Camille GILLOT-34/+12
2025-08-02Use DefKind in should_explore.Camille GILLOT-10/+34
2025-08-02Do not record derived impl def-id for dead code.Camille GILLOT-14/+9
2025-08-01Remove the omit_gdb_pretty_printer_section attributebjorn3-2/+1
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-07-31remove rustc_attr_data_structuresJana Dönszelmann-27/+27
2025-07-28Rename impl_of_method -> impl_of_assocCameron Steffen-1/+1
2025-07-28Rename trait_of_item -> trait_of_assocCameron Steffen-1/+1
2025-07-28Auto merge of #144469 - Kivooeo:chains-cleanup, r=SparrowLiibors-25/+25
Some `let chains` clean-up Not sure if this kind of clean-up is welcoming because of size, but I decided to try out one r? compiler
2025-07-28use let chains in mir, resolve, targetKivooeo-25/+25
2025-07-26Implement check_attrJonathan Brouwer-10/+17
2025-07-24Rollup merge of #143374 - cjgillot:bare-extern-crate-map, r=petrochenkovLeón Orell Valerian Liehr-1/+1
Unquerify extern_mod_stmt_cnum. Based on https://github.com/rust-lang/rust/pull/143247 r? `````@ghost````` for perf
2025-07-23Ports `#[macro_use]` and `#[macro_escape]` to the new attribute parsing ↵Jonathan Brouwer-9/+8
infrastructure
2025-07-22Unquerify extern_mod_stmt_cnum.Camille GILLOT-1/+1
2025-07-22Rollup merge of #144080 - jieyouxu:realign, r=BoxyUwU许杰友 Jieyou Xu (Joe)-0/+1
Mitigate `#[align]` name resolution ambiguity regression with a rename Mitigates beta regression rust-lang/rust#143834 after a beta backport. ### Background on the beta regression The name resolution regression arises due to rust-lang/rust#142507 adding a new feature-gated built-in attribute named `#[align]`. However, unfortunately even [introducing new feature-gated unstable built-in attributes can break user code](https://www.github.com/rust-lang/rust/issues/134963) such as ```rs macro_rules! align { () => { /* .. */ }; } pub(crate) use align; // `use` here becomes ambiguous ``` ### Mitigation approach This PR renames `#[align]` to `#[rustc_align]` to mitigate the beta regression by: 1. Undoing the introduction of a new built-in attribute with a common name, i.e. `#[align]`. 2. Renaming `#[align]` to `#[rustc_align]`. The renamed attribute being `rustc_align` will not introduce new stable breakages, as attributes beginning with `rustc` are reserved and perma-unstable. This does mean existing nightly code using `fn_align` feature will additionally need to specify `#![feature(rustc_attrs)]`. This PR is very much a short-term mitigation to alleviate time pressure from having to fully fix the current limitation of inevitable name resolution regressions that would arise from adding any built-in attributes. Long-term solutions are discussed in [#t-lang > namespacing macro attrs to reduce conflicts with new adds](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/namespacing.20macro.20attrs.20to.20reduce.20conflicts.20with.20new.20adds/with/529249622). ### Alternative mitigation options [Various mitigation options were considered during the compiler triage meeting](https://github.com/rust-lang/rust/issues/143834#issuecomment-3084415277), and those consideration are partly reproduced here: - Reverting the PR doesn't seem very minimal/trivial, and carries risks of its own. - Rename to a less-common but aim-to-stabilization name is itself not safe nor convenient, because (1) that risks introducing new regressions (i.e. ambiguity against the new name), and (2) lang would have to FCP the new name hastily for the mitigation to land timely and have a chance to be backported. This also makes the path towards stabilization annoying. - Rename the attribute to a rustc attribute, which will be perma-unstable and does not cause new ambiguities in stable code. - This alleviates the time pressure to address *this* regression, or for lang to have to rush an FCP for some new name that can still break user code. - This avoids backing out a whole implementation. ### Review advice This PR is best reviewed commit-by-commit. - Commit 1 adds a test `tests/ui/attributes/fn-align-nameres-ambiguity-143834.rs` which demonstrates the current name resolution regression re. `align`. This test fails against current master. - Commit 2 carries out the renames and test reblesses. Notably, commit 2 will cause `tests/ui/attributes/fn-align-nameres-ambiguity-143834.rs` to change from fail (nameres regression) to pass. This PR, if the approach still seems acceptable, will need a beta-backport to address the beta regression.