rust/compiler/rustc_hir/src
bors f242d6c26c Auto merge of #127516 - nnethercote:simplify-LazyAttrTokenStream, r=petrochenkov
Simplify `LazyAttrTokenStream`

`LazyAttrTokenStream` is an unpleasant type: `Lrc<Box<dyn ToAttrTokenStream>>`. Why does it look like that?
- There are two `ToAttrTokenStream` impls, one for the lazy case, and one for the case where we already have an `AttrTokenStream`.
- The lazy case (`LazyAttrTokenStreamImpl`) is implemented in `rustc_parse`, but `LazyAttrTokenStream` is defined in `rustc_ast`, which does not depend on `rustc_parse`. The use of the trait lets `rustc_ast` implicitly depend on `rustc_parse`. This explains the `dyn`.
- `LazyAttrTokenStream` must have a `size_of` as small as possible, because it's used in many AST nodes. This explains the `Lrc<Box<_>>`, which keeps it to one word. (It's required `Lrc<dyn _>` would be a fat pointer.)

This PR moves `LazyAttrTokenStreamImpl` (and a few other token stream things) from `rustc_parse` to `rustc_ast`. This lets us replace the `ToAttrTokenStream` trait with a two-variant enum and also remove the `Box`, changing `LazyAttrTokenStream` to `Lrc<LazyAttrTokenStreamInner>`. Plus it does a few cleanups.

r? `@petrochenkov`
2025-04-30 00:09:21 +00:00
..
hir Extend HIR to track the source and syntax of a lifetime 2025-04-23 16:37:39 -04:00
arena.rs Add hir::Attribute 2024-12-15 19:18:46 +01:00
def.rs Introduce DefPathData::AnonAssocTy. 2025-04-11 19:08:14 +10:00
def_path_hash_map.rs Move hashes from rustc_data_structure to rustc_hashes so they can be shared with rust-analyzer 2025-02-16 16:18:30 -05:00
definitions.rs Use newtype_index!-generated types more idiomatically 2025-04-14 16:17:06 +00:00
diagnostic_items.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
hir.rs Add or-patterns to pattern types 2025-04-28 07:50:18 +00:00
hir_id.rs impl !PartialOrd for HirId 2025-04-03 09:22:21 +00:00
intravisit.rs Add or-patterns to pattern types 2025-04-28 07:50:18 +00:00
lang_items.rs AsyncDrop implementation using shim codegen of async_drop_in_place::{closure}, scoped async drop added. 2025-04-28 16:23:13 +07:00
lib.rs Simplify LazyAttrTokenStream. 2025-04-30 07:10:56 +10:00
pat_util.rs Eliminate PatKind::Path 2025-01-29 15:45:13 +00:00
stable_hash_impls.rs Implement #[define_opaque] attribute for functions. 2025-03-11 12:05:02 +00:00
target.rs Implment #[cfg] and #[cfg_attr] in where clauses 2025-03-01 22:02:46 +08:00
tests.rs Allow drivers to supply a list of extra symbols to intern 2025-04-10 13:39:23 +00:00
weak_lang_items.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00