@@ -40,7 +40,7 @@ pub(super) fn get_builtin_impls(
40
40
if let Ty :: Apply ( ApplicationTy { ctor : TypeCtor :: Closure { def, expr } , .. } ) = ty {
41
41
for & fn_trait in [ super :: FnTrait :: FnOnce , super :: FnTrait :: FnMut , super :: FnTrait :: Fn ] . iter ( )
42
42
{
43
- if let Some ( actual_trait) = get_fn_trait ( db, krate, fn_trait ) {
43
+ if let Some ( actual_trait) = fn_trait . get_id ( db, krate) {
44
44
if trait_ == actual_trait {
45
45
let impl_ = super :: ClosureFnTraitImplData { def : * def, expr : * expr, fn_trait } ;
46
46
if check_closure_fn_trait_impl_prerequisites ( db, krate, impl_) {
@@ -128,15 +128,15 @@ fn check_closure_fn_trait_impl_prerequisites(
128
128
data : super :: ClosureFnTraitImplData ,
129
129
) -> bool {
130
130
// the respective Fn/FnOnce/FnMut trait needs to exist
131
- if get_fn_trait ( db, krate, data . fn_trait ) . is_none ( ) {
131
+ if data . fn_trait . get_id ( db, krate) . is_none ( ) {
132
132
return false ;
133
133
}
134
134
135
135
// FIXME: there are more assumptions that we should probably check here:
136
136
// the traits having no type params, FnOnce being a supertrait
137
137
138
138
// the FnOnce trait needs to exist and have an assoc type named Output
139
- let fn_once_trait = match get_fn_trait ( db , krate , super :: FnTrait :: FnOnce ) {
139
+ let fn_once_trait = match ( super :: FnTrait :: FnOnce ) . get_id ( db , krate ) {
140
140
Some ( t) => t,
141
141
None => return false ,
142
142
} ;
@@ -151,7 +151,9 @@ fn closure_fn_trait_impl_datum(
151
151
// for some closure |X, Y| -> Z:
152
152
// impl<T, U, V> Fn<(T, U)> for closure<fn(T, U) -> V> { Output = V }
153
153
154
- let trait_ = get_fn_trait ( db, krate, data. fn_trait ) // get corresponding fn trait
154
+ let trait_ = data
155
+ . fn_trait
156
+ . get_id ( db, krate) // get corresponding fn trait
155
157
// the existence of the Fn trait has been checked before
156
158
. expect ( "fn trait for closure impl missing" ) ;
157
159
@@ -211,7 +213,7 @@ fn closure_fn_trait_output_assoc_ty_value(
211
213
let output_ty = Ty :: Bound ( BoundVar :: new ( DebruijnIndex :: INNERMOST , num_args. into ( ) ) ) ;
212
214
213
215
let fn_once_trait =
214
- get_fn_trait ( db , krate , super :: FnTrait :: FnOnce ) . expect ( "assoc ty value should not exist" ) ;
216
+ ( super :: FnTrait :: FnOnce ) . get_id ( db , krate ) . expect ( "assoc ty value should not exist" ) ;
215
217
216
218
let output_ty_id = db
217
219
. trait_data ( fn_once_trait)
@@ -360,18 +362,6 @@ fn super_trait_object_unsize_impl_datum(
360
362
BuiltinImplData { num_vars, trait_ref, where_clauses : Vec :: new ( ) , assoc_ty_values : Vec :: new ( ) }
361
363
}
362
364
363
- pub fn get_fn_trait (
364
- db : & dyn HirDatabase ,
365
- krate : CrateId ,
366
- fn_trait : super :: FnTrait ,
367
- ) -> Option < TraitId > {
368
- let target = db. lang_item ( krate, fn_trait. lang_item_name ( ) . into ( ) ) ?;
369
- match target {
370
- LangItemTarget :: TraitId ( t) => Some ( t) ,
371
- _ => None ,
372
- }
373
- }
374
-
375
365
fn get_unsize_trait ( db : & dyn HirDatabase , krate : CrateId ) -> Option < TraitId > {
376
366
let target = db. lang_item ( krate, "unsize" . into ( ) ) ?;
377
367
match target {
0 commit comments