aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src')
-rw-r--r--crates/hir_ty/src/builder.rs2
-rw-r--r--crates/hir_ty/src/display.rs4
-rw-r--r--crates/hir_ty/src/infer.rs14
-rw-r--r--crates/hir_ty/src/infer/path.rs4
-rw-r--r--crates/hir_ty/src/infer/unify.rs4
-rw-r--r--crates/hir_ty/src/lib.rs2
-rw-r--r--crates/hir_ty/src/lower.rs38
-rw-r--r--crates/hir_ty/src/method_resolution.rs2
-rw-r--r--crates/hir_ty/src/op.rs10
-rw-r--r--crates/hir_ty/src/traits/chalk.rs2
-rw-r--r--crates/hir_ty/src/traits/chalk/mapping.rs6
-rw-r--r--crates/hir_ty/src/types.rs2
-rw-r--r--crates/hir_ty/src/walk.rs4
13 files changed, 47 insertions, 47 deletions
diff --git a/crates/hir_ty/src/builder.rs b/crates/hir_ty/src/builder.rs
index 0bac31e4c..372621f73 100644
--- a/crates/hir_ty/src/builder.rs
+++ b/crates/hir_ty/src/builder.rs
@@ -54,7 +54,7 @@ impl<D> TyBuilder<D> {
54 } 54 }
55 55
56 pub fn fill_with_unknown(self) -> Self { 56 pub fn fill_with_unknown(self) -> Self {
57 self.fill(iter::repeat(TyKind::Unknown.intern(&Interner))) 57 self.fill(iter::repeat(TyKind::Error.intern(&Interner)))
58 } 58 }
59 59
60 pub fn fill(mut self, filler: impl Iterator<Item = impl CastTo<GenericArg>>) -> Self { 60 pub fn fill(mut self, filler: impl Iterator<Item = impl CastTo<GenericArg>>) -> Self {
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs
index 148eb7506..83d09a8c7 100644
--- a/crates/hir_ty/src/display.rs
+++ b/crates/hir_ty/src/display.rs
@@ -476,7 +476,7 @@ impl HirDisplay for Ty {
476 parameter.assert_ty_ref(&Interner).kind(&Interner), 476 parameter.assert_ty_ref(&Interner).kind(&Interner),
477 default_parameters.get(i), 477 default_parameters.get(i),
478 ) { 478 ) {
479 (&TyKind::Unknown, _) | (_, None) => { 479 (&TyKind::Error, _) | (_, None) => {
480 default_from = i + 1; 480 default_from = i + 1;
481 } 481 }
482 (_, Some(default_parameter)) => { 482 (_, Some(default_parameter)) => {
@@ -636,7 +636,7 @@ impl HirDisplay for Ty {
636 } 636 }
637 }; 637 };
638 } 638 }
639 TyKind::Unknown => { 639 TyKind::Error => {
640 if f.display_target.is_source_code() { 640 if f.display_target.is_source_code() {
641 return Err(HirDisplayError::DisplaySourceCodeError( 641 return Err(HirDisplayError::DisplaySourceCodeError(
642 DisplaySourceCodeError::UnknownType, 642 DisplaySourceCodeError::UnknownType,
diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs
index bb885db35..6151e48cd 100644
--- a/crates/hir_ty/src/infer.rs
+++ b/crates/hir_ty/src/infer.rs
@@ -120,7 +120,7 @@ struct InternedStandardTypes {
120 120
121impl Default for InternedStandardTypes { 121impl Default for InternedStandardTypes {
122 fn default() -> Self { 122 fn default() -> Self {
123 InternedStandardTypes { unknown: TyKind::Unknown.intern(&Interner) } 123 InternedStandardTypes { unknown: TyKind::Error.intern(&Interner) }
124 } 124 }
125} 125}
126 126
@@ -247,7 +247,7 @@ impl<'a> InferenceContext<'a> {
247 table: unify::InferenceTable::new(), 247 table: unify::InferenceTable::new(),
248 obligations: Vec::default(), 248 obligations: Vec::default(),
249 last_obligations_check: None, 249 last_obligations_check: None,
250 return_ty: TyKind::Unknown.intern(&Interner), // set in collect_fn_signature 250 return_ty: TyKind::Error.intern(&Interner), // set in collect_fn_signature
251 trait_env: owner 251 trait_env: owner
252 .as_generic_def_id() 252 .as_generic_def_id()
253 .map_or_else(Default::default, |d| db.trait_environment(d)), 253 .map_or_else(Default::default, |d| db.trait_environment(d)),
@@ -261,7 +261,7 @@ impl<'a> InferenceContext<'a> {
261 } 261 }
262 262
263 fn err_ty(&self) -> Ty { 263 fn err_ty(&self) -> Ty {
264 TyKind::Unknown.intern(&Interner) 264 TyKind::Error.intern(&Interner)
265 } 265 }
266 266
267 fn resolve_all(mut self) -> InferenceResult { 267 fn resolve_all(mut self) -> InferenceResult {
@@ -326,7 +326,7 @@ impl<'a> InferenceContext<'a> {
326 /// Replaces Ty::Unknown by a new type var, so we can maybe still infer it. 326 /// Replaces Ty::Unknown by a new type var, so we can maybe still infer it.
327 fn insert_type_vars_shallow(&mut self, ty: Ty) -> Ty { 327 fn insert_type_vars_shallow(&mut self, ty: Ty) -> Ty {
328 match ty.kind(&Interner) { 328 match ty.kind(&Interner) {
329 TyKind::Unknown => self.table.new_type_var(), 329 TyKind::Error => self.table.new_type_var(),
330 _ => ty, 330 _ => ty,
331 } 331 }
332 } 332 }
@@ -542,7 +542,7 @@ impl<'a> InferenceContext<'a> {
542 result 542 result
543 } else { 543 } else {
544 // FIXME diagnostic 544 // FIXME diagnostic
545 (TyKind::Unknown.intern(&Interner), None) 545 (TyKind::Error.intern(&Interner), None)
546 } 546 }
547 } 547 }
548 548
@@ -755,7 +755,7 @@ impl Expectation {
755 fn none() -> Self { 755 fn none() -> Self {
756 Expectation { 756 Expectation {
757 // FIXME 757 // FIXME
758 ty: TyKind::Unknown.intern(&Interner), 758 ty: TyKind::Error.intern(&Interner),
759 rvalue_hint: false, 759 rvalue_hint: false,
760 } 760 }
761 } 761 }
@@ -763,7 +763,7 @@ impl Expectation {
763 fn coercion_target(&self) -> Ty { 763 fn coercion_target(&self) -> Ty {
764 if self.rvalue_hint { 764 if self.rvalue_hint {
765 // FIXME 765 // FIXME
766 TyKind::Unknown.intern(&Interner) 766 TyKind::Error.intern(&Interner)
767 } else { 767 } else {
768 self.ty.clone() 768 self.ty.clone()
769 } 769 }
diff --git a/crates/hir_ty/src/infer/path.rs b/crates/hir_ty/src/infer/path.rs
index 637341b53..89d78e781 100644
--- a/crates/hir_ty/src/infer/path.rs
+++ b/crates/hir_ty/src/infer/path.rs
@@ -142,7 +142,7 @@ impl<'a> InferenceContext<'a> {
142 remaining_segments_for_ty, 142 remaining_segments_for_ty,
143 true, 143 true,
144 ); 144 );
145 if let TyKind::Unknown = ty.kind(&Interner) { 145 if let TyKind::Error = ty.kind(&Interner) {
146 return None; 146 return None;
147 } 147 }
148 148
@@ -207,7 +207,7 @@ impl<'a> InferenceContext<'a> {
207 name: &Name, 207 name: &Name,
208 id: ExprOrPatId, 208 id: ExprOrPatId,
209 ) -> Option<(ValueNs, Option<Substitution>)> { 209 ) -> Option<(ValueNs, Option<Substitution>)> {
210 if let TyKind::Unknown = ty.kind(&Interner) { 210 if let TyKind::Error = ty.kind(&Interner) {
211 return None; 211 return None;
212 } 212 }
213 213
diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs
index b7bc48569..8370f2e1c 100644
--- a/crates/hir_ty/src/infer/unify.rs
+++ b/crates/hir_ty/src/infer/unify.rs
@@ -214,7 +214,7 @@ impl TypeVariableTable {
214 fn fallback_value(&self, iv: InferenceVar, kind: TyVariableKind) -> Ty { 214 fn fallback_value(&self, iv: InferenceVar, kind: TyVariableKind) -> Ty {
215 match kind { 215 match kind {
216 _ if self.inner[iv.to_inner().0 as usize].diverging => TyKind::Never, 216 _ if self.inner[iv.to_inner().0 as usize].diverging => TyKind::Never,
217 TyVariableKind::General => TyKind::Unknown, 217 TyVariableKind::General => TyKind::Error,
218 TyVariableKind::Integer => TyKind::Scalar(Scalar::Int(IntTy::I32)), 218 TyVariableKind::Integer => TyKind::Scalar(Scalar::Int(IntTy::I32)),
219 TyVariableKind::Float => TyKind::Scalar(Scalar::Float(FloatTy::F64)), 219 TyVariableKind::Float => TyKind::Scalar(Scalar::Float(FloatTy::F64)),
220 } 220 }
@@ -327,7 +327,7 @@ impl InferenceTable {
327 327
328 pub(super) fn unify_inner_trivial(&mut self, ty1: &Ty, ty2: &Ty, depth: usize) -> bool { 328 pub(super) fn unify_inner_trivial(&mut self, ty1: &Ty, ty2: &Ty, depth: usize) -> bool {
329 match (ty1.kind(&Interner), ty2.kind(&Interner)) { 329 match (ty1.kind(&Interner), ty2.kind(&Interner)) {
330 (TyKind::Unknown, _) | (_, TyKind::Unknown) => true, 330 (TyKind::Error, _) | (_, TyKind::Error) => true,
331 331
332 (TyKind::Placeholder(p1), TyKind::Placeholder(p2)) if *p1 == *p2 => true, 332 (TyKind::Placeholder(p1), TyKind::Placeholder(p2)) if *p1 == *p2 => true,
333 333
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs
index 76609e2df..9e030e775 100644
--- a/crates/hir_ty/src/lib.rs
+++ b/crates/hir_ty/src/lib.rs
@@ -300,7 +300,7 @@ impl Ty {
300 } 300 }
301 301
302 pub fn is_unknown(&self) -> bool { 302 pub fn is_unknown(&self) -> bool {
303 matches!(self.kind(&Interner), TyKind::Unknown) 303 matches!(self.kind(&Interner), TyKind::Error)
304 } 304 }
305 305
306 pub fn equals_ctor(&self, other: &Ty) -> bool { 306 pub fn equals_ctor(&self, other: &Ty) -> bool {
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs
index 214655807..dd40eb5c3 100644
--- a/crates/hir_ty/src/lower.rs
+++ b/crates/hir_ty/src/lower.rs
@@ -176,7 +176,7 @@ impl<'a> TyLoweringContext<'a> {
176 let inner_ty = self.lower_ty(inner); 176 let inner_ty = self.lower_ty(inner);
177 TyKind::Ref(lower_to_chalk_mutability(*mutability), inner_ty).intern(&Interner) 177 TyKind::Ref(lower_to_chalk_mutability(*mutability), inner_ty).intern(&Interner)
178 } 178 }
179 TypeRef::Placeholder => TyKind::Unknown.intern(&Interner), 179 TypeRef::Placeholder => TyKind::Error.intern(&Interner),
180 TypeRef::Fn(params, is_varargs) => { 180 TypeRef::Fn(params, is_varargs) => {
181 let substs = 181 let substs =
182 Substitution::from_iter(&Interner, params.iter().map(|tr| self.lower_ty(tr))); 182 Substitution::from_iter(&Interner, params.iter().map(|tr| self.lower_ty(tr)));
@@ -253,12 +253,12 @@ impl<'a> TyLoweringContext<'a> {
253 data.provenance == TypeParamProvenance::ArgumentImplTrait 253 data.provenance == TypeParamProvenance::ArgumentImplTrait
254 }) 254 })
255 .nth(idx as usize) 255 .nth(idx as usize)
256 .map_or(TyKind::Unknown, |(id, _)| { 256 .map_or(TyKind::Error, |(id, _)| {
257 TyKind::Placeholder(to_placeholder_idx(self.db, id)) 257 TyKind::Placeholder(to_placeholder_idx(self.db, id))
258 }); 258 });
259 param.intern(&Interner) 259 param.intern(&Interner)
260 } else { 260 } else {
261 TyKind::Unknown.intern(&Interner) 261 TyKind::Error.intern(&Interner)
262 } 262 }
263 } 263 }
264 ImplTraitLoweringMode::Variable => { 264 ImplTraitLoweringMode::Variable => {
@@ -280,11 +280,11 @@ impl<'a> TyLoweringContext<'a> {
280 } 280 }
281 ImplTraitLoweringMode::Disallowed => { 281 ImplTraitLoweringMode::Disallowed => {
282 // FIXME: report error 282 // FIXME: report error
283 TyKind::Unknown.intern(&Interner) 283 TyKind::Error.intern(&Interner)
284 } 284 }
285 } 285 }
286 } 286 }
287 TypeRef::Error => TyKind::Unknown.intern(&Interner), 287 TypeRef::Error => TyKind::Error.intern(&Interner),
288 }; 288 };
289 (ty, res) 289 (ty, res)
290 } 290 }
@@ -328,7 +328,7 @@ impl<'a> TyLoweringContext<'a> {
328 (self.select_associated_type(res, segment), None) 328 (self.select_associated_type(res, segment), None)
329 } else if remaining_segments.len() > 1 { 329 } else if remaining_segments.len() > 1 {
330 // FIXME report error (ambiguous associated type) 330 // FIXME report error (ambiguous associated type)
331 (TyKind::Unknown.intern(&Interner), None) 331 (TyKind::Error.intern(&Interner), None)
332 } else { 332 } else {
333 (ty, res) 333 (ty, res)
334 } 334 }
@@ -372,12 +372,12 @@ impl<'a> TyLoweringContext<'a> {
372 } 372 }
373 None => { 373 None => {
374 // FIXME: report error (associated type not found) 374 // FIXME: report error (associated type not found)
375 TyKind::Unknown.intern(&Interner) 375 TyKind::Error.intern(&Interner)
376 } 376 }
377 } 377 }
378 } else if remaining_segments.len() > 1 { 378 } else if remaining_segments.len() > 1 {
379 // FIXME report error (ambiguous associated type) 379 // FIXME report error (ambiguous associated type)
380 TyKind::Unknown.intern(&Interner) 380 TyKind::Error.intern(&Interner)
381 } else { 381 } else {
382 let dyn_ty = DynTy { 382 let dyn_ty = DynTy {
383 bounds: Binders::new( 383 bounds: Binders::new(
@@ -433,7 +433,7 @@ impl<'a> TyLoweringContext<'a> {
433 self.lower_path_inner(resolved_segment, it.into(), infer_args) 433 self.lower_path_inner(resolved_segment, it.into(), infer_args)
434 } 434 }
435 // FIXME: report error 435 // FIXME: report error
436 TypeNs::EnumVariantId(_) => return (TyKind::Unknown.intern(&Interner), None), 436 TypeNs::EnumVariantId(_) => return (TyKind::Error.intern(&Interner), None),
437 }; 437 };
438 self.lower_ty_relative_path(ty, Some(resolution), remaining_segments) 438 self.lower_ty_relative_path(ty, Some(resolution), remaining_segments)
439 } 439 }
@@ -447,7 +447,7 @@ impl<'a> TyLoweringContext<'a> {
447 let (resolution, remaining_index) = 447 let (resolution, remaining_index) =
448 match self.resolver.resolve_path_in_type_ns(self.db.upcast(), path.mod_path()) { 448 match self.resolver.resolve_path_in_type_ns(self.db.upcast(), path.mod_path()) {
449 Some(it) => it, 449 Some(it) => it,
450 None => return (TyKind::Unknown.intern(&Interner), None), 450 None => return (TyKind::Error.intern(&Interner), None),
451 }; 451 };
452 let (resolved_segment, remaining_segments) = match remaining_index { 452 let (resolved_segment, remaining_segments) = match remaining_index {
453 None => ( 453 None => (
@@ -498,9 +498,9 @@ impl<'a> TyLoweringContext<'a> {
498 }, 498 },
499 ); 499 );
500 500
501 ty.unwrap_or(TyKind::Unknown.intern(&Interner)) 501 ty.unwrap_or(TyKind::Error.intern(&Interner))
502 } else { 502 } else {
503 TyKind::Unknown.intern(&Interner) 503 TyKind::Error.intern(&Interner)
504 } 504 }
505 } 505 }
506 506
@@ -569,13 +569,13 @@ impl<'a> TyLoweringContext<'a> {
569 def_generics.map_or((0, 0, 0, 0), |g| g.provenance_split()); 569 def_generics.map_or((0, 0, 0, 0), |g| g.provenance_split());
570 let total_len = parent_params + self_params + type_params + impl_trait_params; 570 let total_len = parent_params + self_params + type_params + impl_trait_params;
571 571
572 substs.extend(iter::repeat(TyKind::Unknown.intern(&Interner)).take(parent_params)); 572 substs.extend(iter::repeat(TyKind::Error.intern(&Interner)).take(parent_params));
573 573
574 let fill_self_params = || { 574 let fill_self_params = || {
575 substs.extend( 575 substs.extend(
576 explicit_self_ty 576 explicit_self_ty
577 .into_iter() 577 .into_iter()
578 .chain(iter::repeat(TyKind::Unknown.intern(&Interner))) 578 .chain(iter::repeat(TyKind::Error.intern(&Interner)))
579 .take(self_params), 579 .take(self_params),
580 ) 580 )
581 }; 581 };
@@ -628,7 +628,7 @@ impl<'a> TyLoweringContext<'a> {
628 // add placeholders for args that were not provided 628 // add placeholders for args that were not provided
629 // FIXME: emit diagnostics in contexts where this is not allowed 629 // FIXME: emit diagnostics in contexts where this is not allowed
630 for _ in substs.len()..total_len { 630 for _ in substs.len()..total_len {
631 substs.push(TyKind::Unknown.intern(&Interner)); 631 substs.push(TyKind::Error.intern(&Interner));
632 } 632 }
633 assert_eq!(substs.len(), total_len); 633 assert_eq!(substs.len(), total_len);
634 634
@@ -1008,7 +1008,7 @@ pub(crate) fn generic_defaults_query(
1008 .enumerate() 1008 .enumerate()
1009 .map(|(idx, (_, p))| { 1009 .map(|(idx, (_, p))| {
1010 let mut ty = 1010 let mut ty =
1011 p.default.as_ref().map_or(TyKind::Unknown.intern(&Interner), |t| ctx.lower_ty(t)); 1011 p.default.as_ref().map_or(TyKind::Error.intern(&Interner), |t| ctx.lower_ty(t));
1012 1012
1013 // Each default can only refer to previous parameters. 1013 // Each default can only refer to previous parameters.
1014 ty.walk_mut_binders( 1014 ty.walk_mut_binders(
@@ -1018,7 +1018,7 @@ pub(crate) fn generic_defaults_query(
1018 // type variable default referring to parameter coming 1018 // type variable default referring to parameter coming
1019 // after it. This is forbidden (FIXME: report 1019 // after it. This is forbidden (FIXME: report
1020 // diagnostic) 1020 // diagnostic)
1021 *ty = TyKind::Unknown.intern(&Interner); 1021 *ty = TyKind::Error.intern(&Interner);
1022 } 1022 }
1023 } 1023 }
1024 _ => {} 1024 _ => {}
@@ -1220,7 +1220,7 @@ pub(crate) fn ty_recover(db: &dyn HirDatabase, _cycle: &[String], def: &TyDefId)
1220 TyDefId::AdtId(it) => generics(db.upcast(), it.into()).len(), 1220 TyDefId::AdtId(it) => generics(db.upcast(), it.into()).len(),
1221 TyDefId::TypeAliasId(it) => generics(db.upcast(), it.into()).len(), 1221 TyDefId::TypeAliasId(it) => generics(db.upcast(), it.into()).len(),
1222 }; 1222 };
1223 Binders::new(num_binders, TyKind::Unknown.intern(&Interner)) 1223 Binders::new(num_binders, TyKind::Error.intern(&Interner))
1224} 1224}
1225 1225
1226pub(crate) fn value_ty_query(db: &dyn HirDatabase, def: ValueTyDefId) -> Binders<Ty> { 1226pub(crate) fn value_ty_query(db: &dyn HirDatabase, def: ValueTyDefId) -> Binders<Ty> {
@@ -1258,7 +1258,7 @@ pub(crate) fn impl_self_ty_recover(
1258 impl_id: &ImplId, 1258 impl_id: &ImplId,
1259) -> Binders<Ty> { 1259) -> Binders<Ty> {
1260 let generics = generics(db.upcast(), (*impl_id).into()); 1260 let generics = generics(db.upcast(), (*impl_id).into());
1261 Binders::new(generics.len(), TyKind::Unknown.intern(&Interner)) 1261 Binders::new(generics.len(), TyKind::Error.intern(&Interner))
1262} 1262}
1263 1263
1264pub(crate) fn impl_trait_query(db: &dyn HirDatabase, impl_id: ImplId) -> Option<Binders<TraitRef>> { 1264pub(crate) fn impl_trait_query(db: &dyn HirDatabase, impl_id: ImplId) -> Option<Binders<TraitRef>> {
diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs
index 0e4a620b6..dc6324780 100644
--- a/crates/hir_ty/src/method_resolution.rs
+++ b/crates/hir_ty/src/method_resolution.rs
@@ -742,7 +742,7 @@ fn fallback_bound_vars(s: Substitution, num_vars_to_keep: usize) -> Substitution
742 &mut |ty, binders| { 742 &mut |ty, binders| {
743 if let TyKind::BoundVar(bound) = ty.kind(&Interner) { 743 if let TyKind::BoundVar(bound) = ty.kind(&Interner) {
744 if bound.index >= num_vars_to_keep && bound.debruijn >= binders { 744 if bound.index >= num_vars_to_keep && bound.debruijn >= binders {
745 TyKind::Unknown.intern(&Interner) 745 TyKind::Error.intern(&Interner)
746 } else { 746 } else {
747 ty 747 ty
748 } 748 }
diff --git a/crates/hir_ty/src/op.rs b/crates/hir_ty/src/op.rs
index 90dd31a35..0491c5cb4 100644
--- a/crates/hir_ty/src/op.rs
+++ b/crates/hir_ty/src/op.rs
@@ -15,7 +15,7 @@ pub(super) fn binary_op_return_ty(op: BinaryOp, lhs_ty: Ty, rhs_ty: Ty) -> Ty {
15 | TyKind::Scalar(Scalar::Float(_)) => lhs_ty, 15 | TyKind::Scalar(Scalar::Float(_)) => lhs_ty,
16 TyKind::InferenceVar(_, TyVariableKind::Integer) 16 TyKind::InferenceVar(_, TyVariableKind::Integer)
17 | TyKind::InferenceVar(_, TyVariableKind::Float) => lhs_ty, 17 | TyKind::InferenceVar(_, TyVariableKind::Float) => lhs_ty,
18 _ => TyKind::Unknown.intern(&Interner), 18 _ => TyKind::Error.intern(&Interner),
19 } 19 }
20 } 20 }
21 BinaryOp::ArithOp(_) => match rhs_ty.kind(&Interner) { 21 BinaryOp::ArithOp(_) => match rhs_ty.kind(&Interner) {
@@ -24,7 +24,7 @@ pub(super) fn binary_op_return_ty(op: BinaryOp, lhs_ty: Ty, rhs_ty: Ty) -> Ty {
24 | TyKind::Scalar(Scalar::Float(_)) => rhs_ty, 24 | TyKind::Scalar(Scalar::Float(_)) => rhs_ty,
25 TyKind::InferenceVar(_, TyVariableKind::Integer) 25 TyKind::InferenceVar(_, TyVariableKind::Integer)
26 | TyKind::InferenceVar(_, TyVariableKind::Float) => rhs_ty, 26 | TyKind::InferenceVar(_, TyVariableKind::Float) => rhs_ty,
27 _ => TyKind::Unknown.intern(&Interner), 27 _ => TyKind::Error.intern(&Interner),
28 }, 28 },
29 } 29 }
30} 30}
@@ -37,10 +37,10 @@ pub(super) fn binary_op_rhs_expectation(op: BinaryOp, lhs_ty: Ty) -> Ty {
37 TyKind::Scalar(_) | TyKind::Str => lhs_ty, 37 TyKind::Scalar(_) | TyKind::Str => lhs_ty,
38 TyKind::InferenceVar(_, TyVariableKind::Integer) 38 TyKind::InferenceVar(_, TyVariableKind::Integer)
39 | TyKind::InferenceVar(_, TyVariableKind::Float) => lhs_ty, 39 | TyKind::InferenceVar(_, TyVariableKind::Float) => lhs_ty,
40 _ => TyKind::Unknown.intern(&Interner), 40 _ => TyKind::Error.intern(&Interner),
41 }, 41 },
42 BinaryOp::ArithOp(ArithOp::Shl) | BinaryOp::ArithOp(ArithOp::Shr) => { 42 BinaryOp::ArithOp(ArithOp::Shl) | BinaryOp::ArithOp(ArithOp::Shr) => {
43 TyKind::Unknown.intern(&Interner) 43 TyKind::Error.intern(&Interner)
44 } 44 }
45 BinaryOp::CmpOp(CmpOp::Ord { .. }) 45 BinaryOp::CmpOp(CmpOp::Ord { .. })
46 | BinaryOp::Assignment { op: Some(_) } 46 | BinaryOp::Assignment { op: Some(_) }
@@ -50,7 +50,7 @@ pub(super) fn binary_op_rhs_expectation(op: BinaryOp, lhs_ty: Ty) -> Ty {
50 | TyKind::Scalar(Scalar::Float(_)) => lhs_ty, 50 | TyKind::Scalar(Scalar::Float(_)) => lhs_ty,
51 TyKind::InferenceVar(_, TyVariableKind::Integer) 51 TyKind::InferenceVar(_, TyVariableKind::Integer)
52 | TyKind::InferenceVar(_, TyVariableKind::Float) => lhs_ty, 52 | TyKind::InferenceVar(_, TyVariableKind::Float) => lhs_ty,
53 _ => TyKind::Unknown.intern(&Interner), 53 _ => TyKind::Error.intern(&Interner),
54 }, 54 },
55 } 55 }
56} 56}
diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs
index 541e6082f..b7388b98c 100644
--- a/crates/hir_ty/src/traits/chalk.rs
+++ b/crates/hir_ty/src/traits/chalk.rs
@@ -265,7 +265,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
265 265
266 fn hidden_opaque_type(&self, _id: chalk_ir::OpaqueTyId<Interner>) -> chalk_ir::Ty<Interner> { 266 fn hidden_opaque_type(&self, _id: chalk_ir::OpaqueTyId<Interner>) -> chalk_ir::Ty<Interner> {
267 // FIXME: actually provide the hidden type; it is relevant for auto traits 267 // FIXME: actually provide the hidden type; it is relevant for auto traits
268 TyKind::Unknown.intern(&Interner).to_chalk(self.db) 268 TyKind::Error.intern(&Interner).to_chalk(self.db)
269 } 269 }
270 270
271 fn is_object_safe(&self, _trait_id: chalk_ir::TraitId<Interner>) -> bool { 271 fn is_object_safe(&self, _trait_id: chalk_ir::TraitId<Interner>) -> bool {
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs
index 5e4f97a46..c5654f17b 100644
--- a/crates/hir_ty/src/traits/chalk/mapping.rs
+++ b/crates/hir_ty/src/traits/chalk/mapping.rs
@@ -103,12 +103,12 @@ impl ToChalk for Ty {
103 }; 103 };
104 chalk_ir::TyKind::Dyn(bounded_ty).intern(&Interner) 104 chalk_ir::TyKind::Dyn(bounded_ty).intern(&Interner)
105 } 105 }
106 TyKind::Unknown => chalk_ir::TyKind::Error.intern(&Interner), 106 TyKind::Error => chalk_ir::TyKind::Error.intern(&Interner),
107 } 107 }
108 } 108 }
109 fn from_chalk(db: &dyn HirDatabase, chalk: chalk_ir::Ty<Interner>) -> Self { 109 fn from_chalk(db: &dyn HirDatabase, chalk: chalk_ir::Ty<Interner>) -> Self {
110 match chalk.data(&Interner).kind.clone() { 110 match chalk.data(&Interner).kind.clone() {
111 chalk_ir::TyKind::Error => TyKind::Unknown, 111 chalk_ir::TyKind::Error => TyKind::Error,
112 chalk_ir::TyKind::Array(ty, _size) => TyKind::Array(from_chalk(db, ty)), 112 chalk_ir::TyKind::Array(ty, _size) => TyKind::Array(from_chalk(db, ty)),
113 chalk_ir::TyKind::Placeholder(idx) => TyKind::Placeholder(idx), 113 chalk_ir::TyKind::Placeholder(idx) => TyKind::Placeholder(idx),
114 chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Projection(proj)) => { 114 chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Projection(proj)) => {
@@ -138,7 +138,7 @@ impl ToChalk for Ty {
138 TyKind::Function(FnPointer { num_args: (substs.len(&Interner) - 1), sig, substs }) 138 TyKind::Function(FnPointer { num_args: (substs.len(&Interner) - 1), sig, substs })
139 } 139 }
140 chalk_ir::TyKind::BoundVar(idx) => TyKind::BoundVar(idx), 140 chalk_ir::TyKind::BoundVar(idx) => TyKind::BoundVar(idx),
141 chalk_ir::TyKind::InferenceVar(_iv, _kind) => TyKind::Unknown, 141 chalk_ir::TyKind::InferenceVar(_iv, _kind) => TyKind::Error,
142 chalk_ir::TyKind::Dyn(where_clauses) => { 142 chalk_ir::TyKind::Dyn(where_clauses) => {
143 assert_eq!(where_clauses.bounds.binders.len(&Interner), 1); 143 assert_eq!(where_clauses.bounds.binders.len(&Interner), 1);
144 let bounds = where_clauses 144 let bounds = where_clauses
diff --git a/crates/hir_ty/src/types.rs b/crates/hir_ty/src/types.rs
index 53662fcdc..9853ab3be 100644
--- a/crates/hir_ty/src/types.rs
+++ b/crates/hir_ty/src/types.rs
@@ -179,7 +179,7 @@ pub enum TyKind {
179 /// variables are inserted before type checking, since we want to try to 179 /// variables are inserted before type checking, since we want to try to
180 /// infer a better type here anyway -- for the IDE use case, we want to try 180 /// infer a better type here anyway -- for the IDE use case, we want to try
181 /// to infer as much as possible even in the presence of type errors. 181 /// to infer as much as possible even in the presence of type errors.
182 Unknown, 182 Error,
183} 183}
184 184
185#[derive(Clone, PartialEq, Eq, Debug, Hash)] 185#[derive(Clone, PartialEq, Eq, Debug, Hash)]
diff --git a/crates/hir_ty/src/walk.rs b/crates/hir_ty/src/walk.rs
index bfb3f1041..5dfd59746 100644
--- a/crates/hir_ty/src/walk.rs
+++ b/crates/hir_ty/src/walk.rs
@@ -43,7 +43,7 @@ pub trait TypeWalk {
43 { 43 {
44 self.walk_mut_binders( 44 self.walk_mut_binders(
45 &mut |ty_mut, binders| { 45 &mut |ty_mut, binders| {
46 let ty = mem::replace(ty_mut, TyKind::Unknown.intern(&Interner)); 46 let ty = mem::replace(ty_mut, TyKind::Error.intern(&Interner));
47 *ty_mut = f(ty, binders); 47 *ty_mut = f(ty, binders);
48 }, 48 },
49 binders, 49 binders,
@@ -56,7 +56,7 @@ pub trait TypeWalk {
56 Self: Sized, 56 Self: Sized,
57 { 57 {
58 self.walk_mut(&mut |ty_mut| { 58 self.walk_mut(&mut |ty_mut| {
59 let ty = mem::replace(ty_mut, TyKind::Unknown.intern(&Interner)); 59 let ty = mem::replace(ty_mut, TyKind::Error.intern(&Interner));
60 *ty_mut = f(ty); 60 *ty_mut = f(ty);
61 }); 61 });
62 self 62 self