File tree Expand file tree Collapse file tree 4 files changed +15
-12
lines changed Expand file tree Collapse file tree 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> {
355355}
356356
357357impl 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 {
359359 Self { attrs : db. attrs ( owner) , owner }
360360 }
361361
Original file line number Diff line number Diff line change @@ -214,10 +214,6 @@ pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDataba
214214 #[ salsa:: invoke( lang_item:: lang_attr_query) ]
215215 fn lang_attr ( & self , def : AttrDefId ) -> Option < LangItem > ;
216216
217- #[ salsa:: transparent]
218- #[ salsa:: invoke( AttrsWithOwner :: attrs_with_owner) ]
219- fn attrs_with_owner ( & self , def : AttrDefId ) -> AttrsWithOwner ;
220-
221217 // endregion:attrs
222218
223219 #[ salsa:: invoke( LangItems :: lang_item_query) ]
@@ -241,7 +237,7 @@ pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDataba
241237 // endregion:visibilities
242238
243239 #[ 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 > > ;
245241
246242 fn crate_supports_no_std ( & self , crate_id : CrateId ) -> bool ;
247243}
Original file line number Diff line number Diff line change @@ -87,7 +87,10 @@ impl LangItems {
8787 }
8888
8989 /// 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 > > {
9194 let _p = profile:: span ( "crate_lang_items_query" ) ;
9295
9396 let mut lang_items = LangItems :: default ( ) ;
@@ -150,7 +153,11 @@ impl LangItems {
150153 }
151154 }
152155
153- Arc :: new ( lang_items)
156+ if lang_items. items . is_empty ( ) {
157+ None
158+ } else {
159+ Some ( Arc :: new ( lang_items) )
160+ }
154161 }
155162
156163 /// Salsa query. Look for a lang item, starting from the specified crate and recursively
@@ -161,9 +168,9 @@ impl LangItems {
161168 item : LangItem ,
162169 ) -> Option < LangItemTarget > {
163170 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+ {
167174 return Some ( target) ;
168175 }
169176 db. crate_graph ( ) [ start_crate]
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ macro_rules! impl_has_attrs {
3535 impl HasAttrs for $def {
3636 fn attrs( self , db: & dyn HirDatabase ) -> AttrsWithOwner {
3737 let def = AttrDefId :: $def_id( self . into( ) ) ;
38- db. attrs_with_owner ( def)
38+ AttrsWithOwner :: attrs_with_owner ( db. upcast ( ) , def)
3939 }
4040 fn attr_id( self ) -> AttrDefId {
4141 AttrDefId :: $def_id( self . into( ) )
You can’t perform that action at this time.
0 commit comments