aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/generics.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-10-30 14:19:30 +0000
committerAleksey Kladov <[email protected]>2019-10-30 14:43:14 +0000
commitf8ddef875af08f6c67fe69f7803f3926bc6f66bb (patch)
treeed4704070c4e5bb9db7225b1f5af753b83864661 /crates/ra_hir/src/generics.rs
parent16e620c052016010b2f17070a98bdc1e7e849ab3 (diff)
remove forward pointer for name
Diffstat (limited to 'crates/ra_hir/src/generics.rs')
-rw-r--r--crates/ra_hir/src/generics.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/crates/ra_hir/src/generics.rs b/crates/ra_hir/src/generics.rs
index 4ce7551c3..61786a614 100644
--- a/crates/ra_hir/src/generics.rs
+++ b/crates/ra_hir/src/generics.rs
@@ -5,15 +5,15 @@
5 5
6use std::sync::Arc; 6use std::sync::Arc;
7 7
8use hir_def::name::{self, AsName};
8use ra_syntax::ast::{self, DefaultTypeParamOwner, NameOwner, TypeBoundsOwner, TypeParamsOwner}; 9use ra_syntax::ast::{self, DefaultTypeParamOwner, NameOwner, TypeBoundsOwner, TypeParamsOwner};
9 10
10use crate::{ 11use crate::{
11 db::{AstDatabase, DefDatabase, HirDatabase}, 12 db::{AstDatabase, DefDatabase, HirDatabase},
12 name::SELF_TYPE,
13 path::Path, 13 path::Path,
14 type_ref::{TypeBound, TypeRef}, 14 type_ref::{TypeBound, TypeRef},
15 Adt, AsName, Const, Container, Enum, EnumVariant, Function, HasSource, ImplBlock, Name, Struct, 15 Adt, Const, Container, Enum, EnumVariant, Function, HasSource, ImplBlock, Name, Struct, Trait,
16 Trait, TypeAlias, Union, 16 TypeAlias, Union,
17}; 17};
18 18
19/// Data about a generic parameter (to a function, struct, impl, ...). 19/// Data about a generic parameter (to a function, struct, impl, ...).
@@ -94,11 +94,15 @@ impl GenericParams {
94 GenericDef::Adt(Adt::Enum(it)) => generics.fill(&it.source(db).ast, start), 94 GenericDef::Adt(Adt::Enum(it)) => generics.fill(&it.source(db).ast, start),
95 GenericDef::Trait(it) => { 95 GenericDef::Trait(it) => {
96 // traits get the Self type as an implicit first type parameter 96 // traits get the Self type as an implicit first type parameter
97 generics.params.push(GenericParam { idx: start, name: SELF_TYPE, default: None }); 97 generics.params.push(GenericParam {
98 idx: start,
99 name: name::SELF_TYPE,
100 default: None,
101 });
98 generics.fill(&it.source(db).ast, start + 1); 102 generics.fill(&it.source(db).ast, start + 1);
99 // add super traits as bounds on Self 103 // add super traits as bounds on Self
100 // i.e., trait Foo: Bar is equivalent to trait Foo where Self: Bar 104 // i.e., trait Foo: Bar is equivalent to trait Foo where Self: Bar
101 let self_param = TypeRef::Path(SELF_TYPE.into()); 105 let self_param = TypeRef::Path(name::SELF_TYPE.into());
102 generics.fill_bounds(&it.source(db).ast, self_param); 106 generics.fill_bounds(&it.source(db).ast, self_param);
103 } 107 }
104 GenericDef::TypeAlias(it) => generics.fill(&it.source(db).ast, start), 108 GenericDef::TypeAlias(it) => generics.fill(&it.source(db).ast, start),