about summary refs log tree commit diff
path: root/compiler/rustc_hir/src/arena.rs
AgeCommit message (Collapse)AuthorLines
2025-06-30Introduce `ByteSymbol`.Nicholas Nethercote-1/+0
It's like `Symbol` but for byte strings. The interner is now used for both `Symbol` and `ByteSymbol`. E.g. if you intern `"dog"` and `b"dog"` you'll get a `Symbol` and a `ByteSymbol` with the same index and the characters will only be stored once. The motivation for this is to eliminate the `Arc`s in `ast::LitKind`, to make `ast::LitKind` impl `Copy`, and to avoid the need to arena-allocate `ast::LitKind` in HIR. The latter change reduces peak memory by a non-trivial amount on literal-heavy benchmarks such as `deep-vector` and `tuple-stress`. `Encoder`, `Decoder`, `SpanEncoder`, and `SpanDecoder` all get some changes so that they can handle normal strings and byte strings. This change does slow down compilation of programs that use `include_bytes!` on large files, because the contents of those files are now interned (hashed). This makes `include_bytes!` more similar to `include_str!`, though `include_bytes!` contents still aren't escaped, and hashing is still much cheaper than escaping.
2025-06-03Overhaul `UsePath`.Nicholas Nethercote-1/+0
`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.
2024-12-15Add hir::AttributeJonathan Dönszelmann-1/+1
2023-11-20Remove unused arena kinds in `rustc_hir` and `rustc_middle`.Nicholas Nethercote-1/+0
2023-04-22Also arena-allocate `ast::MacroDef` to make `Item: Copy`Nilstrieb-1/+1
2023-04-22Impl `Copy` for almost all HIR typesNilstrieb-41/+1
This simplifies the invocation of the `arena_types` macro and probably makes working with HIR nicer in general.
2023-04-16Alloc `hir::Lit` in an arena to remove the destructor from `Expr`Nilstrieb-0/+1
This allows allocating `Expr`s into a dropless arena, which is useful for using length prefixed thing slices in HIR, since these can only be allocated in the dropless arena and not in a typed arena. This is something I'm working on.
2022-12-01rustc_hir: Change representation of import paths to support multiple resolutionsVadim Petrochenkov-0/+1
2022-07-12Add an indirection for closures in `hir::ExprKind`Maybe Waffle-0/+1
This helps bring `hir::Expr` size down, `Closure` was the biggest variant, especially after `for<>` additions.
2022-07-06Make AST lowering a query.Camille GILLOT-1/+1
2022-04-30Box HIR Generics and Impl.Camille GILLOT-0/+2
2022-01-12Remove deprecated LLVM-style inline assemblyTomasz Miąsko-1/+0
2021-12-13let-else: add hir::Let and type check it like a hir::LocalCormac Relf-0/+1
unify typeck of hir::Local and hir::Let remove extraneous pub(crate/super)
2021-11-19Add some comments.Nicholas Nethercote-1/+1
Also use `Default::default()` in one `TypedArena::default()`, for consistency with `DroplessArena::default()`.
2021-11-17Remove unnecessary lifetime argument from arena macros.Nicholas Nethercote-37/+37
Because it's always `'tcx`. In fact, some of them use a mixture of passed-in `$tcx` and hard-coded `'tcx`, so no other lifetime would even work. This makes the code easier to read.
2021-11-15Remove `DropArena`.Nicholas Nethercote-10/+5
Most arena-allocate types that impl `Drop` get their own `TypedArena`, but a few infrequently used ones share a `DropArena`. This sharing adds complexity but doesn't help performance or memory usage. Perhaps it was more effective in the past prior to some other improvements to arenas. This commit removes `DropArena` and the sharing of arenas via the `few` attribute of the `arena_types` macro. This change removes over 100 lines of code and nine uses of `unsafe` (one of which affects the parallel compiler) and makes the remaining code easier to read.
2021-10-09Perform indexing during lowering.Camille GILLOT-0/+1
Do not access DefId<->HirId maps before they are initialized.
2021-10-09Use an IndexVec for bodies.Camille GILLOT-0/+1
2021-09-20Do not store visibility in *ItemRef.Camille GILLOT-2/+2
2021-08-30Remove unused arena macro argsbjorn3-2/+2
2021-08-28Treat macros as HIR itemsinquisitivecrystal-1/+0
2021-07-25Introduce OwnerNode::Crate.Camille GILLOT-0/+1
2021-07-25Merge the BTreeMap in hir::Crate.Camille GILLOT-0/+3
2021-06-01Revert "Reduce the amount of untracked state in TyCtxt"Camille Gillot-1/+0
2021-05-30Remove StableVec.Camille GILLOT-0/+1
2021-05-13Add support for const operands and options to global_asm!Amanieu d'Antras-1/+0
On x86, the default syntax is also switched to Intel to match asm!
2021-03-16ast/hir: Rename field-related structuresVadim Petrochenkov-3/+3
StructField -> FieldDef ("field definition") Field -> ExprField ("expression field", not "field expression") FieldPat -> PatField ("pattern field", not "field pattern") Also rename visiting and other methods working on them.
2020-12-06Retain assembly operands span when lowering AST to HIRTomasz Miąsko-1/+1
2020-11-26Formatting.Camille GILLOT-1/+1
2020-11-26Store ForeignItem in a side table.Camille GILLOT-0/+1
2020-08-30mv compiler to compiler/mark-0/+52