@@ -34,7 +34,8 @@ pub struct FunctionData {
34
34
35
35
impl FunctionData {
36
36
pub ( crate ) fn fn_data_query ( db : & impl DefDatabase , func : FunctionId ) -> Arc < FunctionData > {
37
- let src = func. lookup ( db) . source ( db) ;
37
+ let loc = func. lookup ( db) ;
38
+ let src = loc. source ( db) ;
38
39
let name = src. value . name ( ) . map ( |n| n. as_name ( ) ) . unwrap_or_else ( Name :: missing) ;
39
40
let mut params = Vec :: new ( ) ;
40
41
let mut has_self_param = false ;
@@ -76,7 +77,9 @@ impl FunctionData {
76
77
ret_type
77
78
} ;
78
79
79
- let visibility = RawVisibility :: from_ast ( db, src. map ( |s| s. visibility ( ) ) ) ;
80
+ let vis_default = RawVisibility :: default_for_container ( loc. container ) ;
81
+ let visibility =
82
+ RawVisibility :: from_ast_with_default ( db, vis_default, src. map ( |s| s. visibility ( ) ) ) ;
80
83
81
84
let sig = FunctionData { name, params, ret_type, has_self_param, visibility } ;
82
85
Arc :: new ( sig)
@@ -105,10 +108,13 @@ impl TypeAliasData {
105
108
db : & impl DefDatabase ,
106
109
typ : TypeAliasId ,
107
110
) -> Arc < TypeAliasData > {
108
- let node = typ. lookup ( db) . source ( db) ;
111
+ let loc = typ. lookup ( db) ;
112
+ let node = loc. source ( db) ;
109
113
let name = node. value . name ( ) . map_or_else ( Name :: missing, |n| n. as_name ( ) ) ;
110
114
let type_ref = node. value . type_ref ( ) . map ( TypeRef :: from_ast) ;
111
- let visibility = RawVisibility :: from_ast ( db, node. map ( |n| n. visibility ( ) ) ) ;
115
+ let vis_default = RawVisibility :: default_for_container ( loc. container ) ;
116
+ let visibility =
117
+ RawVisibility :: from_ast_with_default ( db, vis_default, node. map ( |n| n. visibility ( ) ) ) ;
112
118
Arc :: new ( TypeAliasData { name, type_ref, visibility } )
113
119
}
114
120
}
@@ -230,22 +236,26 @@ pub struct ConstData {
230
236
231
237
impl ConstData {
232
238
pub ( crate ) fn const_data_query ( db : & impl DefDatabase , konst : ConstId ) -> Arc < ConstData > {
233
- let node = konst. lookup ( db) . source ( db) ;
234
- Arc :: new ( ConstData :: new ( db, node) )
239
+ let loc = konst. lookup ( db) ;
240
+ let node = loc. source ( db) ;
241
+ let vis_default = RawVisibility :: default_for_container ( loc. container ) ;
242
+ Arc :: new ( ConstData :: new ( db, vis_default, node) )
235
243
}
236
244
237
245
pub ( crate ) fn static_data_query ( db : & impl DefDatabase , konst : StaticId ) -> Arc < ConstData > {
238
246
let node = konst. lookup ( db) . source ( db) ;
239
- Arc :: new ( ConstData :: new ( db, node) )
247
+ Arc :: new ( ConstData :: new ( db, RawVisibility :: private ( ) , node) )
240
248
}
241
249
242
250
fn new < N : NameOwner + TypeAscriptionOwner + VisibilityOwner > (
243
251
db : & impl DefDatabase ,
252
+ vis_default : RawVisibility ,
244
253
node : InFile < N > ,
245
254
) -> ConstData {
246
255
let name = node. value . name ( ) . map ( |n| n. as_name ( ) ) ;
247
256
let type_ref = TypeRef :: from_ast_opt ( node. value . ascribed_type ( ) ) ;
248
- let visibility = RawVisibility :: from_ast ( db, node. map ( |n| n. visibility ( ) ) ) ;
257
+ let visibility =
258
+ RawVisibility :: from_ast_with_default ( db, vis_default, node. map ( |n| n. visibility ( ) ) ) ;
249
259
ConstData { name, type_ref, visibility }
250
260
}
251
261
}
0 commit comments