about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/middle
AgeCommit message (Collapse)AuthorLines
2025-09-26Rollup merge of #146704 - jdonszelmann:port-debug-visualizer, r=petrochenkovMatthias Krüger-7/+1
port `#[debugger_visualizer]` to the new attribute system
2025-09-21port `#[debugger_visualizer]` to the new attribute systemJana Dönszelmann-7/+1
2025-09-21Add panic=immediate-abortBen Kimock-0/+1
2025-09-13initial implementation of the darwin_objc unstable featureJo Bates-0/+6
2025-09-04Rollup merge of #145932 - JamieCunliffe:target-feature-inlining, r=jackh726Stuart Cook-1/+1
Allow `inline(always)` with a target feature behind a unstable feature `target_feature_inline_always`. Rather than adding the inline always attribute to the function definition, we add it to the callsite. We can then check that the target features match and that the call would be safe to inline. If the function isn't inlined due to a mismatch, we emit a warning informing the user that the function can't be inlined due to the target feature mismatch. See tracking issue rust-lang/rust#145574
2025-09-04Rollup merge of #145342 - dianne:if-let-super-let, r=nnethercoteStuart Cook-0/+39
fix drop scope for `super let` bindings within `if let` Fixes rust-lang/rust#145328 by making non-lifetime-extended `super let` reuse the logic used to compute drop scopes for non-lifetime-extended temporaries. Also fixes rust-lang/rust#145374, which regressed due to rust-lang/rust#143376 introducing `if let`-like scopes for match arms with guards. Tracking issue for `super let`: rust-lang/rust#139076 This is a regression fix / breaking change for macros stably exposing `super let`, including `pin!` and `format_args!`. Nominating to be discussed alongside rust-lang/rust#145328: ```@rustbot``` label +I-lang-nominated +I-libs-api-nominated
2025-08-27inline at the callsite & warn when target features mismatchJames Barford-Evans-1/+1
Co-authored-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
2025-08-26add a flag to codegen fn attrs for foreign itemsJana Dönszelmann-3/+4
2025-08-22Rollup merge of #145747 - joshtriplett:builtin-diag-dyn, r=jdonszelmannJacob Pratt-2/+2
Refactor lint buffering to avoid requiring a giant enum Lint buffering currently relies on a giant enum `BuiltinLintDiag` containing all the lints that might potentially get buffered. In addition to being an unwieldy enum in a central crate, this also makes `rustc_lint_defs` a build bottleneck: it depends on various types from various crates (with a steady pressure to add more), and many crates depend on it. Having all of these variants in a separate crate also prevents detecting when a variant becomes unused, which we can do with a dedicated type defined and used in the same crate. Refactor this to use a dyn trait, to allow using `LintDiagnostic` types directly. Because the existing `BuiltinLintDiag` requires some additional types in order to decorate some variants, which are only available later in `rustc_lint`, use an enum `DecorateDiagCompat` to handle both the `dyn LintDiagnostic` case and the `BuiltinLintDiag` case. --- With the infrastructure in place, use it to migrate three of the enum variants to use `LintDiagnostic` directly, as a proof of concept and to demonstrate that the net result is a reduction in code size and a removal of a boilerplate-heavy layer of indirection. Also remove an unused `BuiltinLintDiag` variant.
2025-08-22Refactor lint buffering to avoid requiring a giant enumJosh Triplett-2/+2
Lint buffering currently relies on a giant enum `BuiltinLintDiag` containing all the lints that might potentially get buffered. In addition to being an unwieldy enum in a central crate, this also makes `rustc_lint_defs` a build bottleneck: it depends on various types from various crates (with a steady pressure to add more), and many crates depend on it. Having all of these variants in a separate crate also prevents detecting when a variant becomes unused, which we can do with a dedicated type defined and used in the same crate. Refactor this to use a dyn trait, to allow using `LintDiagnostic` types directly. This requires boxing, but all of this is already on the slow path (emitting an error). Because the existing `BuiltinLintDiag` requires some additional types in order to decorate some variants, which are only available later in `rustc_lint`, use an enum `DecorateDiagCompat` to handle both the `dyn LintDiagnostic` case and the `BuiltinLintDiag` case.
2025-08-22Add an experimental unsafe(force_target_feature) attribute.Luca Versari-3/+13
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-19Rollup merge of #145429 - bjorn3:codegen_fn_attrs_improvements, r=jdonszelmann许杰友 Jieyou Xu (Joe)-11/+6
Couple of codegen_fn_attrs improvements As noted in https://github.com/rust-lang/rust/pull/144678#discussion_r2245060329 here is no need to keep link_name and export_name separate, which the third commit fixes by merging them. The second commit removes some dead code and the first commit merges two ifs with equivalent conditions. The last commit is an unrelated change which removes an unused `feature(autodiff)`.
2025-08-18Remove the no_sanitize attribute in favor of sanitizeBastian Kersting-2/+2
This removes the #[no_sanitize] attribute, which was behind an unstable feature named no_sanitize. Instead, we introduce the sanitize attribute which is more powerful and allows to be extended in the future (instead of just focusing on turning sanitizers off). This also makes sanitize(kernel_address = ..) attribute work with -Zsanitize=address To do it the same as how clang disables address sanitizer, we now disable ASAN on sanitize(kernel_address = "off") and KASAN on sanitize(address = "off"). The same was added to clang in https://reviews.llvm.org/D44981.
2025-08-15Merge link_name and export_namebjorn3-11/+6
2025-08-14Complete functionality and general cleanupMarcelo Domínguez-4/+0
2025-08-14Rollup merge of #145323 - scrabsha:push-pqwvmznzzmpr, r=jdonszelmannGuillaume Gomez-2/+1
Port the `#[linkage]` attribute to the new attribute system r? `@jdonszelmann`
2025-08-13Port the `#[linkage]` attribute to the new attribute systemSasha Pourcelot-2/+1
2025-08-13Cleanup assoc parent utilsCameron Steffen-5/+1
2025-08-13fix scope of `super let` bindings within `if let`dianne-0/+39
They now use the enclosing temporary scope as their scope, regardless of which `ScopeData` was used to mark it.
2025-08-12make no_mangle explicit on foreign itemsJana Dönszelmann-1/+6
2025-08-07add a scope for `if let` guard temporaries and bindingsdianne-0/+6
This ensures `if let` guard temporaries and bindings are dropped before the match arm's pattern's bindings.
2025-07-31remove rustc_attr_data_structuresJana Dönszelmann-8/+6
2025-07-28Rename impl_of_method -> impl_of_assocCameron Steffen-1/+1
2025-07-28use let chains in hir, lint, mirKivooeo-17/+16
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.
2025-07-19Mitigate `#[align]` name resolution ambiguity regression with a renameJieyou Xu-0/+1
From `#[align]` -> `#[rustc_align]`. Attributes starting with `rustc` are always perma-unstable and feature-gated by `feature(rustc_attrs)`. See regression RUST-143834. For the underlying problem where even introducing new feature-gated unstable built-in attributes can break user code such as ```rs macro_rules! align { () => { /* .. */ }; } pub(crate) use align; // `use` here becomes ambiguous ``` refer to RUST-134963. Since the `#[align]` attribute is still feature-gated by `feature(fn_align)`, we can rename it as a mitigation. Note that `#[rustc_align]` will obviously mean that current unstable user code using `feature(fn_aling)` will need additionally `feature(rustc_attrs)`, but this is a short-term mitigation to buy time, and is expected to be changed to a better name with less collision potential. See <https://rust-lang.zulipchat.com/#narrow/channel/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202025-07-17/near/529290371> where mitigation options were considered.
2025-07-18Auto merge of #143845 - cjgillot:stability-query, r=jieyouxubors-44/+1
Split-up stability_index query This PR aims to move deprecation and stability processing away from the monolithic `stability_index` query, and directly implement `lookup_{deprecation,stability,body_stability,const_stability}` queries. The basic idea is to: - move per-attribute sanity checks into `check_attr.rs`; - move attribute compatibility checks into the `MissingStabilityAnnotations` visitor; - progressively dismantle the `Annotator` visitor and the `stability_index` query. The first commit contains functional change, and now warns when `#[automatically_derived]` is applied on a non-trait impl block. The other commits should not change visible behaviour. Perf in https://github.com/rust-lang/rust/pull/143845#issuecomment-3066308630 shows small but consistent improvement, except for unused-warnings case. That case being a stress test, I'm leaning towards accepting the regression. This PR changes `check_attr`, so has a high conflict rate on that file. This should not cause issues for review.
2025-07-17Retire stability_index query.Camille GILLOT-19/+0
2025-07-17Querify lookup_const_stability.Camille GILLOT-10/+1
2025-07-17Querify lookup_stability.Camille GILLOT-5/+0
2025-07-17Querify lookup_default_body_stability.Camille GILLOT-5/+0
2025-07-17Querify lookup_deprecation_entry.Camille GILLOT-5/+0
2025-07-16use `codegen_instance_attrs` where an instance is (easily) availableFolkert de Vries-1/+3
2025-07-16add `codegen_instance_attrs` queryFolkert de Vries-0/+20
and use it for naked functions
2025-07-05Remove yields_in_scope from the scope tree.Camille GILLOT-92/+0
2025-06-27Rollup merge of #140809 - bjorn3:panic_runtime_cleanup, r=petrochenkovMatthias Krüger-0/+6
Reduce special casing for the panic runtime See the individual commits for more info.
2025-06-27Rollup merge of #139858 - oli-obk:new-const-traits-syntax, r=fee1-deadMatthias Krüger-1/+1
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-27Update commentsbjorn3-0/+3
2025-06-26Change const trait bound syntax from ~const to [const]Oli Scherer-1/+1
2025-06-24Add all rustc_std_internal_symbol to symbols.objorn3-0/+3
rustc_std_internal_symbol is meant to call functions from crates where there is no direct dependency on said crate. As they either have to be added to symbols.o or rustc has to introduce an implicit dependency on them to avoid linker errors. The latter is done for some things like the panic runtime, but adding these symbols to symbols.o allows removing those implicit dependencies.
2025-06-23[Arm64EC] Only decorate functions with `#`Daniel Paoliello-1/+1
2025-06-18add `#[align]` attributeFolkert de Vries-2/+1
Right now it's used for functions with `fn_align`, in the future it will get more uses (statics, struct fields, etc.)
2025-06-12Tracking the old name of renamed unstable library attributexizheyin-2/+2
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-05Replace some `Option<Span>` with `Span` and use DUMMY_SP instead of NoneOli Scherer-1/+1
2025-05-24Cleanup CodegenFnAttrFlagsNoratrieb-24/+21
- Rename `USED` to `USED_COMPILER` to better reflect its behavior. - Reorder some items to group the used and allocator flags together - Renumber them without gaps
2025-05-19Rollup merge of #140874 - mejrs:rads, r=WaffleLapkinStuart Cook-4/+4
make `rustc_attr_parsing` less dominant in the rustc crate graph It has/had a glob re-export of `rustc_attr_data_structures`, which is a crate much lower in the graph, and a lot of crates were using it *just* (or *mostly*) for that re-export, while they can rely on `rustc_attr_data_structures` directly. Previous graph: ![graph_1](https://github.com/user-attachments/assets/f4a5f13c-4222-4903-b56d-28c83511fcbd) Graph with this PR: ![graph_2](https://github.com/user-attachments/assets/1e053d9c-75cc-402b-84df-86229c98277a) The first commit keeps the re-export, and just changes the dependency if possible. The second commit is the "breaking change" which removes the re-export, and "explicitly" adds the `rustc_attr_data_structures` dependency where needed. It also switches over some src/tools/*. The second commit is actually a lot more involved than I expected. Please let me know if it's a better idea to back it out and just keep the first commit.
2025-05-18Remove rustc_attr_data_structures re-export from rustc_attr_parsingmejrs-4/+4
2025-05-15Revert "Fix linking statics on Arm64EC #140176"Jieyou Xu-1/+1
Unfortunately, multiple people are reporting linker warnings related to `__rust_no_alloc_shim_is_unstable` after this change. The solution isn't quite clear yet, let's revert to green for now, and try a reland with a determined solution for `__rust_no_alloc_shim_is_unstable`. This reverts commit c8b7f32434c0306db5c1b974ee43443746098a92, reversing changes made to 667247db71ea18c4130dd018d060e7f09d589490.
2025-05-07[Arm64EC] Only decorate functions with `#`Daniel Paoliello-1/+1
2025-05-05Rename Instance::new to Instance::new_raw and add a note that it is rawMichael Goulet-1/+1