about summary refs log tree commit diff
path: root/compiler/rustc_hir/src/definitions.rs
AgeCommit message (Collapse)AuthorLines
2025-07-17Auto merge of #142903 - cjgillot:local-def-path-hash, r=compiler-errorsbors-3/+13
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-06-22Only inherit local hash for paths.Camille GILLOT-3/+13
2025-05-07Add `DefPathData::OpaqueLifetime` to avoid conflicts for remapped opaque ↵John Kåre Alsaker-7/+8
lifetimes
2025-05-02Split `get_opt_name` hashing use into `hashed_symbol`John Kåre Alsaker-1/+21
2025-05-02Add comment about the symbol on `AnonAssocTy`John Kåre Alsaker-1/+2
2025-05-02Add `DefPathData::NestedStatic` instead of reusing `DefPathData::AnonConst`John Kåre Alsaker-1/+5
2025-04-29Remove global `next_disambiguator` state and handle it with a ↵John Kåre Alsaker-12/+44
`DisambiguatorState` type
2025-04-14Use `newtype_index!`-generated types more idiomaticallyYotam Ofek-6/+3
2025-04-11Change how anonymous associated types are printed.Nicholas Nethercote-1/+1
Give them their own symbol `anon_assoc`, as is done for all the other anonymous `DefPathData` variants.
2025-04-11Introduce `DefPathData::AnonAssocTy`.Nicholas Nethercote-13/+9
PR #137977 changed `DefPathData::TypeNs` to contain `Option<Symbol>` to account for RPITIT assoc types being anonymous. This commit changes it back to `Symbol` and gives anonymous assoc types their own variant. It makes things a bit nicer overall.
2025-03-30Encode synthetic by-move coroutine body with a different DefPathDataMichael Goulet-2/+13
2025-03-07Make synthetic RPITIT assoc ty name handling more rigorous.Nicholas Nethercote-9/+13
Currently it relies on special treatment of `kw::Empty`, which is really easy to get wrong. This commit makes the special case clearer in the type system by using `Option`. It's a bit clumsy, but the synthetic name handling itself is a bit clumsy; better to make it explicit than sneak it in. Fixes #133426.
2025-02-22Greatly simplify lifetime captures in edition 2024Michael Goulet-1/+1
2025-02-16Move hashes from rustc_data_structure to rustc_hashes so they can be shared ↵Ben Kimock-1/+2
with rust-analyzer
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-1/+1
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-12-10Remove more traces of anonymous ADTsMichael Goulet-4/+1
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-2/+2
2024-07-29Reformat `use` declarations.Nicholas Nethercote-5/+7
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-19local_def_path_hash_to_def_id can failMichael Baikov-11/+6
local_def_path_hash_to_def_id is used by Debug impl for DepNode and it looks for DefPathHash inside the current compilation. During incremental compilation we are going through nodes that belong to a previous compilation and might not be present and a simple attempt to print such node with tracing::debug (try_mark_parent_green does it for example) results in a otherwise avoidable panic Panic was added in https://github.com/rust-lang/rust/pull/82183, specifically in 2b60338ee9, with a comment "We only use this mapping for cases where we know that it must succeed.", but I'm not sure if this property holds when we traverse nodes from the old compilation in order to figure out if they are valid or not
2024-04-30Remove `extern crate tracing` from numerous crates.Nicholas Nethercote-2/+1
2024-04-29Remove `extern crate rustc_macros` from numerous crates.Nicholas Nethercote-0/+1
2024-04-04Try explicitly outlining the panic machineryOli Scherer-1/+6
2024-03-27Use a `dyn Debug` trait object instead of a closure.Oli Scherer-2/+2
Simplifies the API a bit.
2024-02-27rename RPITIT from opaque to syntheticMichael Goulet-1/+3
2024-02-12Lower anonymous structs or unions to HIRFrank King-1/+5
2023-12-24Do not store stable crate id in on-disk hash map.Camille GILLOT-3/+4
2023-12-24Do not store stable_crate_id again in Definitions.Camille GILLOT-5/+2
2023-12-24Only store StableCrateId once in DefPathTable.Camille GILLOT-15/+22
2023-12-18Replace some instances of FxHashMap/FxHashSet with stable alternatives ↵Michael Woerister-2/+2
(mostly in rustc_hir and rustc_ast_lowering) Part of https://github.com/rust-lang/compiler-team/issues/533
2023-12-03rustc: Harmonize `DefKind` and `DefPathData`Vadim Petrochenkov-9/+9
`DefPathData::(ClosureExpr,ImplTrait)` are renamed to match `DefKind::(Closure,OpaqueTy)`. `DefPathData::ImplTraitAssocTy` is replaced with `DefPathData::TypeNS(kw::Empty)` because both correspond to `DefKind::AssocTy`. It's possible that introducing `(DefKind,DefPathData)::AssocOpaqueTy` could be a better solution, but that would be a much more invasive change. Const generic parameters introduced for effects are moved from `DefPathData::TypeNS` to `DefPathData::ValueNS`, because constants are values. `DefPathData` is no longer passed to `create_def` functions to avoid redundancy.
2023-08-30Pretty-print impl trait to name it.Camille GILLOT-1/+2
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-1/+1
2023-04-18Store hashes in special types so they aren't accidentally encoded as numbersBen Kimock-3/+3
2023-03-29Properly skip RPITITs from ModChild and give a name in AssocItemSantiago Pastorino-5/+1
2023-03-14Make fns from other crates with RPITIT workSantiago Pastorino-1/+5
2023-02-19Add associated_items_for_impl_trait_in_trait querySantiago Pastorino-2/+4
2023-02-13rustc_resolve: Remove `Resolver::clone_output`Vadim Petrochenkov-1/+1
And remove `Clone` impls and `Lrc`s that are no longer necessary
2023-01-05Fix `uninlined_format_args` for some compiler cratesnils-6/+5
Convert all the crates that have had their diagnostic migration completed (except save_analysis because that will be deleted soon and apfloat because of the licensing problem).
2022-11-29Only allow feeding a value to newly created definitions.Camille GILLOT-4/+4
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-1/+0
by module
2022-08-01fix ICE in Definitions::create_defGoldstein-1/+6
2022-06-14Separate `source_span` and `expn_that_defined` from `Definitions`.Camille GILLOT-51/+5
2022-05-12Replace DefPathData::Misc by two appropriately-named variants.Camille GILLOT-6/+8
2022-04-17Stop using CRATE_DEF_INDEX.Camille GILLOT-5/+0
`CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want.
2022-04-09Use def_key in `tcx.item_name` when possible.Camille GILLOT-0/+5
2022-03-31Store next_disambiguator in Definitions.Camille GILLOT-2/+9
2022-03-30Spellchecking compiler codeYuri Astrakhan-1/+1
Address some spelling mistakes in strings, private function names, and function params.
2022-03-01compiler: fix some typoscuishuang-1/+1
2022-01-27Store def_id_to_hir_id as variant in hir_owner.Camille GILLOT-30/+1
If hir_owner is Owner(_), the LocalDefId is pointing to an owner, so the ItemLocalId is 0. If the HIR node does not exist, we store Phantom. Otherwise, we store the HirId associated to the LocalDefId.