Skip to content

Commit 8a18f23

Browse files
bors[bot]lnicola
andauthored
Merge #8342
8342: Rename `TyKind::Unknown` and `TyKind::ForeignType` (Chalk move) r=flodiebold a=lnicola CC #8313 Co-authored-by: Laurențiu Nicola <[email protected]>
2 parents c2be91d + 72c54c5 commit 8a18f23

File tree

14 files changed

+58
-58
lines changed

14 files changed

+58
-58
lines changed

crates/hir/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,7 +1876,7 @@ impl Type {
18761876

18771877
fn go(ty: &Ty) -> bool {
18781878
match ty.kind(&Interner) {
1879-
TyKind::Unknown => true,
1879+
TyKind::Error => true,
18801880

18811881
TyKind::Adt(_, substs)
18821882
| TyKind::AssociatedType(_, substs)
@@ -1900,7 +1900,7 @@ impl Type {
19001900
| TyKind::Dyn(_)
19011901
| TyKind::Function(_)
19021902
| TyKind::Alias(_)
1903-
| TyKind::ForeignType(_) => false,
1903+
| TyKind::Foreign(_) => false,
19041904
}
19051905
}
19061906
}

crates/hir_ty/src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<D> TyBuilder<D> {
5454
}
5555

5656
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)))
5858
}
5959

6060
pub fn fill(mut self, filler: impl Iterator<Item = impl CastTo<GenericArg>>) -> Self {

crates/hir_ty/src/display.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ impl HirDisplay for Ty {
476476
parameter.assert_ty_ref(&Interner).kind(&Interner),
477477
default_parameters.get(i),
478478
) {
479-
(&TyKind::Unknown, _) | (_, None) => {
479+
(&TyKind::Error, _) | (_, None) => {
480480
default_from = i + 1;
481481
}
482482
(_, Some(default_parameter)) => {
@@ -529,7 +529,7 @@ impl HirDisplay for Ty {
529529
projection_ty.hir_fmt(f)?;
530530
}
531531
}
532-
TyKind::ForeignType(type_alias) => {
532+
TyKind::Foreign(type_alias) => {
533533
let type_alias = f.db.type_alias_data(from_foreign_def_id(*type_alias));
534534
write!(f, "{}", type_alias.name)?;
535535
}
@@ -636,7 +636,7 @@ impl HirDisplay for Ty {
636636
}
637637
};
638638
}
639-
TyKind::Unknown => {
639+
TyKind::Error => {
640640
if f.display_target.is_source_code() {
641641
return Err(HirDisplayError::DisplaySourceCodeError(
642642
DisplaySourceCodeError::UnknownType,

crates/hir_ty/src/infer.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ struct InternedStandardTypes {
120120

121121
impl Default for InternedStandardTypes {
122122
fn default() -> Self {
123-
InternedStandardTypes { unknown: TyKind::Unknown.intern(&Interner) }
123+
InternedStandardTypes { unknown: TyKind::Error.intern(&Interner) }
124124
}
125125
}
126126

@@ -247,7 +247,7 @@ impl<'a> InferenceContext<'a> {
247247
table: unify::InferenceTable::new(),
248248
obligations: Vec::default(),
249249
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
251251
trait_env: owner
252252
.as_generic_def_id()
253253
.map_or_else(Default::default, |d| db.trait_environment(d)),
@@ -261,7 +261,7 @@ impl<'a> InferenceContext<'a> {
261261
}
262262

263263
fn err_ty(&self) -> Ty {
264-
TyKind::Unknown.intern(&Interner)
264+
TyKind::Error.intern(&Interner)
265265
}
266266

267267
fn resolve_all(mut self) -> InferenceResult {
@@ -326,7 +326,7 @@ impl<'a> InferenceContext<'a> {
326326
/// Replaces Ty::Unknown by a new type var, so we can maybe still infer it.
327327
fn insert_type_vars_shallow(&mut self, ty: Ty) -> Ty {
328328
match ty.kind(&Interner) {
329-
TyKind::Unknown => self.table.new_type_var(),
329+
TyKind::Error => self.table.new_type_var(),
330330
_ => ty,
331331
}
332332
}
@@ -542,7 +542,7 @@ impl<'a> InferenceContext<'a> {
542542
result
543543
} else {
544544
// FIXME diagnostic
545-
(TyKind::Unknown.intern(&Interner), None)
545+
(TyKind::Error.intern(&Interner), None)
546546
}
547547
}
548548

@@ -755,15 +755,15 @@ impl Expectation {
755755
fn none() -> Self {
756756
Expectation {
757757
// FIXME
758-
ty: TyKind::Unknown.intern(&Interner),
758+
ty: TyKind::Error.intern(&Interner),
759759
rvalue_hint: false,
760760
}
761761
}
762762

763763
fn coercion_target(&self) -> Ty {
764764
if self.rvalue_hint {
765765
// FIXME
766-
TyKind::Unknown.intern(&Interner)
766+
TyKind::Error.intern(&Interner)
767767
} else {
768768
self.ty.clone()
769769
}

crates/hir_ty/src/infer/path.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl<'a> InferenceContext<'a> {
142142
remaining_segments_for_ty,
143143
true,
144144
);
145-
if let TyKind::Unknown = ty.kind(&Interner) {
145+
if let TyKind::Error = ty.kind(&Interner) {
146146
return None;
147147
}
148148

@@ -207,7 +207,7 @@ impl<'a> InferenceContext<'a> {
207207
name: &Name,
208208
id: ExprOrPatId,
209209
) -> Option<(ValueNs, Option<Substitution>)> {
210-
if let TyKind::Unknown = ty.kind(&Interner) {
210+
if let TyKind::Error = ty.kind(&Interner) {
211211
return None;
212212
}
213213

crates/hir_ty/src/infer/unify.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ impl TypeVariableTable {
214214
fn fallback_value(&self, iv: InferenceVar, kind: TyVariableKind) -> Ty {
215215
match kind {
216216
_ if self.inner[iv.to_inner().0 as usize].diverging => TyKind::Never,
217-
TyVariableKind::General => TyKind::Unknown,
217+
TyVariableKind::General => TyKind::Error,
218218
TyVariableKind::Integer => TyKind::Scalar(Scalar::Int(IntTy::I32)),
219219
TyVariableKind::Float => TyKind::Scalar(Scalar::Float(FloatTy::F64)),
220220
}
@@ -327,7 +327,7 @@ impl InferenceTable {
327327

328328
pub(super) fn unify_inner_trivial(&mut self, ty1: &Ty, ty2: &Ty, depth: usize) -> bool {
329329
match (ty1.kind(&Interner), ty2.kind(&Interner)) {
330-
(TyKind::Unknown, _) | (_, TyKind::Unknown) => true,
330+
(TyKind::Error, _) | (_, TyKind::Error) => true,
331331

332332
(TyKind::Placeholder(p1), TyKind::Placeholder(p2)) if *p1 == *p2 => true,
333333

crates/hir_ty/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ impl Ty {
290290
Some(db.lookup_intern_callable_def(callable.into()).into())
291291
}
292292
TyKind::AssociatedType(type_alias, ..) => Some(from_assoc_type_id(type_alias).into()),
293-
TyKind::ForeignType(type_alias, ..) => Some(from_foreign_def_id(type_alias).into()),
293+
TyKind::Foreign(type_alias, ..) => Some(from_foreign_def_id(type_alias).into()),
294294
_ => None,
295295
}
296296
}
@@ -300,7 +300,7 @@ impl Ty {
300300
}
301301

302302
pub fn is_unknown(&self) -> bool {
303-
matches!(self.kind(&Interner), TyKind::Unknown)
303+
matches!(self.kind(&Interner), TyKind::Error)
304304
}
305305

306306
pub fn equals_ctor(&self, other: &Ty) -> bool {
@@ -312,7 +312,7 @@ impl Ty {
312312
(TyKind::AssociatedType(ty_id, ..), TyKind::AssociatedType(ty_id2, ..)) => {
313313
ty_id == ty_id2
314314
}
315-
(TyKind::ForeignType(ty_id, ..), TyKind::ForeignType(ty_id2, ..)) => ty_id == ty_id2,
315+
(TyKind::Foreign(ty_id, ..), TyKind::Foreign(ty_id2, ..)) => ty_id == ty_id2,
316316
(TyKind::Closure(id1, _), TyKind::Closure(id2, _)) => id1 == id2,
317317
(TyKind::Ref(mutability, ..), TyKind::Ref(mutability2, ..))
318318
| (TyKind::Raw(mutability, ..), TyKind::Raw(mutability2, ..)) => {

crates/hir_ty/src/lower.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl<'a> TyLoweringContext<'a> {
176176
let inner_ty = self.lower_ty(inner);
177177
TyKind::Ref(lower_to_chalk_mutability(*mutability), inner_ty).intern(&Interner)
178178
}
179-
TypeRef::Placeholder => TyKind::Unknown.intern(&Interner),
179+
TypeRef::Placeholder => TyKind::Error.intern(&Interner),
180180
TypeRef::Fn(params, is_varargs) => {
181181
let substs =
182182
Substitution::from_iter(&Interner, params.iter().map(|tr| self.lower_ty(tr)));
@@ -253,12 +253,12 @@ impl<'a> TyLoweringContext<'a> {
253253
data.provenance == TypeParamProvenance::ArgumentImplTrait
254254
})
255255
.nth(idx as usize)
256-
.map_or(TyKind::Unknown, |(id, _)| {
256+
.map_or(TyKind::Error, |(id, _)| {
257257
TyKind::Placeholder(to_placeholder_idx(self.db, id))
258258
});
259259
param.intern(&Interner)
260260
} else {
261-
TyKind::Unknown.intern(&Interner)
261+
TyKind::Error.intern(&Interner)
262262
}
263263
}
264264
ImplTraitLoweringMode::Variable => {
@@ -280,11 +280,11 @@ impl<'a> TyLoweringContext<'a> {
280280
}
281281
ImplTraitLoweringMode::Disallowed => {
282282
// FIXME: report error
283-
TyKind::Unknown.intern(&Interner)
283+
TyKind::Error.intern(&Interner)
284284
}
285285
}
286286
}
287-
TypeRef::Error => TyKind::Unknown.intern(&Interner),
287+
TypeRef::Error => TyKind::Error.intern(&Interner),
288288
};
289289
(ty, res)
290290
}
@@ -328,7 +328,7 @@ impl<'a> TyLoweringContext<'a> {
328328
(self.select_associated_type(res, segment), None)
329329
} else if remaining_segments.len() > 1 {
330330
// FIXME report error (ambiguous associated type)
331-
(TyKind::Unknown.intern(&Interner), None)
331+
(TyKind::Error.intern(&Interner), None)
332332
} else {
333333
(ty, res)
334334
}
@@ -372,12 +372,12 @@ impl<'a> TyLoweringContext<'a> {
372372
}
373373
None => {
374374
// FIXME: report error (associated type not found)
375-
TyKind::Unknown.intern(&Interner)
375+
TyKind::Error.intern(&Interner)
376376
}
377377
}
378378
} else if remaining_segments.len() > 1 {
379379
// FIXME report error (ambiguous associated type)
380-
TyKind::Unknown.intern(&Interner)
380+
TyKind::Error.intern(&Interner)
381381
} else {
382382
let dyn_ty = DynTy {
383383
bounds: Binders::new(
@@ -433,7 +433,7 @@ impl<'a> TyLoweringContext<'a> {
433433
self.lower_path_inner(resolved_segment, it.into(), infer_args)
434434
}
435435
// FIXME: report error
436-
TypeNs::EnumVariantId(_) => return (TyKind::Unknown.intern(&Interner), None),
436+
TypeNs::EnumVariantId(_) => return (TyKind::Error.intern(&Interner), None),
437437
};
438438
self.lower_ty_relative_path(ty, Some(resolution), remaining_segments)
439439
}
@@ -447,7 +447,7 @@ impl<'a> TyLoweringContext<'a> {
447447
let (resolution, remaining_index) =
448448
match self.resolver.resolve_path_in_type_ns(self.db.upcast(), path.mod_path()) {
449449
Some(it) => it,
450-
None => return (TyKind::Unknown.intern(&Interner), None),
450+
None => return (TyKind::Error.intern(&Interner), None),
451451
};
452452
let (resolved_segment, remaining_segments) = match remaining_index {
453453
None => (
@@ -498,9 +498,9 @@ impl<'a> TyLoweringContext<'a> {
498498
},
499499
);
500500

501-
ty.unwrap_or(TyKind::Unknown.intern(&Interner))
501+
ty.unwrap_or(TyKind::Error.intern(&Interner))
502502
} else {
503-
TyKind::Unknown.intern(&Interner)
503+
TyKind::Error.intern(&Interner)
504504
}
505505
}
506506

@@ -569,13 +569,13 @@ impl<'a> TyLoweringContext<'a> {
569569
def_generics.map_or((0, 0, 0, 0), |g| g.provenance_split());
570570
let total_len = parent_params + self_params + type_params + impl_trait_params;
571571

572-
substs.extend(iter::repeat(TyKind::Unknown.intern(&Interner)).take(parent_params));
572+
substs.extend(iter::repeat(TyKind::Error.intern(&Interner)).take(parent_params));
573573

574574
let fill_self_params = || {
575575
substs.extend(
576576
explicit_self_ty
577577
.into_iter()
578-
.chain(iter::repeat(TyKind::Unknown.intern(&Interner)))
578+
.chain(iter::repeat(TyKind::Error.intern(&Interner)))
579579
.take(self_params),
580580
)
581581
};
@@ -628,7 +628,7 @@ impl<'a> TyLoweringContext<'a> {
628628
// add placeholders for args that were not provided
629629
// FIXME: emit diagnostics in contexts where this is not allowed
630630
for _ in substs.len()..total_len {
631-
substs.push(TyKind::Unknown.intern(&Interner));
631+
substs.push(TyKind::Error.intern(&Interner));
632632
}
633633
assert_eq!(substs.len(), total_len);
634634

@@ -1008,7 +1008,7 @@ pub(crate) fn generic_defaults_query(
10081008
.enumerate()
10091009
.map(|(idx, (_, p))| {
10101010
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));
10121012

10131013
// Each default can only refer to previous parameters.
10141014
ty.walk_mut_binders(
@@ -1018,7 +1018,7 @@ pub(crate) fn generic_defaults_query(
10181018
// type variable default referring to parameter coming
10191019
// after it. This is forbidden (FIXME: report
10201020
// diagnostic)
1021-
*ty = TyKind::Unknown.intern(&Interner);
1021+
*ty = TyKind::Error.intern(&Interner);
10221022
}
10231023
}
10241024
_ => {}
@@ -1145,7 +1145,7 @@ fn type_for_type_alias(db: &dyn HirDatabase, t: TypeAliasId) -> Binders<Ty> {
11451145
let ctx =
11461146
TyLoweringContext::new(db, &resolver).with_type_param_mode(TypeParamLoweringMode::Variable);
11471147
if db.type_alias_data(t).is_extern {
1148-
Binders::new(0, TyKind::ForeignType(crate::to_foreign_def_id(t)).intern(&Interner))
1148+
Binders::new(0, TyKind::Foreign(crate::to_foreign_def_id(t)).intern(&Interner))
11491149
} else {
11501150
let type_ref = &db.type_alias_data(t).type_ref;
11511151
let inner = ctx.lower_ty(type_ref.as_deref().unwrap_or(&TypeRef::Error));
@@ -1220,7 +1220,7 @@ pub(crate) fn ty_recover(db: &dyn HirDatabase, _cycle: &[String], def: &TyDefId)
12201220
TyDefId::AdtId(it) => generics(db.upcast(), it.into()).len(),
12211221
TyDefId::TypeAliasId(it) => generics(db.upcast(), it.into()).len(),
12221222
};
1223-
Binders::new(num_binders, TyKind::Unknown.intern(&Interner))
1223+
Binders::new(num_binders, TyKind::Error.intern(&Interner))
12241224
}
12251225

12261226
pub(crate) fn value_ty_query(db: &dyn HirDatabase, def: ValueTyDefId) -> Binders<Ty> {
@@ -1258,7 +1258,7 @@ pub(crate) fn impl_self_ty_recover(
12581258
impl_id: &ImplId,
12591259
) -> Binders<Ty> {
12601260
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))
12621262
}
12631263

12641264
pub(crate) fn impl_trait_query(db: &dyn HirDatabase, impl_id: ImplId) -> Option<Binders<TraitRef>> {

crates/hir_ty/src/method_resolution.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl TyFingerprint {
5555
TyKind::Adt(AdtId(adt), _) => TyFingerprint::Adt(adt),
5656
TyKind::Tuple(cardinality, _) => TyFingerprint::Tuple(cardinality),
5757
TyKind::Raw(mutability, ..) => TyFingerprint::RawPtr(mutability),
58-
TyKind::ForeignType(alias_id, ..) => TyFingerprint::ForeignType(alias_id),
58+
TyKind::Foreign(alias_id, ..) => TyFingerprint::ForeignType(alias_id),
5959
TyKind::Function(FnPointer { num_args, sig, .. }) => {
6060
TyFingerprint::FnPtr(num_args, sig)
6161
}
@@ -246,7 +246,7 @@ impl Ty {
246246
TyKind::Adt(AdtId(def_id), _) => {
247247
return mod_to_crate_ids(def_id.module(db.upcast()));
248248
}
249-
TyKind::ForeignType(id) => {
249+
TyKind::Foreign(id) => {
250250
return mod_to_crate_ids(
251251
from_foreign_def_id(*id).lookup(db.upcast()).module(db.upcast()),
252252
);
@@ -742,7 +742,7 @@ fn fallback_bound_vars(s: Substitution, num_vars_to_keep: usize) -> Substitution
742742
&mut |ty, binders| {
743743
if let TyKind::BoundVar(bound) = ty.kind(&Interner) {
744744
if bound.index >= num_vars_to_keep && bound.debruijn >= binders {
745-
TyKind::Unknown.intern(&Interner)
745+
TyKind::Error.intern(&Interner)
746746
} else {
747747
ty
748748
}

0 commit comments

Comments
 (0)