Skip to content

Commit 8d01570

Browse files
authored
Merge pull request #19343 from flodiebold/push-tmumzoxxmxsr
Make GenericParamsCollector::type_or_consts not unnecessarily pub(crate)
2 parents 44f18c3 + 9780734 commit 8d01570

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

crates/hir-def/src/generics.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use hir_expand::{
1010
name::{AsName, Name},
1111
ExpandResult,
1212
};
13+
use intern::sym;
1314
use la_arena::{Arena, RawIdx};
1415
use stdx::{
1516
impl_from,
@@ -446,12 +447,23 @@ impl GenericParams {
446447

447448
#[derive(Clone, Default)]
448449
pub(crate) struct GenericParamsCollector {
449-
pub(crate) type_or_consts: Arena<TypeOrConstParamData>,
450+
type_or_consts: Arena<TypeOrConstParamData>,
450451
lifetimes: Arena<LifetimeParamData>,
451452
where_predicates: Vec<WherePredicate>,
452453
}
453454

454455
impl GenericParamsCollector {
456+
pub(crate) fn fill_self_param(&mut self) {
457+
self.type_or_consts.alloc(
458+
TypeParamData {
459+
name: Some(Name::new_symbol_root(sym::Self_.clone())),
460+
default: None,
461+
provenance: TypeParamProvenance::TraitSelf,
462+
}
463+
.into(),
464+
);
465+
}
466+
455467
pub(crate) fn fill(
456468
&mut self,
457469
lower_ctx: &mut LowerCtx<'_>,

crates/hir-def/src/item_tree/lower.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use triomphe::Arc;
2121

2222
use crate::{
2323
db::DefDatabase,
24-
generics::{GenericParams, GenericParamsCollector, TypeParamData, TypeParamProvenance},
24+
generics::{GenericParams, GenericParamsCollector},
2525
item_tree::{
2626
AssocItem, AttrOwner, Const, Either, Enum, ExternBlock, ExternCrate, Field, FieldParent,
2727
FieldsShape, FileItemTreeId, FnFlags, Function, GenericArgs, GenericItemSourceMapBuilder,
@@ -881,14 +881,7 @@ impl<'a> Ctx<'a> {
881881

882882
if let HasImplicitSelf::Yes(bounds) = has_implicit_self {
883883
// Traits and trait aliases get the Self type as an implicit first type parameter.
884-
generics.type_or_consts.alloc(
885-
TypeParamData {
886-
name: Some(Name::new_symbol_root(sym::Self_.clone())),
887-
default: None,
888-
provenance: TypeParamProvenance::TraitSelf,
889-
}
890-
.into(),
891-
);
884+
generics.fill_self_param();
892885
// add super traits as bounds on Self
893886
// i.e., `trait Foo: Bar` is equivalent to `trait Foo where Self: Bar`
894887
let bound_target = Either::Left(body_ctx.alloc_type_ref_desugared(TypeRef::Path(

0 commit comments

Comments
 (0)