rust/compiler/rustc_resolve/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
..
late Move name field from AssocItem to AssocKind variants. 2025-04-15 08:07:15 +10:00
build_reduced_graph.rs Avoid storing the LocalDefId twice 2025-04-11 10:04:27 +00:00
check_unused.rs Move ast::Item::ident into ast::ItemKind. 2025-04-01 14:08:57 +11:00
def_collector.rs Address review comments. 2025-04-01 16:07:23 +11:00
diagnostics.rs Avoid a reverse map that is only used in diagnostics paths 2025-04-11 09:33:38 +00:00
effective_visibilities.rs Move ast::Item::ident into ast::ItemKind. 2025-04-01 14:08:57 +11:00
errors.rs Allow builtin macros to be used more than once. 2025-03-19 14:12:47 +01:00
ident.rs Avoid an empty trait name in impl blocks. 2025-04-09 15:01:14 +10:00
imports.rs Use a dummy ident for a lint_if_path_starts_with_module call. 2025-04-15 16:05:13 +10:00
late.rs Add or-patterns to pattern types 2025-04-28 07:50:18 +00:00
lib.rs Simplify LazyAttrTokenStream. 2025-04-30 07:10:56 +10:00
macros.rs Remove #[rustc_macro_edition_2021]. 2025-04-20 11:15:46 +02:00
rustdoc.rs rustc_resolve: prevent iteration of refids for completeness 2025-03-27 12:39:48 -04:00