about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src/index.rs
AgeCommit message (Collapse)AuthorLines
2025-08-03Rollup merge of #142678 - BoxyUwU:gai_cleanup, r=nnethercoteSamuel Tardieu-1/+1
Misc cleanups of `generic_arg_infer` related HIR logic r? ````@nnethercote````
2025-07-28use let chains in ast, borrowck, codegen, const_evalKivooeo-4/+4
2025-07-13Retire hir::*ItemRef.Camille GILLOT-12/+4
2025-07-13Retire hir::ForeignItemRef.Camille GILLOT-6/+2
2025-07-13Remove hir::AssocItemKind.Camille GILLOT-2/+2
2025-07-13Move trait_item_def_id from ImplItemRef to ImplItem.Camille GILLOT-1/+1
2025-06-17Rename hir const arg walking functionsBoxy-1/+1
2025-05-30Reorder fields in `hir::ItemKind` variants.Nicholas Nethercote-1/+1
Specifically `TyAlias`, `Enum`, `Struct`, `Union`. So the fields match the textual order in the source code. The interesting part of the change is in `compiler/rustc_hir/src/hir.rs`. The rest is extremely mechanical refactoring.
2025-03-18Move `hir::Item::ident` into `hir::ItemKind`.Nicholas Nethercote-1/+1
`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-02-03Use a different hir type for patterns in pattern types than we use in match ↵Oli Scherer-2/+6
patterns
2025-01-23Split hir `TyKind` and `ConstArgKind` in two and update `hir::Visitor`Boxy-14/+26
2025-01-22Enforce that all spans are lowered in ast loweringOli Scherer-17/+24
2025-01-08Exhaustively handle expressions in patternsOli Scherer-0/+8
2024-11-30Remove hir::ArrayLen, introduce ConstArgKind::InferDominik Stolz-11/+2
Remove Node::ArrayLenInfer
2024-11-25Refactor `where` predicates, and reserve for attributes supportFrank King-9/+4
2024-10-04rm `ItemKind::OpaqueTy`Noah Lev-0/+8
This introduce an additional collection of opaques on HIR, as they can no longer be listed using the free item list.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-1/+1
2024-09-11Simplify some nested if statementsMichael Goulet-19/+17
2024-07-16Add `ConstArgKind::Path` and make `ConstArg` its own HIR nodeNoah Lev-0/+10
This is a very large commit since a lot needs to be changed in order to make the tests pass. The salient changes are: - `ConstArgKind` gets a new `Path` variant, and all const params are now represented using it. Non-param paths still use `ConstArgKind::Anon` to prevent this change from getting too large, but they will soon use the `Path` variant too. - `ConstArg` gets a distinct `hir_id` field and its own variant in `hir::Node`. This affected many parts of the compiler that expected the parent of an `AnonConst` to be the containing context (e.g., an array repeat expression). They have been changed to check the "grandparent" where necessary. - Some `ast::AnonConst`s now have their `DefId`s created in rustc_ast_lowering rather than `DefCollector`. This is because in some cases they will end up becoming a `ConstArgKind::Path` instead, which has no `DefId`. We have to solve this in a hacky way where we guess whether the `AnonConst` could end up as a path const since we can't know for sure until after name resolution (`N` could refer to a free const or a nullary struct). If it has no chance as being a const param, then we create a `DefId` in `DefCollector` -- otherwise we decide during ast_lowering. This will have to be updated once all path consts use `ConstArgKind::Path`. - We explicitly use `ConstArgHasType` for array lengths, rather than implicitly relying on anon const type feeding -- this is due to the addition of `ConstArgKind::Path`. - Some tests have their outputs changed, but the changes are for the most part minor (including removing duplicate or almost-duplicate errors). One test now ICEs, but it is for an incomplete, unstable feature and is now tracked at #127009.
2024-07-16Use `ConstArg` for const param defaultsNoah Lev-1/+1
Now everything that actually affects the type system (i.e., excluding const blocks, enum variant discriminants, etc.) *should* be using `ConstArg`.
2024-06-07Revert "Create const block DefIds in typeck instead of ast lowering"Oli Scherer-0/+8
This reverts commit ddc5f9b6c1f21da5d4596bf7980185a00984ac42.
2024-05-31Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constraint, ↵Matthias Krüger-4/+4
r=compiler-errors Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanup Rename `hir::TypeBinding` and `ast::AssocConstraint` to `AssocItemConstraint` and update all items and locals using the old terminology. Motivation: The terminology *type binding* is extremely outdated. "Type bindings" not only include constraints on associated *types* but also on associated *constants* (feature `associated_const_equality`) and on RPITITs of associated *functions* (feature `return_type_notation`). Hence the word *item* in the new name. Furthermore, the word *binding* commonly refers to a mapping from a binder/identifier to a "value" for some definition of "value". Its use in "type binding" made sense when equality constraints (e.g., `AssocTy = Ty`) were the only kind of associated item constraint. Nowadays however, we also have *associated type bounds* (e.g., `AssocTy: Bound`) for which the term *binding* doesn't make sense. --- Old terminology (HIR, rustdoc): ``` `TypeBinding`: (associated) type binding ├── `Constraint`: associated type bound └── `Equality`: (associated) equality constraint (?) ├── `Ty`: (associated) type binding └── `Const`: associated const equality (constraint) ``` Old terminology (AST, abbrev.): ``` `AssocConstraint` ├── `Bound` └── `Equality` ├── `Ty` └── `Const` ``` New terminology (AST, HIR, rustdoc): ``` `AssocItemConstraint`: associated item constraint ├── `Bound`: associated type bound └── `Equality`: associated item equality constraint OR associated item binding (for short) ├── `Ty`: associated type equality constraint OR associated type binding (for short) └── `Const`: associated const equality constraint OR associated const binding (for short) ``` r? compiler-errors
2024-05-30Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanupLeón Orell Valerian Liehr-4/+4
2024-05-28Create const block DefIds in typeck instead of ast loweringOli Scherer-8/+0
2024-05-04Auto merge of #124401 - oli-obk:some_hir_cleanups, r=cjgillotbors-2/+2
Some hir cleanups It seemed odd to not put `AnonConst` in the arena, compared with the other types that we did put into an arena. This way we can also give it a `Span` without growing a lot of other HIR data structures because of the extra field. r? compiler
2024-04-30Remove `extern crate tracing` from numerous crates.Nicholas Nethercote-0/+1
2024-04-26`Span`s are already 64 bit, just like references, so stop putting them ↵Oli Scherer-1/+1
behind indirections
2024-04-26put `hir::AnonConst` on the hir arenaOli Scherer-1/+1
2024-04-15Add hir::Node::PreciseCapturingNonLifetimeArgMichael Goulet-0/+17
2024-04-08Actually create ranged int types in the type system.Oli Scherer-0/+4
2024-04-04hir: Use `ItemLocalId` in a couple more placesVadim Petrochenkov-6/+5
2024-04-03Auto merge of #123429 - matthiaskrgr:rollup-4emw4e9, r=matthiaskrgrbors-2/+2
Rollup of 8 pull requests Successful merges: - #121595 (Better reporting on generic argument mismatchs) - #122619 (Fix some unsoundness with PassMode::Cast ABI) - #122964 (Rename `expose_addr` to `expose_provenance`) - #123291 (Move some tests) - #123301 (pattern analysis: fix union handling) - #123395 (More postfix match fixes) - #123419 (rustc_index: Add a `ZERO` constant to index types) - #123421 (Fix target name in NetBSD platform-support doc) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-03rustc_index: Add a `ZERO` constant to index typesVadim Petrochenkov-2/+2
It is commonly used.
2024-04-03hir: Drop owner's own item-local id (zero) from parenting tablesVadim Petrochenkov-1/+3
2024-03-22Rename `hir::Node::Local` into `hir::Node::LetStmt`Guillaume Gomez-1/+1
2024-03-22Rename `hir::Local` into `hir::LetStmt`Guillaume Gomez-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-13Create some minimal HIR for associated opaque typesVadim Petrochenkov-0/+1
2024-02-07hir: Add some FIXMEs for future workVadim Petrochenkov-0/+1
2024-02-07hir: Make sure all `HirId`s have corresponding HIR `Node`sVadim Petrochenkov-6/+36
2023-12-18Replace some instances of FxHashMap/FxHashSet with stable alternatives ↵Michael Woerister-5/+4
(mostly in rustc_hir and rustc_ast_lowering) Part of https://github.com/rust-lang/compiler-team/issues/533
2023-12-10remove redundant importssurechen-1/+1
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-11-28Reduce exposure of some things.Nicholas Nethercote-1/+1
2023-11-26merge `DefKind::Coroutine` into `DefKind::Closure`bohan-1/+1
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-1/+1
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-09-02Don't hold the definitions' lock across `index_hir`John Kåre Alsaker-15/+15
2023-06-02Separate AnonConst from ConstBlock in HIR.Camille GILLOT-0/+8
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-1/+1
2023-01-28Take a LocalDefId in hir::Visitor::visit_fn.Camille GILLOT-13/+0
2023-01-17Remove double spaces after dots in commentsMaybe Waffle-1/+1