aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/traits/chalk.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-04-08 13:16:05 +0100
committerFlorian Diebold <[email protected]>2021-04-08 13:23:17 +0100
commit8ce6fea325c001deeed2857da560fa5cfbc6eea3 (patch)
tree4f9fb1a7f0b9987d9e23c0667b7495d68f08c03d /crates/hir_ty/src/traits/chalk.rs
parenta163554857db677e892c211b41deda676a6d1511 (diff)
Remove identity impls for ToChalk
Diffstat (limited to 'crates/hir_ty/src/traits/chalk.rs')
-rw-r--r--crates/hir_ty/src/traits/chalk.rs38
1 files changed, 14 insertions, 24 deletions
diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs
index a5aa40c10..fcdcc2b4d 100644
--- a/crates/hir_ty/src/traits/chalk.rs
+++ b/crates/hir_ty/src/traits/chalk.rs
@@ -86,7 +86,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
86 debug!("impls_for_trait {:?}", trait_id); 86 debug!("impls_for_trait {:?}", trait_id);
87 let trait_: hir_def::TraitId = from_chalk(self.db, trait_id); 87 let trait_: hir_def::TraitId = from_chalk(self.db, trait_id);
88 88
89 let ty: Ty = from_chalk(self.db, parameters[0].assert_ty_ref(&Interner).clone()); 89 let ty: Ty = parameters[0].assert_ty_ref(&Interner).clone();
90 90
91 fn binder_kind( 91 fn binder_kind(
92 ty: &Ty, 92 ty: &Ty,
@@ -187,15 +187,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
187 let (datas, binders) = (*datas).as_ref().into_value_and_skipped_binders(); 187 let (datas, binders) = (*datas).as_ref().into_value_and_skipped_binders();
188 let data = &datas.impl_traits[idx as usize]; 188 let data = &datas.impl_traits[idx as usize];
189 let bound = OpaqueTyDatumBound { 189 let bound = OpaqueTyDatumBound {
190 bounds: make_binders( 190 bounds: make_binders(data.bounds.skip_binders().iter().cloned().collect(), 1),
191 data.bounds
192 .skip_binders()
193 .iter()
194 .cloned()
195 .map(|b| b.to_chalk(self.db))
196 .collect(),
197 1,
198 ),
199 where_clauses: make_binders(vec![], 0), 191 where_clauses: make_binders(vec![], 0),
200 }; 192 };
201 chalk_ir::Binders::new(binders, bound) 193 chalk_ir::Binders::new(binders, bound)
@@ -246,8 +238,8 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
246 let bound = OpaqueTyDatumBound { 238 let bound = OpaqueTyDatumBound {
247 bounds: make_binders( 239 bounds: make_binders(
248 vec![ 240 vec![
249 crate::wrap_empty_binders(impl_bound).to_chalk(self.db), 241 crate::wrap_empty_binders(impl_bound),
250 crate::wrap_empty_binders(proj_bound).to_chalk(self.db), 242 crate::wrap_empty_binders(proj_bound),
251 ], 243 ],
252 1, 244 1,
253 ), 245 ),
@@ -272,7 +264,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
272 264
273 fn hidden_opaque_type(&self, _id: chalk_ir::OpaqueTyId<Interner>) -> chalk_ir::Ty<Interner> { 265 fn hidden_opaque_type(&self, _id: chalk_ir::OpaqueTyId<Interner>) -> chalk_ir::Ty<Interner> {
274 // FIXME: actually provide the hidden type; it is relevant for auto traits 266 // FIXME: actually provide the hidden type; it is relevant for auto traits
275 TyKind::Error.intern(&Interner).to_chalk(self.db) 267 TyKind::Error.intern(&Interner)
276 } 268 }
277 269
278 fn is_object_safe(&self, _trait_id: chalk_ir::TraitId<Interner>) -> bool { 270 fn is_object_safe(&self, _trait_id: chalk_ir::TraitId<Interner>) -> bool {
@@ -293,12 +285,11 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
293 _closure_id: chalk_ir::ClosureId<Interner>, 285 _closure_id: chalk_ir::ClosureId<Interner>,
294 substs: &chalk_ir::Substitution<Interner>, 286 substs: &chalk_ir::Substitution<Interner>,
295 ) -> chalk_ir::Binders<rust_ir::FnDefInputsAndOutputDatum<Interner>> { 287 ) -> chalk_ir::Binders<rust_ir::FnDefInputsAndOutputDatum<Interner>> {
296 let sig_ty: Ty = 288 let sig_ty = substs.at(&Interner, 0).assert_ty_ref(&Interner).clone();
297 from_chalk(self.db, substs.at(&Interner, 0).assert_ty_ref(&Interner).clone());
298 let sig = &sig_ty.callable_sig(self.db).expect("first closure param should be fn ptr"); 289 let sig = &sig_ty.callable_sig(self.db).expect("first closure param should be fn ptr");
299 let io = rust_ir::FnDefInputsAndOutputDatum { 290 let io = rust_ir::FnDefInputsAndOutputDatum {
300 argument_types: sig.params().iter().map(|ty| ty.clone().to_chalk(self.db)).collect(), 291 argument_types: sig.params().iter().cloned().collect(),
301 return_type: sig.ret().clone().to_chalk(self.db), 292 return_type: sig.ret().clone(),
302 }; 293 };
303 make_binders(io.shifted_in(&Interner), 0) 294 make_binders(io.shifted_in(&Interner), 0)
304 } 295 }
@@ -307,7 +298,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
307 _closure_id: chalk_ir::ClosureId<Interner>, 298 _closure_id: chalk_ir::ClosureId<Interner>,
308 _substs: &chalk_ir::Substitution<Interner>, 299 _substs: &chalk_ir::Substitution<Interner>,
309 ) -> chalk_ir::Binders<chalk_ir::Ty<Interner>> { 300 ) -> chalk_ir::Binders<chalk_ir::Ty<Interner>> {
310 let ty = TyBuilder::unit().to_chalk(self.db); 301 let ty = TyBuilder::unit();
311 make_binders(ty, 0) 302 make_binders(ty, 0)
312 } 303 }
313 fn closure_fn_substitution( 304 fn closure_fn_substitution(
@@ -315,7 +306,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
315 _closure_id: chalk_ir::ClosureId<Interner>, 306 _closure_id: chalk_ir::ClosureId<Interner>,
316 _substs: &chalk_ir::Substitution<Interner>, 307 _substs: &chalk_ir::Substitution<Interner>,
317 ) -> chalk_ir::Substitution<Interner> { 308 ) -> chalk_ir::Substitution<Interner> {
318 Substitution::empty(&Interner).to_chalk(self.db) 309 Substitution::empty(&Interner)
319 } 310 }
320 311
321 fn trait_name(&self, trait_id: chalk_ir::TraitId<Interner>) -> String { 312 fn trait_name(&self, trait_id: chalk_ir::TraitId<Interner>) -> String {
@@ -410,7 +401,7 @@ pub(crate) fn associated_ty_data_query(
410 let where_clauses = convert_where_clauses(db, type_alias.into(), &bound_vars); 401 let where_clauses = convert_where_clauses(db, type_alias.into(), &bound_vars);
411 let bound_data = rust_ir::AssociatedTyDatumBound { bounds, where_clauses }; 402 let bound_data = rust_ir::AssociatedTyDatumBound { bounds, where_clauses };
412 let datum = AssociatedTyDatum { 403 let datum = AssociatedTyDatum {
413 trait_id: trait_.to_chalk(db), 404 trait_id: to_chalk_trait_id(trait_),
414 id, 405 id,
415 name: type_alias, 406 name: type_alias,
416 binders: make_binders(bound_data, generic_params.len()), 407 binders: make_binders(bound_data, generic_params.len()),
@@ -563,7 +554,6 @@ fn impl_def_datum(
563 trait_ref.display(db), 554 trait_ref.display(db),
564 where_clauses 555 where_clauses
565 ); 556 );
566 let trait_ref = trait_ref.to_chalk(db);
567 557
568 let polarity = if negative { rust_ir::Polarity::Negative } else { rust_ir::Polarity::Positive }; 558 let polarity = if negative { rust_ir::Polarity::Negative } else { rust_ir::Polarity::Positive };
569 559
@@ -624,7 +614,7 @@ fn type_alias_associated_ty_value(
624 .associated_type_by_name(&type_alias_data.name) 614 .associated_type_by_name(&type_alias_data.name)
625 .expect("assoc ty value should not exist"); // validated when building the impl data as well 615 .expect("assoc ty value should not exist"); // validated when building the impl data as well
626 let (ty, binders) = db.ty(type_alias.into()).into_value_and_skipped_binders(); 616 let (ty, binders) = db.ty(type_alias.into()).into_value_and_skipped_binders();
627 let value_bound = rust_ir::AssociatedTyValueBound { ty: ty.to_chalk(db) }; 617 let value_bound = rust_ir::AssociatedTyValueBound { ty };
628 let value = rust_ir::AssociatedTyValue { 618 let value = rust_ir::AssociatedTyValue {
629 impl_id: impl_id.to_chalk(db), 619 impl_id: impl_id.to_chalk(db),
630 associated_ty_id: to_assoc_type_id(assoc_ty), 620 associated_ty_id: to_assoc_type_id(assoc_ty),
@@ -647,8 +637,8 @@ pub(crate) fn fn_def_datum_query(
647 // Note: Chalk doesn't actually use this information yet as far as I am aware, but we provide it anyway 637 // Note: Chalk doesn't actually use this information yet as far as I am aware, but we provide it anyway
648 inputs_and_output: make_binders( 638 inputs_and_output: make_binders(
649 rust_ir::FnDefInputsAndOutputDatum { 639 rust_ir::FnDefInputsAndOutputDatum {
650 argument_types: sig.params().iter().map(|ty| ty.clone().to_chalk(db)).collect(), 640 argument_types: sig.params().iter().cloned().collect(),
651 return_type: sig.ret().clone().to_chalk(db), 641 return_type: sig.ret().clone(),
652 } 642 }
653 .shifted_in(&Interner), 643 .shifted_in(&Interner),
654 0, 644 0,