diff options
author | Florian Diebold <[email protected]> | 2021-05-16 14:56:27 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2021-05-21 16:48:34 +0100 |
commit | a78f0076abbbf61f7b68ce5c323639037c8a72de (patch) | |
tree | f2a5f46b348c6b32e6860523a4ed06547fbf4ea2 /crates/hir_ty/src/infer/unify.rs | |
parent | 1250ddc5cf58ff0a6bbf7c07e5bd9f7cc7db5a09 (diff) |
Make resolve_ty_shallow return Ty
Diffstat (limited to 'crates/hir_ty/src/infer/unify.rs')
-rw-r--r-- | crates/hir_ty/src/infer/unify.rs | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs index 75e04e8b5..278127c69 100644 --- a/crates/hir_ty/src/infer/unify.rs +++ b/crates/hir_ty/src/infer/unify.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | //! Unification and canonicalization logic. | 1 | //! Unification and canonicalization logic. |
2 | 2 | ||
3 | use std::{borrow::Cow, fmt, mem, sync::Arc}; | 3 | use std::{fmt, mem, sync::Arc}; |
4 | 4 | ||
5 | use chalk_ir::{ | 5 | use chalk_ir::{ |
6 | cast::Cast, fold::Fold, interner::HasInterner, zip::Zip, FloatTy, IntTy, TyVariableKind, | 6 | cast::Cast, fold::Fold, interner::HasInterner, zip::Zip, FloatTy, IntTy, TyVariableKind, |
@@ -340,11 +340,8 @@ impl<'a> InferenceTable<'a> { | |||
340 | 340 | ||
341 | /// If `ty` is a type variable with known type, returns that type; | 341 | /// If `ty` is a type variable with known type, returns that type; |
342 | /// otherwise, return ty. | 342 | /// otherwise, return ty. |
343 | // FIXME this could probably just return Ty | 343 | pub(crate) fn resolve_ty_shallow(&mut self, ty: &Ty) -> Ty { |
344 | pub(crate) fn resolve_ty_shallow<'b>(&mut self, ty: &'b Ty) -> Cow<'b, Ty> { | 344 | self.var_unification_table.normalize_ty_shallow(&Interner, ty).unwrap_or_else(|| ty.clone()) |
345 | self.var_unification_table | ||
346 | .normalize_ty_shallow(&Interner, ty) | ||
347 | .map_or(Cow::Borrowed(ty), Cow::Owned) | ||
348 | } | 345 | } |
349 | 346 | ||
350 | /// Resolves the type as far as currently possible, replacing type variables | 347 | /// Resolves the type as far as currently possible, replacing type variables |