mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-26 17:57:19 +00:00
Merge pull request #19343 from flodiebold/push-tmumzoxxmxsr
Make GenericParamsCollector::type_or_consts not unnecessarily pub(crate)
This commit is contained in:
commit
8d01570b5e
2 changed files with 15 additions and 10 deletions
|
|
@ -10,6 +10,7 @@ use hir_expand::{
|
||||||
name::{AsName, Name},
|
name::{AsName, Name},
|
||||||
ExpandResult,
|
ExpandResult,
|
||||||
};
|
};
|
||||||
|
use intern::sym;
|
||||||
use la_arena::{Arena, RawIdx};
|
use la_arena::{Arena, RawIdx};
|
||||||
use stdx::{
|
use stdx::{
|
||||||
impl_from,
|
impl_from,
|
||||||
|
|
@ -446,12 +447,23 @@ impl GenericParams {
|
||||||
|
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
pub(crate) struct GenericParamsCollector {
|
pub(crate) struct GenericParamsCollector {
|
||||||
pub(crate) type_or_consts: Arena<TypeOrConstParamData>,
|
type_or_consts: Arena<TypeOrConstParamData>,
|
||||||
lifetimes: Arena<LifetimeParamData>,
|
lifetimes: Arena<LifetimeParamData>,
|
||||||
where_predicates: Vec<WherePredicate>,
|
where_predicates: Vec<WherePredicate>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GenericParamsCollector {
|
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(
|
pub(crate) fn fill(
|
||||||
&mut self,
|
&mut self,
|
||||||
lower_ctx: &mut LowerCtx<'_>,
|
lower_ctx: &mut LowerCtx<'_>,
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ use triomphe::Arc;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::DefDatabase,
|
db::DefDatabase,
|
||||||
generics::{GenericParams, GenericParamsCollector, TypeParamData, TypeParamProvenance},
|
generics::{GenericParams, GenericParamsCollector},
|
||||||
item_tree::{
|
item_tree::{
|
||||||
AssocItem, AttrOwner, Const, Either, Enum, ExternBlock, ExternCrate, Field, FieldParent,
|
AssocItem, AttrOwner, Const, Either, Enum, ExternBlock, ExternCrate, Field, FieldParent,
|
||||||
FieldsShape, FileItemTreeId, FnFlags, Function, GenericArgs, GenericItemSourceMapBuilder,
|
FieldsShape, FileItemTreeId, FnFlags, Function, GenericArgs, GenericItemSourceMapBuilder,
|
||||||
|
|
@ -881,14 +881,7 @@ impl<'a> Ctx<'a> {
|
||||||
|
|
||||||
if let HasImplicitSelf::Yes(bounds) = has_implicit_self {
|
if let HasImplicitSelf::Yes(bounds) = has_implicit_self {
|
||||||
// Traits and trait aliases get the Self type as an implicit first type parameter.
|
// Traits and trait aliases get the Self type as an implicit first type parameter.
|
||||||
generics.type_or_consts.alloc(
|
generics.fill_self_param();
|
||||||
TypeParamData {
|
|
||||||
name: Some(Name::new_symbol_root(sym::Self_.clone())),
|
|
||||||
default: None,
|
|
||||||
provenance: TypeParamProvenance::TraitSelf,
|
|
||||||
}
|
|
||||||
.into(),
|
|
||||||
);
|
|
||||||
// add super traits as bounds on Self
|
// add super traits as bounds on Self
|
||||||
// i.e., `trait Foo: Bar` is equivalent to `trait Foo where Self: Bar`
|
// 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(
|
let bound_target = Either::Left(body_ctx.alloc_type_ref_desugared(TypeRef::Path(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue