File tree 2 files changed +10
-9
lines changed
2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -177,15 +177,7 @@ impl InferenceContext<'_> {
177
177
}
178
178
179
179
fn fn_trait_kind_from_trait_id ( & self , trait_id : hir_def:: TraitId ) -> Option < FnTrait > {
180
- utils:: fn_traits ( self . db . upcast ( ) , self . owner . module ( self . db . upcast ( ) ) . krate ( ) )
181
- . enumerate ( )
182
- . find_map ( |( i, t) | ( t == trait_id) . then_some ( i) )
183
- . map ( |i| match i {
184
- 0 => FnTrait :: Fn ,
185
- 1 => FnTrait :: FnMut ,
186
- 2 => FnTrait :: FnOnce ,
187
- _ => unreachable ! ( ) ,
188
- } )
180
+ FnTrait :: from_lang_item ( self . db . lang_attr ( trait_id. into ( ) ) ?)
189
181
}
190
182
}
191
183
Original file line number Diff line number Diff line change @@ -217,6 +217,15 @@ impl FnTrait {
217
217
}
218
218
}
219
219
220
+ pub const fn from_lang_item ( lang_item : LangItem ) -> Option < Self > {
221
+ match lang_item {
222
+ LangItem :: FnOnce => Some ( FnTrait :: FnOnce ) ,
223
+ LangItem :: FnMut => Some ( FnTrait :: FnMut ) ,
224
+ LangItem :: Fn => Some ( FnTrait :: Fn ) ,
225
+ _ => None ,
226
+ }
227
+ }
228
+
220
229
pub const fn to_chalk_ir ( self ) -> rust_ir:: ClosureKind {
221
230
match self {
222
231
FnTrait :: FnOnce => rust_ir:: ClosureKind :: FnOnce ,
You can’t perform that action at this time.
0 commit comments