aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/infer.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-05-23 18:23:17 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-05-23 18:23:17 +0100
commit1dc9adc6e27d603f05f794adda91bca8b6dec8ac (patch)
treec2ebe02614abf66618ed3975f7108cd03689416a /crates/ra_hir/src/ty/infer.rs
parentef00b5af1c7a7a7cac685eff661a10252825d84a (diff)
parent5d54aa678153d0af0edc8b4dd2d74709d10ca66c (diff)
Merge #1290
1290: Add Union to code_model r=matklad a=matklad @flodiebold I am conflicted about two possible implementation approaches: * we can add a separate `struct Union` to code model * we can add `fn is_union(&self)` to existing `Struct` This PR goes with the former approach, because it seems like Unions are sufficiently different in semantics to warrant a separate types. Which is in contrast to Syntax Tree, where both structs and unions share the same node kind, because their syntax is the same. What would be the right thing to do here? Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/ty/infer.rs')
-rw-r--r--crates/ra_hir/src/ty/infer.rs21
1 files changed, 13 insertions, 8 deletions
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index a48272981..7d8250292 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -27,13 +27,13 @@ use ra_prof::profile;
27use test_utils::tested_by; 27use test_utils::tested_by;
28 28
29use crate::{ 29use crate::{
30 Function, StructField, Path, Name, 30 Function, StructField, Path, Name, FnSignature, AdtDef, ConstSignature, HirDatabase,
31 FnSignature, AdtDef,ConstSignature, 31 DefWithBody, ImplItem,
32 HirDatabase,
33 DefWithBody,
34 ImplItem,
35 type_ref::{TypeRef, Mutability}, 32 type_ref::{TypeRef, Mutability},
36 expr::{Body, Expr, BindingAnnotation, Literal, ExprId, Pat, PatId, UnaryOp, BinaryOp, Statement, FieldPat,Array, self}, 33 expr::{
34 Body, Expr, BindingAnnotation, Literal, ExprId, Pat, PatId, UnaryOp, BinaryOp, Statement,
35 FieldPat, Array, self,
36 },
37 generics::{GenericParams, HasGenericParams}, 37 generics::{GenericParams, HasGenericParams},
38 path::{GenericArgs, GenericArg}, 38 path::{GenericArgs, GenericArg},
39 ModuleDef, 39 ModuleDef,
@@ -644,7 +644,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
644 let ty = self.insert_type_vars(ty.apply_substs(substs)); 644 let ty = self.insert_type_vars(ty.apply_substs(substs));
645 (ty, Some(var.into())) 645 (ty, Some(var.into()))
646 } 646 }
647 TypableDef::TypeAlias(_) 647 TypableDef::Union(_)
648 | TypableDef::TypeAlias(_)
648 | TypableDef::Function(_) 649 | TypableDef::Function(_)
649 | TypableDef::Enum(_) 650 | TypableDef::Enum(_)
650 | TypableDef::Const(_) 651 | TypableDef::Const(_)
@@ -1407,7 +1408,11 @@ impl Expectation {
1407} 1408}
1408 1409
1409mod diagnostics { 1410mod diagnostics {
1410 use crate::{expr::ExprId, diagnostics::{DiagnosticSink, NoSuchField}, HirDatabase, Function}; 1411 use crate::{
1412 expr::ExprId,
1413 diagnostics::{DiagnosticSink, NoSuchField},
1414 HirDatabase, Function,
1415};
1411 1416
1412 #[derive(Debug, PartialEq, Eq, Clone)] 1417 #[derive(Debug, PartialEq, Eq, Clone)]
1413 pub(super) enum InferenceDiagnostic { 1418 pub(super) enum InferenceDiagnostic {