@@ -17,16 +17,14 @@ use super::ChalkContext;
17
17
use crate :: {
18
18
db:: HirDatabase ,
19
19
display:: HirDisplay ,
20
- from_assoc_type_id,
20
+ from_assoc_type_id, make_only_type_binders ,
21
21
method_resolution:: { TyFingerprint , ALL_FLOAT_FPS , ALL_INT_FPS } ,
22
22
to_assoc_type_id, to_chalk_trait_id,
23
23
utils:: generics,
24
24
AliasEq , AliasTy , BoundVar , CallableDefId , DebruijnIndex , FnDefId , ProjectionTy , Substitution ,
25
25
TraitRef , TraitRefExt , Ty , TyBuilder , TyExt , TyKind , WhereClause ,
26
26
} ;
27
- use mapping:: {
28
- convert_where_clauses, generic_predicate_to_inline_bound, make_binders, TypeAliasAsValue ,
29
- } ;
27
+ use mapping:: { convert_where_clauses, generic_predicate_to_inline_bound, TypeAliasAsValue } ;
30
28
31
29
pub use self :: interner:: Interner ;
32
30
pub ( crate ) use self :: interner:: * ;
@@ -187,8 +185,11 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
187
185
let ( datas, binders) = ( * datas) . as_ref ( ) . into_value_and_skipped_binders ( ) ;
188
186
let data = & datas. impl_traits [ idx as usize ] ;
189
187
let bound = OpaqueTyDatumBound {
190
- bounds : make_binders ( data. bounds . skip_binders ( ) . iter ( ) . cloned ( ) . collect ( ) , 1 ) ,
191
- where_clauses : make_binders ( vec ! [ ] , 0 ) ,
188
+ bounds : make_only_type_binders (
189
+ 1 ,
190
+ data. bounds . skip_binders ( ) . iter ( ) . cloned ( ) . collect ( ) ,
191
+ ) ,
192
+ where_clauses : make_only_type_binders ( 0 , vec ! [ ] ) ,
192
193
} ;
193
194
chalk_ir:: Binders :: new ( binders, bound)
194
195
}
@@ -236,25 +237,25 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
236
237
. intern ( & Interner ) ,
237
238
} ) ;
238
239
let bound = OpaqueTyDatumBound {
239
- bounds : make_binders (
240
+ bounds : make_only_type_binders (
241
+ 1 ,
240
242
vec ! [
241
243
crate :: wrap_empty_binders( impl_bound) ,
242
244
crate :: wrap_empty_binders( proj_bound) ,
243
245
] ,
244
- 1 ,
245
246
) ,
246
- where_clauses : make_binders ( vec ! [ ] , 0 ) ,
247
+ where_clauses : make_only_type_binders ( 0 , vec ! [ ] ) ,
247
248
} ;
248
249
// The opaque type has 1 parameter.
249
- make_binders ( bound , 1 )
250
+ make_only_type_binders ( 1 , bound )
250
251
} else {
251
252
// If failed to find Symbol’s value as variable is void: Future::Output, return empty bounds as fallback.
252
253
let bound = OpaqueTyDatumBound {
253
- bounds : make_binders ( vec ! [ ] , 0 ) ,
254
- where_clauses : make_binders ( vec ! [ ] , 0 ) ,
254
+ bounds : make_only_type_binders ( 0 , vec ! [ ] ) ,
255
+ where_clauses : make_only_type_binders ( 0 , vec ! [ ] ) ,
255
256
} ;
256
257
// The opaque type has 1 parameter.
257
- make_binders ( bound , 1 )
258
+ make_only_type_binders ( 1 , bound )
258
259
}
259
260
}
260
261
} ;
@@ -291,15 +292,15 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
291
292
argument_types : sig. params ( ) . iter ( ) . cloned ( ) . collect ( ) ,
292
293
return_type : sig. ret ( ) . clone ( ) ,
293
294
} ;
294
- make_binders ( io. shifted_in ( & Interner ) , 0 )
295
+ make_only_type_binders ( 0 , io. shifted_in ( & Interner ) )
295
296
}
296
297
fn closure_upvars (
297
298
& self ,
298
299
_closure_id : chalk_ir:: ClosureId < Interner > ,
299
300
_substs : & chalk_ir:: Substitution < Interner > ,
300
301
) -> chalk_ir:: Binders < chalk_ir:: Ty < Interner > > {
301
302
let ty = TyBuilder :: unit ( ) ;
302
- make_binders ( ty , 0 )
303
+ make_only_type_binders ( 0 , ty )
303
304
}
304
305
fn closure_fn_substitution (
305
306
& self ,
@@ -404,7 +405,7 @@ pub(crate) fn associated_ty_data_query(
404
405
trait_id : to_chalk_trait_id ( trait_) ,
405
406
id,
406
407
name : type_alias,
407
- binders : make_binders ( bound_data , generic_params. len ( ) ) ,
408
+ binders : make_only_type_binders ( generic_params. len ( ) , bound_data ) ,
408
409
} ;
409
410
Arc :: new ( datum)
410
411
}
@@ -437,7 +438,7 @@ pub(crate) fn trait_datum_query(
437
438
lang_attr ( db. upcast ( ) , trait_) . and_then ( |name| well_known_trait_from_lang_attr ( & name) ) ;
438
439
let trait_datum = TraitDatum {
439
440
id : trait_id,
440
- binders : make_binders ( trait_datum_bound , bound_vars. len ( & Interner ) ) ,
441
+ binders : make_only_type_binders ( bound_vars. len ( & Interner ) , trait_datum_bound ) ,
441
442
flags,
442
443
associated_ty_ids,
443
444
well_known,
@@ -506,7 +507,7 @@ pub(crate) fn struct_datum_query(
506
507
// FIXME set ADT kind
507
508
kind : rust_ir:: AdtKind :: Struct ,
508
509
id : struct_id,
509
- binders : make_binders ( struct_datum_bound , num_params ) ,
510
+ binders : make_only_type_binders ( num_params , struct_datum_bound ) ,
510
511
flags,
511
512
} ;
512
513
Arc :: new ( struct_datum)
@@ -575,7 +576,7 @@ fn impl_def_datum(
575
576
. collect ( ) ;
576
577
debug ! ( "impl_datum: {:?}" , impl_datum_bound) ;
577
578
let impl_datum = ImplDatum {
578
- binders : make_binders ( impl_datum_bound , bound_vars. len ( & Interner ) ) ,
579
+ binders : make_only_type_binders ( bound_vars. len ( & Interner ) , impl_datum_bound ) ,
579
580
impl_type,
580
581
polarity,
581
582
associated_ty_value_ids,
@@ -635,13 +636,13 @@ pub(crate) fn fn_def_datum_query(
635
636
let where_clauses = convert_where_clauses ( db, callable_def. into ( ) , & bound_vars) ;
636
637
let bound = rust_ir:: FnDefDatumBound {
637
638
// Note: Chalk doesn't actually use this information yet as far as I am aware, but we provide it anyway
638
- inputs_and_output : make_binders (
639
+ inputs_and_output : make_only_type_binders (
640
+ 0 ,
639
641
rust_ir:: FnDefInputsAndOutputDatum {
640
642
argument_types : sig. params ( ) . iter ( ) . cloned ( ) . collect ( ) ,
641
643
return_type : sig. ret ( ) . clone ( ) ,
642
644
}
643
645
. shifted_in ( & Interner ) ,
644
- 0 ,
645
646
) ,
646
647
where_clauses,
647
648
} ;
0 commit comments