diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-10-30 15:07:12 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-10-30 15:07:12 +0000 |
commit | 5806195bc1cdb1ca3fa257e99fd6e0dd897713a9 (patch) | |
tree | 92b54891047977e6483e430a467d8e561ea3bc53 /crates/ra_hir/src/generics.rs | |
parent | f996b6019bd2f388bd9994ea83f25487eb111560 (diff) | |
parent | e34e71c62d9b4cf0ab237969e03ecde893ab347b (diff) |
Merge #2128
2128: move raw_items to hir_def r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/generics.rs')
-rw-r--r-- | crates/ra_hir/src/generics.rs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/crates/ra_hir/src/generics.rs b/crates/ra_hir/src/generics.rs index 4ce7551c3..9d5d18564 100644 --- a/crates/ra_hir/src/generics.rs +++ b/crates/ra_hir/src/generics.rs | |||
@@ -5,15 +5,17 @@ | |||
5 | 5 | ||
6 | use std::sync::Arc; | 6 | use std::sync::Arc; |
7 | 7 | ||
8 | use hir_def::{ | ||
9 | name::{self, AsName}, | ||
10 | path::Path, | ||
11 | type_ref::{TypeBound, TypeRef}, | ||
12 | }; | ||
8 | use ra_syntax::ast::{self, DefaultTypeParamOwner, NameOwner, TypeBoundsOwner, TypeParamsOwner}; | 13 | use ra_syntax::ast::{self, DefaultTypeParamOwner, NameOwner, TypeBoundsOwner, TypeParamsOwner}; |
9 | 14 | ||
10 | use crate::{ | 15 | use crate::{ |
11 | db::{AstDatabase, DefDatabase, HirDatabase}, | 16 | db::{AstDatabase, DefDatabase, HirDatabase}, |
12 | name::SELF_TYPE, | 17 | Adt, Const, Container, Enum, EnumVariant, Function, HasSource, ImplBlock, Name, Struct, Trait, |
13 | path::Path, | 18 | TypeAlias, Union, |
14 | type_ref::{TypeBound, TypeRef}, | ||
15 | Adt, AsName, Const, Container, Enum, EnumVariant, Function, HasSource, ImplBlock, Name, Struct, | ||
16 | Trait, TypeAlias, Union, | ||
17 | }; | 19 | }; |
18 | 20 | ||
19 | /// Data about a generic parameter (to a function, struct, impl, ...). | 21 | /// Data about a generic parameter (to a function, struct, impl, ...). |
@@ -94,11 +96,15 @@ impl GenericParams { | |||
94 | GenericDef::Adt(Adt::Enum(it)) => generics.fill(&it.source(db).ast, start), | 96 | GenericDef::Adt(Adt::Enum(it)) => generics.fill(&it.source(db).ast, start), |
95 | GenericDef::Trait(it) => { | 97 | GenericDef::Trait(it) => { |
96 | // traits get the Self type as an implicit first type parameter | 98 | // traits get the Self type as an implicit first type parameter |
97 | generics.params.push(GenericParam { idx: start, name: SELF_TYPE, default: None }); | 99 | generics.params.push(GenericParam { |
100 | idx: start, | ||
101 | name: name::SELF_TYPE, | ||
102 | default: None, | ||
103 | }); | ||
98 | generics.fill(&it.source(db).ast, start + 1); | 104 | generics.fill(&it.source(db).ast, start + 1); |
99 | // add super traits as bounds on Self | 105 | // add super traits as bounds on Self |
100 | // i.e., trait Foo: Bar is equivalent to trait Foo where Self: Bar | 106 | // i.e., trait Foo: Bar is equivalent to trait Foo where Self: Bar |
101 | let self_param = TypeRef::Path(SELF_TYPE.into()); | 107 | let self_param = TypeRef::Path(name::SELF_TYPE.into()); |
102 | generics.fill_bounds(&it.source(db).ast, self_param); | 108 | generics.fill_bounds(&it.source(db).ast, self_param); |
103 | } | 109 | } |
104 | GenericDef::TypeAlias(it) => generics.fill(&it.source(db).ast, start), | 110 | GenericDef::TypeAlias(it) => generics.fill(&it.source(db).ast, start), |