File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -177,15 +177,7 @@ impl InferenceContext<'_> {
177177 }
178178
179179 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 ( ) ) ?)
189181 }
190182}
191183
Original file line number Diff line number Diff line change @@ -217,6 +217,15 @@ impl FnTrait {
217217 }
218218 }
219219
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+
220229 pub const fn to_chalk_ir ( self ) -> rust_ir:: ClosureKind {
221230 match self {
222231 FnTrait :: FnOnce => rust_ir:: ClosureKind :: FnOnce ,
You can’t perform that action at this time.
0 commit comments