@@ -9,6 +9,7 @@ use crate::{
9
9
attr:: Attrs ,
10
10
body:: Expander ,
11
11
db:: DefDatabase ,
12
+ intern:: Interned ,
12
13
item_tree:: { AssocItem , FunctionQualifier , ItemTreeId , ModItem , Param } ,
13
14
type_ref:: { TraitRef , TypeBound , TypeRef } ,
14
15
visibility:: RawVisibility ,
@@ -19,8 +20,8 @@ use crate::{
19
20
#[ derive( Debug , Clone , PartialEq , Eq ) ]
20
21
pub struct FunctionData {
21
22
pub name : Name ,
22
- pub params : Vec < TypeRef > ,
23
- pub ret_type : TypeRef ,
23
+ pub params : Vec < Interned < TypeRef > > ,
24
+ pub ret_type : Interned < TypeRef > ,
24
25
pub attrs : Attrs ,
25
26
/// True if the first param is `self`. This is relevant to decide whether this
26
27
/// can be called as a method.
@@ -57,11 +58,11 @@ impl FunctionData {
57
58
params : enabled_params
58
59
. clone ( )
59
60
. filter_map ( |id| match & item_tree[ id] {
60
- Param :: Normal ( ty) => Some ( item_tree [ * ty ] . clone ( ) ) ,
61
+ Param :: Normal ( ty) => Some ( ty . clone ( ) ) ,
61
62
Param :: Varargs => None ,
62
63
} )
63
64
. collect ( ) ,
64
- ret_type : item_tree [ func. ret_type ] . clone ( ) ,
65
+ ret_type : func. ret_type . clone ( ) ,
65
66
attrs : item_tree. attrs ( db, krate, ModItem :: from ( loc. id . value ) . into ( ) ) ,
66
67
has_self_param : func. has_self_param ,
67
68
has_body : func. has_body ,
@@ -76,7 +77,7 @@ impl FunctionData {
76
77
#[ derive( Debug , Clone , PartialEq , Eq ) ]
77
78
pub struct TypeAliasData {
78
79
pub name : Name ,
79
- pub type_ref : Option < TypeRef > ,
80
+ pub type_ref : Option < Interned < TypeRef > > ,
80
81
pub visibility : RawVisibility ,
81
82
pub is_extern : bool ,
82
83
/// Bounds restricting the type alias itself (eg. `type Ty: Bound;` in a trait or impl).
@@ -94,7 +95,7 @@ impl TypeAliasData {
94
95
95
96
Arc :: new ( TypeAliasData {
96
97
name : typ. name . clone ( ) ,
97
- type_ref : typ. type_ref . map ( |id| item_tree [ id ] . clone ( ) ) ,
98
+ type_ref : typ. type_ref . clone ( ) ,
98
99
visibility : item_tree[ typ. visibility ] . clone ( ) ,
99
100
is_extern : typ. is_extern ,
100
101
bounds : typ. bounds . to_vec ( ) ,
@@ -156,8 +157,8 @@ impl TraitData {
156
157
157
158
#[ derive( Debug , Clone , PartialEq , Eq ) ]
158
159
pub struct ImplData {
159
- pub target_trait : Option < TraitRef > ,
160
- pub self_ty : TypeRef ,
160
+ pub target_trait : Option < Interned < TraitRef > > ,
161
+ pub self_ty : Interned < TypeRef > ,
161
162
pub items : Vec < AssocItemId > ,
162
163
pub is_negative : bool ,
163
164
}
@@ -169,8 +170,8 @@ impl ImplData {
169
170
170
171
let item_tree = impl_loc. id . item_tree ( db) ;
171
172
let impl_def = & item_tree[ impl_loc. id . value ] ;
172
- let target_trait = impl_def. target_trait . map ( |id| item_tree [ id ] . clone ( ) ) ;
173
- let self_ty = item_tree [ impl_def. self_ty ] . clone ( ) ;
173
+ let target_trait = impl_def. target_trait . clone ( ) ;
174
+ let self_ty = impl_def. self_ty . clone ( ) ;
174
175
let is_negative = impl_def. is_negative ;
175
176
let module_id = impl_loc. container ;
176
177
let container = AssocContainerId :: ImplId ( id) ;
@@ -195,7 +196,7 @@ impl ImplData {
195
196
pub struct ConstData {
196
197
/// const _: () = ();
197
198
pub name : Option < Name > ,
198
- pub type_ref : TypeRef ,
199
+ pub type_ref : Interned < TypeRef > ,
199
200
pub visibility : RawVisibility ,
200
201
}
201
202
@@ -207,7 +208,7 @@ impl ConstData {
207
208
208
209
Arc :: new ( ConstData {
209
210
name : konst. name . clone ( ) ,
210
- type_ref : item_tree [ konst. type_ref ] . clone ( ) ,
211
+ type_ref : konst. type_ref . clone ( ) ,
211
212
visibility : item_tree[ konst. visibility ] . clone ( ) ,
212
213
} )
213
214
}
@@ -216,7 +217,7 @@ impl ConstData {
216
217
#[ derive( Debug , Clone , PartialEq , Eq ) ]
217
218
pub struct StaticData {
218
219
pub name : Option < Name > ,
219
- pub type_ref : TypeRef ,
220
+ pub type_ref : Interned < TypeRef > ,
220
221
pub visibility : RawVisibility ,
221
222
pub mutable : bool ,
222
223
pub is_extern : bool ,
@@ -230,7 +231,7 @@ impl StaticData {
230
231
231
232
Arc :: new ( StaticData {
232
233
name : Some ( statik. name . clone ( ) ) ,
233
- type_ref : item_tree [ statik. type_ref ] . clone ( ) ,
234
+ type_ref : statik. type_ref . clone ( ) ,
234
235
visibility : item_tree[ statik. visibility ] . clone ( ) ,
235
236
mutable : statik. mutable ,
236
237
is_extern : statik. is_extern ,
0 commit comments