about summary refs log tree commit diff
path: root/compiler/rustc_hir/src/def.rs
AgeCommit message (Collapse)AuthorLines
2025-07-06compiler: rename {ast,hir}::BareFn* to FnPtr*Jubilee Young-1/+1
Fix some comments and related types and locals where it is obvious, e.g. - bare_fn -> fn_ptr - LifetimeBinderKind::BareFnType -> LifetimeBinderKind::FnPtrType Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
2025-06-04Replace `elided_named_lifetimes` with `mismatched_lifetime_syntaxes`Jake Goulding-6/+1
2025-06-03Overhaul `UsePath`.Nicholas Nethercote-1/+11
`UsePath` contains a `SmallVec<[Res; 3]>`. This holds up to three `Res` results, one per namespace (type, value, or macro). `lower_import_res` takes a `PerNS<Option<Res<NodeId>>>` result and lowers it into the `SmallVec`. This is pretty weird. The input `PerNS` makes it clear which `Res` belongs to which namespace, but the `SmallVec` throws that information away. And code that operates on the `SmallVec` tends to use iteration (or even just grabbing the first entry!) without knowing which namespace the `Res` belongs to. Even weirder! Also, `SmallVec` is an overly flexible type to use here, because it can contain any number of elements (even though it's optimized for 3 in this case). This commit changes `UsePath` so it also contains a `PerNS<Option<Res<HirId>>>`. This type preserves more information and is more self-documenting. The commit also changes a lot of the use sites to access the result for a particular namespace. E.g. if you're looking up a trait, it will be in the `Res` for the type namespace if it's present; it's silly to look in the `Res` for the value namespace or macro namespace. Overall I find the new code much easier to understand. However, some use sites still iterate. These now use `present_items` because that filters out the `None` results. Also, `redundant_pub_crate.rs` gets a bigger change. A `UseKind:ListStem` item gets no `Res` results, which means the old `all` call in `is_not_macro_export` would succeed (because `all` succeeds on an empty iterator) and the `ListStem` would be ignored. This is what we want, but was more by luck than design. The new code detects `ListStem` explicitly. The commit generalizes the name of that function accordingly. Finally, the commit also removes the `use_path` arena, because `PerNS<Option<Res>>` impls `Copy` (unlike `SmallVec`) and it can be allocated in the arena shared by all `Copy` types.
2025-05-02Add `DefPathData::NestedStatic` instead of reusing `DefPathData::AnonConst`John Kåre Alsaker-3/+0
2025-04-29Remove global `next_disambiguator` state and handle it with a ↵John Kåre Alsaker-8/+3
`DisambiguatorState` type
2025-04-11Introduce `DefPathData::AnonAssocTy`.Nicholas Nethercote-5/+10
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-1/+1
2025-03-09Rollup merge of #138040 - thaliaarchi:use-prelude-size-of.compiler, ↵Matthias Krüger-2/+2
r=compiler-errors compiler: Use `size_of` from the prelude instead of imported Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. Apply this change across the compiler. These functions were added to all preludes in Rust 1.80. r? ``@compiler-errors``
2025-03-07compiler: Use size_of from the prelude instead of importedThalia Archibald-2/+2
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. These functions were added to all preludes in Rust 1.80.
2025-03-07Make synthetic RPITIT assoc ty name handling more rigorous.Nicholas Nethercote-3/+7
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-03-07Pass `Option<Symbol>` to `def_path_data`/`create_def` methods.Nicholas Nethercote-5/+7
It's clearer than using `kw::Empty` to mean `None`.
2025-01-19Run `clippy --fix` for `unnecessary_map_or` lintYotam Ofek-1/+1
2024-12-10Remove more traces of anonymous ADTsMichael Goulet-2/+0
2024-11-28update commentlcnr-1/+10
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-1/+1
2024-09-16Fix a couple more DefKind discrepancies between DefKind::Closure and ↵Michael Goulet-1/+4
DefKind::SyntheticCoroutineBody
2024-09-01Revert "Auto merge of #127537 - veluca93:struct_tf, r=BoxyUwU"Jakub Beránek-35/+0
This reverts commit acb4e8b6251f1d8da36f08e7a70fa23fc581839e, reversing changes made to 100fde5246bf56f22fb5cc85374dd841296fce0e.
2024-08-31Implement `elided_named_lifetimes` lintPavel Grigorenko-2/+7
2024-08-28Implement RFC 3525.Luca Versari-0/+35
2024-08-26Stop using a special inner body for the coroutine by-move body for async ↵Michael Goulet-2/+9
closures
2024-07-29Reformat `use` declarations.Nicholas Nethercote-4/+4
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-04Add safe/unsafe to static inside extern blocksSantiago Pastorino-0/+2
2024-04-29Remove `extern crate rustc_macros` from numerous crates.Nicholas Nethercote-1/+1
2024-04-15Opaque types have no namespaceMichael Goulet-2/+2
2024-04-05explaining `DefKind::Field`bohan-0/+3
2024-03-21Fix bad span for explicit lifetime suggestionShoyu Vanilla-0/+2
Move verbose logic to a function Minor renaming
2024-03-12Some comment nitsOli Scherer-1/+1
2024-03-12s/mt/mutability/Oli Scherer-1/+1
2024-03-12Ensure nested allocations in statics do not get deduplicatedOli Scherer-0/+3
2024-03-12Add `nested` bool to `DefKind::Static`.Oli Scherer-0/+2
Will be used in the next commit
2024-03-12Change `DefKind::Static` to a struct variantOli Scherer-5/+8
2024-02-12Rollup merge of #120950 - compiler-errors:miri-async-closurs, r=RalfJung,oli-obkMatthias Krüger-0/+6
Fix async closures in CTFE First commit renames `is_coroutine_or_closure` into `is_closure_like`, because `is_coroutine_or_closure_or_coroutine_closure` seems confusing and long. Second commit fixes some forgotten cases where we want to handle `TyKind::CoroutineClosure` the same as closures and coroutines. The test exercises the change to `ValidityVisitor::aggregate_field_path_elem` which is the source of #120946, but not the change to `UsedParamsNeedSubstVisitor`, though I feel like it's not that big of a deal. Let me know if you'd like for me to look into constructing a test for the latter, though I have no idea what it'd look like (we can't assert against `TooGeneric` anywhere?). Fixes #120946 r? oli-obk cc ``@RalfJung``
2024-02-12Lower anonymous structs or unions to HIRFrank King-0/+2
2024-02-11is_closure_likeMichael Goulet-0/+6
2023-12-20Give `VariantData::Struct` named fields, to clairfy `recovered`.Alona Enraght-Moony-1/+1
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-0/+37
`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-11-26merge `DefKind::Coroutine` into `DefKind::Closure`bohan-5/+1
2023-11-20Put derives on a single line where possible.Nicholas Nethercote-10/+5
2023-11-20Add a comment.Nicholas Nethercote-0/+2
2023-10-20s/generator/coroutine/Oli Scherer-3/+3
2023-10-20s/Generator/Coroutine/Oli Scherer-5/+5
2023-09-26Don't store lazyness in DefKindMichael Goulet-6/+4
2023-08-07Store the laziness of type aliases in the DefKindLeón Orell Valerian Liehr-4/+6
2023-07-08Replace RPITIT current impl with new strategy that lowers as a GATSantiago Pastorino-6/+1
2023-04-16use matches! macro in more placesMatthias Krüger-4/+1
2023-02-22diagnostics: if AssocFn has self argument, describe as methodMichael Howell-0/+9
Discussed in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515 This commit also changes the tooltips on rustdoc intra-doc links targeting methods.
2023-02-14Add `of_trait` to DefKind::Impl.Camille GILLOT-5/+7
2023-02-10Resolve documentation links in rustc and store the results in metadataVadim Petrochenkov-1/+15
This commit implements MCP https://github.com/rust-lang/compiler-team/issues/584 It also removes code that is no longer used, and that includes code cloning resolver, so issue #83761 is fixed.
2023-01-17Remove double spaces after dots in commentsMaybe Waffle-1/+1