about summary refs log tree commit diff
path: root/compiler/rustc_passes/src/reachable.rs
AgeCommit message (Collapse)AuthorLines
2025-08-26add a flag to codegen fn attrs for foreign itemsJana Dönszelmann-2/+2
2025-08-12make no_mangle explicit on foreign itemsJana Dönszelmann-2/+3
2025-07-28use let chains in mir, resolve, targetKivooeo-4/+4
2025-07-09Add opaque TypeId handles for CTFEOli Scherer-0/+1
2025-05-24Cleanup CodegenFnAttrFlagsNoratrieb-1/+1
- 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-04Initial support for dynamically linked cratesBryanskiy-4/+6
2025-03-18Auto merge of #138630 - matthiaskrgr:rollup-kk1gogr, r=matthiaskrgrbors-2/+2
Rollup of 7 pull requests Successful merges: - #138384 (Move `hir::Item::ident` into `hir::ItemKind`.) - #138508 (Clarify "owned data" in E0515.md) - #138531 (Store test diffs in job summaries and improve analysis formatting) - #138533 (Only use `DIST_TRY_BUILD` for try jobs that were not selected explicitly) - #138556 (Fix ICE: attempted to remap an already remapped filename) - #138608 (rustc_target: Add target feature constraints for LoongArch) - #138619 (Flatten `if`s in `rustc_codegen_ssa`) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-18Move `hir::Item::ident` into `hir::ItemKind`.Nicholas Nethercote-2/+2
`hir::Item` has an `ident` field. - It's always non-empty for these item kinds: `ExternCrate`, `Static`, `Const`, `Fn`, `Macro`, `Mod`, `TyAlias`, `Enum`, `Struct`, `Union`, Trait`, TraitAalis`. - It's always empty for these item kinds: `ForeignMod`, `GlobalAsm`, `Impl`. - For `Use`, it is non-empty for `UseKind::Single` and empty for `UseKind::{Glob,ListStem}`. All of this is quite non-obvious; the only documentation is a single comment saying "The name might be a dummy name in case of anonymous items". Some sites that handle items check for an empty ident, some don't. This is a very C-like way of doing things, but this is Rust, we have sum types, we can do this properly and never forget to check for the exceptional case and never YOLO possibly empty identifiers (or possibly dummy spans) around and hope that things will work out. The commit is large but it's mostly obvious plumbing work. Some notable things. - A similar transformation makes sense for `ast::Item`, but this is already a big change. That can be done later. - Lots of assertions are added to item lowering to ensure that identifiers are empty/non-empty as expected. These will be removable when `ast::Item` is done later. - `ItemKind::Use` doesn't get an `Ident`, but `UseKind::Single` does. - `lower_use_tree` is significantly simpler. No more confusing `&mut Ident` to deal with. - `ItemKind::ident` is a new method, it returns an `Option<Ident>`. It's used with `unwrap` in a few places; sometimes it's hard to tell exactly which item kinds might occur. None of these unwraps fail on the test suite. It's conceivable that some might fail on alternative input. We can deal with those if/when they happen. - In `trait_path` the `find_map`/`if let` is replaced with a loop, and things end up much clearer that way. - `named_span` no longer checks for an empty name; instead the call site now checks for a missing identifier if necessary. - `maybe_inline_local` doesn't need the `glob` argument, it can be computed in-function from the `renamed` argument. - `arbitrary_source_item_ordering::check_mod` had a big `if` statement that was just getting the ident from the item kinds that had one. It could be mostly replaced by a single call to the new `ItemKind::ident` method. - `ItemKind` grows from 56 to 64 bytes, but `Item` stays the same size, and that's what matters, because `ItemKind` only occurs within `Item`.
2025-03-17Mark #[rustc_std_internal_symbol] as extern indicatorbjorn3-4/+1
It currently implies #[no_mangle] which is alread an extern indicator, but this will change in a future commit.
2025-03-12Adjust `Map`'s `to_string` functionality.Nicholas Nethercote-1/+1
`Map::node_to_string` just calls the free function `hir_id_to_string`. This commit removes the former and changes the latter into a `TyCtxt` method.
2025-02-22Make asm a named fieldMichael Goulet-1/+1
2025-02-17Move some `Map` methods onto `TyCtxt`.Nicholas Nethercote-1/+1
The end goal is to eliminate `Map` altogether. I added a `hir_` prefix to all of them, that seemed simplest. The exceptions are `module_items` which became `hir_module_free_items` because there was already a `hir_module_items`, and `items` which became `hir_free_items` for consistency with `hir_module_free_items`.
2025-01-04turn hir::ItemKind::Fn into a named-field variantRalf Jung-2/+2
2024-10-22Rollup merge of #131049 - compiler-errors:more-validation, r=spastorinoMatthias Krüger-1/+1
Validate args are correct for `UnevaluatedConst`, `ExistentialTraitRef`/`ExistentialProjection` For the `Existential*` ones, we have to do some adjustment to the args list to deal with the missing `Self` type, so we introduce a `debug_assert_existential_args_compatible` function to the interner as well.
2024-10-04rm `ItemKind::OpaqueTy`Noah Lev-2/+2
This introduce an additional collection of opaques on HIR, as they can no longer be listed using the free item list.
2024-09-30Validate ExistentialPredicate argsMichael Goulet-1/+1
2024-09-23Check vtable projections for validity in miriMichael Goulet-2/+2
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-1/+1
2024-08-29Add `warn(unreachable_pub)` to `rustc_passes`.Nicholas Nethercote-1/+1
2024-07-02Miri function identity hack: account for possible inliningRalf Jung-1/+1
2024-06-28Revert "Rollup merge of #126938 - RalfJung:link_section, r=compiler-errors"Rémy Rakic-2/+10
This reverts commit 5c4ede88c61e746ed5c852d7a7e38ab1a824ae52, reversing changes made to 95332b89187bb6a0c910574cfeff1933b619565a.
2024-06-25miri: make sure we can find link_section statics even for the local crateRalf Jung-10/+2
2024-06-11reachable computation: clarify comments around constsRalf Jung-6/+9
2024-06-05Also support generic constantsOli Scherer-9/+9
2024-06-05Don't walk the bodies of free constants for reachability.Oli Scherer-4/+14
2024-06-04Closures are recursively reachableTomasz Miąsko-0/+1
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_passes`.Nicholas Nethercote-0/+1
2024-05-09reachable computation: extend explanation of what this does, and whyRalf Jung-10/+22
2024-04-29Remove `extern crate rustc_middle` from numerous crates.Nicholas Nethercote-0/+1
2024-03-28Rollup merge of #123063 - tmiasko:reachability-abi, r=michaelwoeristerMatthias Krüger-12/+1
Function ABI is irrelevant for reachability
2024-03-25Rollup merge of #122769 - RalfJung:reachable, r=tmiaskoJubilee-23/+49
extend comments for reachability set computation I hope this is right. :) Please review carefully. r? ``@tmiasko`` Cc ``@oli-obk`` ``@saethlin``
2024-03-25extend doc comment for reachability set computationRalf Jung-23/+49
also extend the const fn reachability test
2024-03-25Function ABI is irrelevant for reachabilityTomasz Miąsko-12/+1
2024-03-21rename items -> free_itemsRalf Jung-1/+1
2024-03-19The AssocOpaqueTy HIR node is not actually needed to differentiate from ↵Oli Scherer-1/+1
other hir nodes that were fed
2024-03-16Auto merge of #122371 - oli-obk:visit_nested_body, r=tmiaskobors-39/+79
Stop walking the bodies of statics for reachability, and evaluate them instead cc `@saethlin` `@RalfJung` cc #119214 This reuses the `DefIdVisitor` from `rustc_privacy`, because they basically try to do the same thing. This PR's changes can probably be extended to constants, too, but let's tackle that separately, it's likely more involved.
2024-03-14hir: Remove `opt_local_def_id_to_hir_id` and `opt_hir_node_by_def_id`Vadim Petrochenkov-9/+6
Also replace a few `hir_node()` calls with `hir_node_by_def_id()`
2024-03-14Test and implement reachability for trait objects and generic parameters of ↵Oli Scherer-4/+31
functions
2024-03-14Stop walking the bodies of statics for reachability, and evaluate them insteadOli Scherer-38/+51
2024-03-13Create some minimal HIR for associated opaque typesVadim Petrochenkov-1/+2
2024-03-12Ensure nested allocations in statics do not get deduplicatedOli Scherer-1/+38
2024-03-12Change `DefKind::Static` to a struct variantOli Scherer-1/+1
2023-12-12Move some methods from `tcx.hir()` to `tcx`zetanumbers-2/+2
Renamings: - find -> opt_hir_node - get -> hir_node - find_by_def_id -> opt_hir_node_by_def_id - get_by_def_id -> hir_node_by_def_id Fix rebase changes using removed methods Use `tcx.hir_node_by_def_id()` whenever possible in compiler Fix clippy errors Fix compiler Apply suggestions from code review Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com> Add FIXME for `tcx.hir()` returned type about its removal Simplify with with `tcx.hir_node_by_def_id`
2023-11-26rustc: `hir().local_def_id_to_hir_id()` -> `tcx.local_def_id_to_hir_id()` ↵Vadim Petrochenkov-3/+1
cleanup
2023-10-17Automatically enable cross-crate inlining for small functionsBen Kimock-50/+8
2023-10-13Format all the let chains in compilerMichael Goulet-1/+3
2023-09-10Encode only MIR that can be used by other cratesTomasz Miąsko-0/+4
Only reachable items might participate in the code generation in the downstream crates. Omit redundant optimized MIR of unreachable items from a crate metadata. Additionally, include reachable closures in reachable set, so that unreachable closures can be omitted on the same basis.
2023-08-22Contents of reachable statics is reachableTomasz Miąsko-7/+3
2023-08-09rustc: Move `crate_types` from `Session` to `GlobalCtxt`Vadim Petrochenkov-4/+4
Removes a piece of mutable state. Follow up to #114578.
2023-07-28Lower generic const items to HIRLeón Orell Valerian Liehr-1/+1