mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Minor
This commit is contained in:
parent
a3eb878745
commit
d75f768c13
1 changed files with 4 additions and 3 deletions
|
@ -58,11 +58,12 @@ impl GenericParams {
|
||||||
GenericDefId::TraitId(it) => {
|
GenericDefId::TraitId(it) => {
|
||||||
// traits get the Self type as an implicit first type parameter
|
// traits get the Self type as an implicit first type parameter
|
||||||
generics.params.alloc(GenericParamData { name: name::SELF_TYPE, default: None });
|
generics.params.alloc(GenericParamData { name: name::SELF_TYPE, default: None });
|
||||||
generics.fill(&it.source(db).value);
|
|
||||||
// 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 self_param = TypeRef::Path(name::SELF_TYPE.into());
|
let self_param = TypeRef::Path(name::SELF_TYPE.into());
|
||||||
generics.fill_bounds(&it.source(db).value, self_param);
|
generics.fill_bounds(&it.source(db).value, self_param);
|
||||||
|
|
||||||
|
generics.fill(&it.source(db).value);
|
||||||
}
|
}
|
||||||
GenericDefId::TypeAliasId(it) => generics.fill(&it.lookup(db).source(db).value),
|
GenericDefId::TypeAliasId(it) => generics.fill(&it.lookup(db).source(db).value),
|
||||||
// Note that we don't add `Self` here: in `impl`s, `Self` is not a
|
// Note that we don't add `Self` here: in `impl`s, `Self` is not a
|
||||||
|
@ -75,7 +76,7 @@ impl GenericParams {
|
||||||
generics
|
generics
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fill(&mut self, node: &impl TypeParamsOwner) {
|
fn fill(&mut self, node: &dyn TypeParamsOwner) {
|
||||||
if let Some(params) = node.type_param_list() {
|
if let Some(params) = node.type_param_list() {
|
||||||
self.fill_params(params)
|
self.fill_params(params)
|
||||||
}
|
}
|
||||||
|
@ -84,7 +85,7 @@ impl GenericParams {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fill_bounds(&mut self, node: &impl ast::TypeBoundsOwner, type_ref: TypeRef) {
|
fn fill_bounds(&mut self, node: &dyn ast::TypeBoundsOwner, type_ref: TypeRef) {
|
||||||
for bound in
|
for bound in
|
||||||
node.type_bound_list().iter().flat_map(|type_bound_list| type_bound_list.bounds())
|
node.type_bound_list().iter().flat_map(|type_bound_list| type_bound_list.bounds())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue