This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree 4 files changed +15
-12
lines changed 4 files changed +15
-12
lines changed Original file line number Diff line number Diff line change @@ -355,7 +355,7 @@ fn parse_comma_sep<S>(subtree: &tt::Subtree<S>) -> Vec<SmolStr> {
355
355
}
356
356
357
357
impl AttrsWithOwner {
358
- pub ( crate ) fn attrs_with_owner ( db : & dyn DefDatabase , owner : AttrDefId ) -> Self {
358
+ pub fn attrs_with_owner ( db : & dyn DefDatabase , owner : AttrDefId ) -> Self {
359
359
Self { attrs : db. attrs ( owner) , owner }
360
360
}
361
361
Original file line number Diff line number Diff line change @@ -214,10 +214,6 @@ pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDataba
214
214
#[ salsa:: invoke( lang_item:: lang_attr_query) ]
215
215
fn lang_attr ( & self , def : AttrDefId ) -> Option < LangItem > ;
216
216
217
- #[ salsa:: transparent]
218
- #[ salsa:: invoke( AttrsWithOwner :: attrs_with_owner) ]
219
- fn attrs_with_owner ( & self , def : AttrDefId ) -> AttrsWithOwner ;
220
-
221
217
// endregion:attrs
222
218
223
219
#[ salsa:: invoke( LangItems :: lang_item_query) ]
@@ -241,7 +237,7 @@ pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDataba
241
237
// endregion:visibilities
242
238
243
239
#[ salsa:: invoke( LangItems :: crate_lang_items_query) ]
244
- fn crate_lang_items ( & self , krate : CrateId ) -> Arc < LangItems > ;
240
+ fn crate_lang_items ( & self , krate : CrateId ) -> Option < Arc < LangItems > > ;
245
241
246
242
fn crate_supports_no_std ( & self , crate_id : CrateId ) -> bool ;
247
243
}
Original file line number Diff line number Diff line change @@ -87,7 +87,10 @@ impl LangItems {
87
87
}
88
88
89
89
/// Salsa query. This will look for lang items in a specific crate.
90
- pub ( crate ) fn crate_lang_items_query ( db : & dyn DefDatabase , krate : CrateId ) -> Arc < LangItems > {
90
+ pub ( crate ) fn crate_lang_items_query (
91
+ db : & dyn DefDatabase ,
92
+ krate : CrateId ,
93
+ ) -> Option < Arc < LangItems > > {
91
94
let _p = profile:: span ( "crate_lang_items_query" ) ;
92
95
93
96
let mut lang_items = LangItems :: default ( ) ;
@@ -150,7 +153,11 @@ impl LangItems {
150
153
}
151
154
}
152
155
153
- Arc :: new ( lang_items)
156
+ if lang_items. items . is_empty ( ) {
157
+ None
158
+ } else {
159
+ Some ( Arc :: new ( lang_items) )
160
+ }
154
161
}
155
162
156
163
/// Salsa query. Look for a lang item, starting from the specified crate and recursively
@@ -161,9 +168,9 @@ impl LangItems {
161
168
item : LangItem ,
162
169
) -> Option < LangItemTarget > {
163
170
let _p = profile:: span ( "lang_item_query" ) ;
164
- let lang_items = db . crate_lang_items ( start_crate ) ;
165
- let start_crate_target = lang_items . items . get ( & item) ;
166
- if let Some ( & target ) = start_crate_target {
171
+ if let Some ( target ) =
172
+ db . crate_lang_items ( start_crate ) . and_then ( |it| it . items . get ( & item) . copied ( ) )
173
+ {
167
174
return Some ( target) ;
168
175
}
169
176
db. crate_graph ( ) [ start_crate]
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ macro_rules! impl_has_attrs {
35
35
impl HasAttrs for $def {
36
36
fn attrs( self , db: & dyn HirDatabase ) -> AttrsWithOwner {
37
37
let def = AttrDefId :: $def_id( self . into( ) ) ;
38
- db. attrs_with_owner ( def)
38
+ AttrsWithOwner :: attrs_with_owner ( db. upcast ( ) , def)
39
39
}
40
40
fn attr_id( self ) -> AttrDefId {
41
41
AttrDefId :: $def_id( self . into( ) )
You can’t perform that action at this time.
0 commit comments