diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-03-01 13:29:54 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-01 13:29:54 +0000 |
commit | 4a9eec44787a0f2b35467ea98dd6f596671907f9 (patch) | |
tree | b2a941497dea3cc38adb6c55049668aa31b2554b /crates/hir_ty/src/infer | |
parent | cda13d54613006c7985da0489878605300ba05b8 (diff) | |
parent | 5d121cdb45f5199828ed64a2ca01a74998e023ad (diff) |
Merge #7826
7826: Introduce Ty::Alias r=Veykril a=Veykril
bors r+
Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/hir_ty/src/infer')
-rw-r--r-- | crates/hir_ty/src/infer/coerce.rs | 10 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/expr.rs | 2 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/unify.rs | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/crates/hir_ty/src/infer/coerce.rs b/crates/hir_ty/src/infer/coerce.rs index 667b26a76..c33d8c61e 100644 --- a/crates/hir_ty/src/infer/coerce.rs +++ b/crates/hir_ty/src/infer/coerce.rs | |||
@@ -73,19 +73,19 @@ impl<'a> InferenceContext<'a> { | |||
73 | match (&mut from_ty, to_ty) { | 73 | match (&mut from_ty, to_ty) { |
74 | // `*mut T` -> `*const T` | 74 | // `*mut T` -> `*const T` |
75 | // `&mut T` -> `&T` | 75 | // `&mut T` -> `&T` |
76 | (Ty::RawPtr(m1, ..), Ty::RawPtr(m2 @ Mutability::Shared, ..)) | 76 | (Ty::Raw(m1, ..), Ty::Raw(m2 @ Mutability::Shared, ..)) |
77 | | (Ty::Ref(m1, ..), Ty::Ref(m2 @ Mutability::Shared, ..)) => { | 77 | | (Ty::Ref(m1, ..), Ty::Ref(m2 @ Mutability::Shared, ..)) => { |
78 | *m1 = *m2; | 78 | *m1 = *m2; |
79 | } | 79 | } |
80 | // `&T` -> `*const T` | 80 | // `&T` -> `*const T` |
81 | // `&mut T` -> `*mut T`/`*const T` | 81 | // `&mut T` -> `*mut T`/`*const T` |
82 | (Ty::Ref(.., substs), &Ty::RawPtr(m2 @ Mutability::Shared, ..)) | 82 | (Ty::Ref(.., substs), &Ty::Raw(m2 @ Mutability::Shared, ..)) |
83 | | (Ty::Ref(Mutability::Mut, substs), &Ty::RawPtr(m2, ..)) => { | 83 | | (Ty::Ref(Mutability::Mut, substs), &Ty::Raw(m2, ..)) => { |
84 | from_ty = Ty::RawPtr(m2, substs.clone()); | 84 | from_ty = Ty::Raw(m2, substs.clone()); |
85 | } | 85 | } |
86 | 86 | ||
87 | // Illegal mutability conversion | 87 | // Illegal mutability conversion |
88 | (Ty::RawPtr(Mutability::Shared, ..), Ty::RawPtr(Mutability::Mut, ..)) | 88 | (Ty::Raw(Mutability::Shared, ..), Ty::Raw(Mutability::Mut, ..)) |
89 | | (Ty::Ref(Mutability::Shared, ..), Ty::Ref(Mutability::Mut, ..)) => return false, | 89 | | (Ty::Ref(Mutability::Shared, ..), Ty::Ref(Mutability::Mut, ..)) => return false, |
90 | 90 | ||
91 | // `{function_type}` -> `fn()` | 91 | // `{function_type}` -> `fn()` |
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index 928ad37a3..7852b3d23 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs | |||
@@ -479,7 +479,7 @@ impl<'a> InferenceContext<'a> { | |||
479 | }; | 479 | }; |
480 | let inner_ty = self.infer_expr_inner(*expr, &expectation); | 480 | let inner_ty = self.infer_expr_inner(*expr, &expectation); |
481 | match rawness { | 481 | match rawness { |
482 | Rawness::RawPtr => Ty::RawPtr(*mutability, Substs::single(inner_ty)), | 482 | Rawness::RawPtr => Ty::Raw(*mutability, Substs::single(inner_ty)), |
483 | Rawness::Ref => Ty::Ref(*mutability, Substs::single(inner_ty)), | 483 | Rawness::Ref => Ty::Ref(*mutability, Substs::single(inner_ty)), |
484 | } | 484 | } |
485 | } | 485 | } |
diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs index b481aa1b3..99a89a7f3 100644 --- a/crates/hir_ty/src/infer/unify.rs +++ b/crates/hir_ty/src/infer/unify.rs | |||
@@ -68,7 +68,7 @@ impl<'a, 'b> Canonicalizer<'a, 'b> { | |||
68 | } else { | 68 | } else { |
69 | let root = self.ctx.table.var_unification_table.find(inner); | 69 | let root = self.ctx.table.var_unification_table.find(inner); |
70 | let position = self.add(InferenceVar::from_inner(root), kind); | 70 | let position = self.add(InferenceVar::from_inner(root), kind); |
71 | Ty::Bound(BoundVar::new(binders, position)) | 71 | Ty::BoundVar(BoundVar::new(binders, position)) |
72 | } | 72 | } |
73 | } | 73 | } |
74 | _ => ty, | 74 | _ => ty, |
@@ -110,7 +110,7 @@ impl<T> Canonicalized<T> { | |||
110 | pub(super) fn decanonicalize_ty(&self, mut ty: Ty) -> Ty { | 110 | pub(super) fn decanonicalize_ty(&self, mut ty: Ty) -> Ty { |
111 | ty.walk_mut_binders( | 111 | ty.walk_mut_binders( |
112 | &mut |ty, binders| { | 112 | &mut |ty, binders| { |
113 | if let &mut Ty::Bound(bound) = ty { | 113 | if let &mut Ty::BoundVar(bound) = ty { |
114 | if bound.debruijn >= binders { | 114 | if bound.debruijn >= binders { |
115 | let (v, k) = self.free_vars[bound.index]; | 115 | let (v, k) = self.free_vars[bound.index]; |
116 | *ty = Ty::InferenceVar(v, k); | 116 | *ty = Ty::InferenceVar(v, k); |
@@ -168,7 +168,7 @@ pub(crate) fn unify(tys: &Canonical<(Ty, Ty)>) -> Option<Substs> { | |||
168 | // (kind of hacky) | 168 | // (kind of hacky) |
169 | for (i, var) in vars.iter().enumerate() { | 169 | for (i, var) in vars.iter().enumerate() { |
170 | if &*table.resolve_ty_shallow(var) == var { | 170 | if &*table.resolve_ty_shallow(var) == var { |
171 | table.unify(var, &Ty::Bound(BoundVar::new(DebruijnIndex::INNERMOST, i))); | 171 | table.unify(var, &Ty::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, i))); |
172 | } | 172 | } |
173 | } | 173 | } |
174 | Some( | 174 | Some( |