diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-03-05 16:04:49 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-05 16:04:49 +0000 |
commit | 6c27c55041953327d341f4e7c705e8887fc4dd50 (patch) | |
tree | bcc8bcac74fa61c816986b0635defa7c7512660f /crates/hir_ty/src/infer | |
parent | 25a43e24c81f7b51234fc4e65e5e36ddbe3d60f1 (diff) | |
parent | 50e01d2bc7429d718e0783d75458a6a047ee2b70 (diff) |
Merge #7870
7870: Use chalk_ir::AdtId r=Veykril a=Veykril
It's a bit unfortunate that we got two AdtId's now(technically 3 with the alias in the chalk module but that one won't allow pattern matching), one from hir_def and one from chalk_ir(hir_ty). But the hir_ty/chalk one doesn't leave hir so it shouldn't be that bad I suppose. Though if I see this right this will happen for almost all IDs.
I imagine most of the intermediate changes to using chalk ids will turn out not too nice until the refactor is over.
Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/hir_ty/src/infer')
-rw-r--r-- | crates/hir_ty/src/infer/expr.rs | 24 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/pat.rs | 2 |
2 files changed, 13 insertions, 13 deletions
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index cf1f1038a..ec2c13154 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs | |||
@@ -8,7 +8,7 @@ use hir_def::{ | |||
8 | expr::{Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp}, | 8 | expr::{Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp}, |
9 | path::{GenericArg, GenericArgs}, | 9 | path::{GenericArg, GenericArgs}, |
10 | resolver::resolver_for_expr, | 10 | resolver::resolver_for_expr, |
11 | AdtId, AssocContainerId, FieldId, Lookup, | 11 | AssocContainerId, FieldId, Lookup, |
12 | }; | 12 | }; |
13 | use hir_expand::name::{name, Name}; | 13 | use hir_expand::name::{name, Name}; |
14 | use syntax::ast::RangeOp; | 14 | use syntax::ast::RangeOp; |
@@ -21,8 +21,8 @@ use crate::{ | |||
21 | primitive::{self, UintTy}, | 21 | primitive::{self, UintTy}, |
22 | traits::{FnTrait, InEnvironment}, | 22 | traits::{FnTrait, InEnvironment}, |
23 | utils::{generics, variant_data, Generics}, | 23 | utils::{generics, variant_data, Generics}, |
24 | Binders, CallableDefId, FnPointer, FnSig, Obligation, OpaqueTyId, Rawness, Scalar, Substs, | 24 | AdtId, Binders, CallableDefId, FnPointer, FnSig, Obligation, OpaqueTyId, Rawness, Scalar, |
25 | TraitRef, Ty, | 25 | Substs, TraitRef, Ty, |
26 | }; | 26 | }; |
27 | 27 | ||
28 | use super::{ | 28 | use super::{ |
@@ -429,14 +429,14 @@ impl<'a> InferenceContext<'a> { | |||
429 | Ty::Tuple(_, substs) => { | 429 | Ty::Tuple(_, substs) => { |
430 | name.as_tuple_index().and_then(|idx| substs.0.get(idx).cloned()) | 430 | name.as_tuple_index().and_then(|idx| substs.0.get(idx).cloned()) |
431 | } | 431 | } |
432 | Ty::Adt(AdtId::StructId(s), parameters) => { | 432 | Ty::Adt(AdtId(hir_def::AdtId::StructId(s)), parameters) => { |
433 | self.db.struct_data(s).variant_data.field(name).map(|local_id| { | 433 | self.db.struct_data(s).variant_data.field(name).map(|local_id| { |
434 | let field = FieldId { parent: s.into(), local_id }; | 434 | let field = FieldId { parent: s.into(), local_id }; |
435 | self.write_field_resolution(tgt_expr, field); | 435 | self.write_field_resolution(tgt_expr, field); |
436 | self.db.field_types(s.into())[field.local_id].clone().subst(¶meters) | 436 | self.db.field_types(s.into())[field.local_id].clone().subst(¶meters) |
437 | }) | 437 | }) |
438 | } | 438 | } |
439 | Ty::Adt(AdtId::UnionId(u), parameters) => { | 439 | Ty::Adt(AdtId(hir_def::AdtId::UnionId(u)), parameters) => { |
440 | self.db.union_data(u).variant_data.field(name).map(|local_id| { | 440 | self.db.union_data(u).variant_data.field(name).map(|local_id| { |
441 | let field = FieldId { parent: u.into(), local_id }; | 441 | let field = FieldId { parent: u.into(), local_id }; |
442 | self.write_field_resolution(tgt_expr, field); | 442 | self.write_field_resolution(tgt_expr, field); |
@@ -498,7 +498,7 @@ impl<'a> InferenceContext<'a> { | |||
498 | _ => (), | 498 | _ => (), |
499 | } | 499 | } |
500 | sb = sb.fill(repeat_with(|| self.table.new_type_var())); | 500 | sb = sb.fill(repeat_with(|| self.table.new_type_var())); |
501 | Ty::Adt(box_, sb.build()) | 501 | Ty::adt_ty(box_, sb.build()) |
502 | } else { | 502 | } else { |
503 | Ty::Unknown | 503 | Ty::Unknown |
504 | } | 504 | } |
@@ -586,31 +586,31 @@ impl<'a> InferenceContext<'a> { | |||
586 | let rhs_ty = rhs.map(|e| self.infer_expr(e, &rhs_expect)); | 586 | let rhs_ty = rhs.map(|e| self.infer_expr(e, &rhs_expect)); |
587 | match (range_type, lhs_ty, rhs_ty) { | 587 | match (range_type, lhs_ty, rhs_ty) { |
588 | (RangeOp::Exclusive, None, None) => match self.resolve_range_full() { | 588 | (RangeOp::Exclusive, None, None) => match self.resolve_range_full() { |
589 | Some(adt) => Ty::Adt(adt, Substs::empty()), | 589 | Some(adt) => Ty::adt_ty(adt, Substs::empty()), |
590 | None => Ty::Unknown, | 590 | None => Ty::Unknown, |
591 | }, | 591 | }, |
592 | (RangeOp::Exclusive, None, Some(ty)) => match self.resolve_range_to() { | 592 | (RangeOp::Exclusive, None, Some(ty)) => match self.resolve_range_to() { |
593 | Some(adt) => Ty::Adt(adt, Substs::single(ty)), | 593 | Some(adt) => Ty::adt_ty(adt, Substs::single(ty)), |
594 | None => Ty::Unknown, | 594 | None => Ty::Unknown, |
595 | }, | 595 | }, |
596 | (RangeOp::Inclusive, None, Some(ty)) => { | 596 | (RangeOp::Inclusive, None, Some(ty)) => { |
597 | match self.resolve_range_to_inclusive() { | 597 | match self.resolve_range_to_inclusive() { |
598 | Some(adt) => Ty::Adt(adt, Substs::single(ty)), | 598 | Some(adt) => Ty::adt_ty(adt, Substs::single(ty)), |
599 | None => Ty::Unknown, | 599 | None => Ty::Unknown, |
600 | } | 600 | } |
601 | } | 601 | } |
602 | (RangeOp::Exclusive, Some(_), Some(ty)) => match self.resolve_range() { | 602 | (RangeOp::Exclusive, Some(_), Some(ty)) => match self.resolve_range() { |
603 | Some(adt) => Ty::Adt(adt, Substs::single(ty)), | 603 | Some(adt) => Ty::adt_ty(adt, Substs::single(ty)), |
604 | None => Ty::Unknown, | 604 | None => Ty::Unknown, |
605 | }, | 605 | }, |
606 | (RangeOp::Inclusive, Some(_), Some(ty)) => { | 606 | (RangeOp::Inclusive, Some(_), Some(ty)) => { |
607 | match self.resolve_range_inclusive() { | 607 | match self.resolve_range_inclusive() { |
608 | Some(adt) => Ty::Adt(adt, Substs::single(ty)), | 608 | Some(adt) => Ty::adt_ty(adt, Substs::single(ty)), |
609 | None => Ty::Unknown, | 609 | None => Ty::Unknown, |
610 | } | 610 | } |
611 | } | 611 | } |
612 | (RangeOp::Exclusive, Some(ty), None) => match self.resolve_range_from() { | 612 | (RangeOp::Exclusive, Some(ty), None) => match self.resolve_range_from() { |
613 | Some(adt) => Ty::Adt(adt, Substs::single(ty)), | 613 | Some(adt) => Ty::adt_ty(adt, Substs::single(ty)), |
614 | None => Ty::Unknown, | 614 | None => Ty::Unknown, |
615 | }, | 615 | }, |
616 | (RangeOp::Inclusive, _, None) => Ty::Unknown, | 616 | (RangeOp::Inclusive, _, None) => Ty::Unknown, |
diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs index eb099311c..987793e2e 100644 --- a/crates/hir_ty/src/infer/pat.rs +++ b/crates/hir_ty/src/infer/pat.rs | |||
@@ -237,7 +237,7 @@ impl<'a> InferenceContext<'a> { | |||
237 | }; | 237 | }; |
238 | 238 | ||
239 | let inner_ty = self.infer_pat(*inner, inner_expected, default_bm); | 239 | let inner_ty = self.infer_pat(*inner, inner_expected, default_bm); |
240 | Ty::Adt(box_adt, Substs::single(inner_ty)) | 240 | Ty::adt_ty(box_adt, Substs::single(inner_ty)) |
241 | } | 241 | } |
242 | None => Ty::Unknown, | 242 | None => Ty::Unknown, |
243 | }, | 243 | }, |