@@ -115,6 +115,8 @@ impl CrateImplBlocks {
115
115
}
116
116
117
117
fn def_crates ( db : & impl HirDatabase , cur_crate : Crate , ty : & Ty ) -> Option < ArrayVec < [ Crate ; 2 ] > > {
118
+ // Types like slice can have inherent impls in several crates, (core and alloc).
119
+ // The correspoinding impls are marked with lang items, so we can use them to find the required crates.
118
120
macro_rules! lang_item_crate {
119
121
( $db: expr, $cur_crate: expr, $( $name: expr) ,+ $( , ) ?) => { {
120
122
let mut v = ArrayVec :: <[ Crate ; 2 ] >:: new( ) ;
@@ -128,16 +130,16 @@ fn def_crates(db: &impl HirDatabase, cur_crate: Crate, ty: &Ty) -> Option<ArrayV
128
130
match ty {
129
131
Ty :: Apply ( a_ty) => match a_ty. ctor {
130
132
TypeCtor :: Adt ( def_id) => Some ( std:: iter:: once ( def_id. krate ( db) ?) . collect ( ) ) ,
131
- TypeCtor :: Bool => lang_item_crate ! [ db, cur_crate, "bool" ] ,
132
- TypeCtor :: Char => lang_item_crate ! [ db, cur_crate, "char" ] ,
133
+ TypeCtor :: Bool => lang_item_crate ! ( db, cur_crate, "bool" ) ,
134
+ TypeCtor :: Char => lang_item_crate ! ( db, cur_crate, "char" ) ,
133
135
TypeCtor :: Float ( UncertainFloatTy :: Known ( f) ) => {
134
- lang_item_crate ! [ db, cur_crate, f. ty_to_string( ) ]
136
+ lang_item_crate ! ( db, cur_crate, f. ty_to_string( ) )
135
137
}
136
138
TypeCtor :: Int ( UncertainIntTy :: Known ( i) ) => {
137
- lang_item_crate ! [ db, cur_crate, i. ty_to_string( ) ]
139
+ lang_item_crate ! ( db, cur_crate, i. ty_to_string( ) )
138
140
}
139
- TypeCtor :: Str => lang_item_crate ! [ db, cur_crate, "str" ] ,
140
- TypeCtor :: Slice => lang_item_crate ! [ db, cur_crate, "slice_alloc" , "slice" ] ,
141
+ TypeCtor :: Str => lang_item_crate ! ( db, cur_crate, "str" ) ,
142
+ TypeCtor :: Slice => lang_item_crate ! ( db, cur_crate, "slice_alloc" , "slice" ) ,
141
143
_ => None ,
142
144
} ,
143
145
_ => None ,
0 commit comments