diff options
| author | Florian Diebold <flodiebold@googlemail.com> | 2025-03-11 14:26:24 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-11 14:26:24 +0000 |
| commit | 74220a6f80fcfea25f77cb9285492a1fab928191 (patch) | |
| tree | f5f4afb34bbd92b537a4be30f6ee624293e3809b | |
| parent | da0e2786476d7794873d1efbb9ad302033ed7b81 (diff) | |
| parent | 521fa18d5d6fd01e6cfb37d61471c26d0f6d3998 (diff) | |
| download | rust-74220a6f80fcfea25f77cb9285492a1fab928191.tar.gz rust-74220a6f80fcfea25f77cb9285492a1fab928191.zip | |
Merge pull request #19343 from flodiebold/push-tmumzoxxmxsr
Make GenericParamsCollector::type_or_consts not unnecessarily pub(crate)
| -rw-r--r-- | src/tools/rust-analyzer/crates/hir-def/src/generics.rs | 14 | ||||
| -rw-r--r-- | src/tools/rust-analyzer/crates/hir-def/src/item_tree/lower.rs | 11 |
2 files changed, 15 insertions, 10 deletions
diff --git a/src/tools/rust-analyzer/crates/hir-def/src/generics.rs b/src/tools/rust-analyzer/crates/hir-def/src/generics.rs index 80820193796..ed5038c5aeb 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/generics.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/generics.rs @@ -10,6 +10,7 @@ use hir_expand::{ name::{AsName, Name}, ExpandResult, }; +use intern::sym; use la_arena::{Arena, RawIdx}; use stdx::{ impl_from, @@ -446,12 +447,23 @@ impl GenericParams { #[derive(Clone, Default)] pub(crate) struct GenericParamsCollector { - pub(crate) type_or_consts: Arena<TypeOrConstParamData>, + type_or_consts: Arena<TypeOrConstParamData>, lifetimes: Arena<LifetimeParamData>, where_predicates: Vec<WherePredicate>, } impl GenericParamsCollector { + pub(crate) fn fill_self_param(&mut self) { + self.type_or_consts.alloc( + TypeParamData { + name: Some(Name::new_symbol_root(sym::Self_.clone())), + default: None, + provenance: TypeParamProvenance::TraitSelf, + } + .into(), + ); + } + pub(crate) fn fill( &mut self, lower_ctx: &mut LowerCtx<'_>, diff --git a/src/tools/rust-analyzer/crates/hir-def/src/item_tree/lower.rs b/src/tools/rust-analyzer/crates/hir-def/src/item_tree/lower.rs index 71848845a84..b0546d4f33f 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/item_tree/lower.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/item_tree/lower.rs @@ -21,7 +21,7 @@ use triomphe::Arc; use crate::{ db::DefDatabase, - generics::{GenericParams, GenericParamsCollector, TypeParamData, TypeParamProvenance}, + generics::{GenericParams, GenericParamsCollector}, item_tree::{ AssocItem, AttrOwner, Const, Either, Enum, ExternBlock, ExternCrate, Field, FieldParent, FieldsShape, FileItemTreeId, FnFlags, Function, GenericArgs, GenericItemSourceMapBuilder, @@ -881,14 +881,7 @@ impl<'a> Ctx<'a> { if let HasImplicitSelf::Yes(bounds) = has_implicit_self { // Traits and trait aliases get the Self type as an implicit first type parameter. - generics.type_or_consts.alloc( - TypeParamData { - name: Some(Name::new_symbol_root(sym::Self_.clone())), - default: None, - provenance: TypeParamProvenance::TraitSelf, - } - .into(), - ); + generics.fill_self_param(); // add super traits as bounds on Self // i.e., `trait Foo: Bar` is equivalent to `trait Foo where Self: Bar` let bound_target = Either::Left(body_ctx.alloc_type_ref_desugared(TypeRef::Path( |
