Skip to content

Commit 41501c7

Browse files
Rename super_relate_* to structurally_relate_*
1 parent 6d0b6c0 commit 41501c7

File tree

6 files changed

+26
-23
lines changed

6 files changed

+26
-23
lines changed

compiler/rustc_infer/src/infer/combine.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl<'tcx> InferCtxt<'tcx> {
145145
Ok(a)
146146
}
147147

148-
_ => ty::relate::super_relate_tys(relation, a, b),
148+
_ => ty::relate::structurally_relate_tys(relation, a, b),
149149
}
150150
}
151151

@@ -245,7 +245,7 @@ impl<'tcx> InferCtxt<'tcx> {
245245
_ => {}
246246
}
247247

248-
ty::relate::super_relate_consts(relation, a, b)
248+
ty::relate::structurally_relate_consts(relation, a, b)
249249
}
250250

251251
/// Unifies the const variable `target_vid` with the given constant.

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2723,7 +2723,7 @@ impl<'tcx> TypeRelation<'tcx> for SameTypeModuloInfer<'_, 'tcx> {
27232723
| (ty::Infer(ty::InferTy::TyVar(_)), _)
27242724
| (_, ty::Infer(ty::InferTy::TyVar(_))) => Ok(a),
27252725
(ty::Infer(_), _) | (_, ty::Infer(_)) => Err(TypeError::Mismatch),
2726-
_ => relate::super_relate_tys(self, a, b),
2726+
_ => relate::structurally_relate_tys(self, a, b),
27272727
}
27282728
}
27292729

compiler/rustc_infer/src/infer/generalize.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ where
306306
}
307307
}
308308

309-
_ => relate::super_relate_tys(self, t, t),
309+
_ => relate::structurally_relate_tys(self, t, t),
310310
}?;
311311

312312
self.cache.insert(t, g);
@@ -422,7 +422,7 @@ where
422422
Err(TypeError::Mismatch)
423423
}
424424
}
425-
_ => relate::super_relate_consts(self, c, c),
425+
_ => relate::structurally_relate_consts(self, c, c),
426426
}
427427
}
428428

compiler/rustc_infer/src/infer/outlives/test_type_match.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ impl<'tcx> TypeRelation<'tcx> for Match<'tcx> {
187187
} else if pattern == value {
188188
Ok(pattern)
189189
} else {
190-
relate::super_relate_tys(self, pattern, value)
190+
relate::structurally_relate_tys(self, pattern, value)
191191
}
192192
}
193193

@@ -201,7 +201,7 @@ impl<'tcx> TypeRelation<'tcx> for Match<'tcx> {
201201
if pattern == value {
202202
Ok(pattern)
203203
} else {
204-
relate::super_relate_consts(self, pattern, value)
204+
relate::structurally_relate_consts(self, pattern, value)
205205
}
206206
}
207207

compiler/rustc_middle/src/ty/_match.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl<'tcx> TypeRelation<'tcx> for Match<'tcx> {
8383

8484
(&ty::Error(guar), _) | (_, &ty::Error(guar)) => Ok(self.tcx().ty_error(guar)),
8585

86-
_ => relate::super_relate_tys(self, a, b),
86+
_ => relate::structurally_relate_tys(self, a, b),
8787
}
8888
}
8989

@@ -109,7 +109,7 @@ impl<'tcx> TypeRelation<'tcx> for Match<'tcx> {
109109
_ => {}
110110
}
111111

112-
relate::super_relate_consts(self, a, b)
112+
relate::structurally_relate_consts(self, a, b)
113113
}
114114

115115
fn binders<T>(

compiler/rustc_middle/src/ty/relate.rs

+17-14
Original file line numberDiff line numberDiff line change
@@ -388,24 +388,24 @@ impl<'tcx> Relate<'tcx> for Ty<'tcx> {
388388
}
389389
}
390390

391-
/// The main "type relation" routine. Note that this does not handle
392-
/// inference artifacts, so you should filter those out before calling
393-
/// it.
394-
pub fn super_relate_tys<'tcx, R: TypeRelation<'tcx>>(
391+
/// Relates `a` and `b` structurally, calling the relation for all nested values.
392+
/// Any semantic equality, e.g. of projections, and inference variables have to be
393+
/// handled by the caller.
394+
pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>(
395395
relation: &mut R,
396396
a: Ty<'tcx>,
397397
b: Ty<'tcx>,
398398
) -> RelateResult<'tcx, Ty<'tcx>> {
399399
let tcx = relation.tcx();
400-
debug!("super_relate_tys: a={:?} b={:?}", a, b);
400+
debug!("structurally_relate_tys: a={:?} b={:?}", a, b);
401401
match (a.kind(), b.kind()) {
402402
(&ty::Infer(_), _) | (_, &ty::Infer(_)) => {
403403
// The caller should handle these cases!
404-
bug!("var types encountered in super_relate_tys")
404+
bug!("var types encountered in structurally_relate_tys")
405405
}
406406

407407
(ty::Bound(..), _) | (_, ty::Bound(..)) => {
408-
bug!("bound types encountered in super_relate_tys")
408+
bug!("bound types encountered in structurally_relate_tys")
409409
}
410410

411411
(&ty::Error(guar), _) | (_, &ty::Error(guar)) => Ok(tcx.ty_error(guar)),
@@ -575,15 +575,18 @@ pub fn super_relate_tys<'tcx, R: TypeRelation<'tcx>>(
575575
}
576576
}
577577

578-
/// The main "const relation" routine. Note that this does not handle
579-
/// inference artifacts, so you should filter those out before calling
580-
/// it.
581-
pub fn super_relate_consts<'tcx, R: TypeRelation<'tcx>>(
578+
/// Relates `a` and `b` structurally, calling the relation for all nested values.
579+
/// Any semantic equality, e.g. of unevaluated consts, and inference variables have
580+
/// to be handled by the caller.
581+
///
582+
/// FIXME: This is not totally structual, which probably should be fixed.
583+
/// See the HACKs below.
584+
pub fn structurally_relate_consts<'tcx, R: TypeRelation<'tcx>>(
582585
relation: &mut R,
583586
mut a: ty::Const<'tcx>,
584587
mut b: ty::Const<'tcx>,
585588
) -> RelateResult<'tcx, ty::Const<'tcx>> {
586-
debug!("{}.super_relate_consts(a = {:?}, b = {:?})", relation.tag(), a, b);
589+
debug!("{}.structurally_relate_consts(a = {:?}, b = {:?})", relation.tag(), a, b);
587590
let tcx = relation.tcx();
588591

589592
// HACK(const_generics): We still need to eagerly evaluate consts when
@@ -602,15 +605,15 @@ pub fn super_relate_consts<'tcx, R: TypeRelation<'tcx>>(
602605
b = tcx.expand_abstract_consts(b);
603606
}
604607

605-
debug!("{}.super_relate_consts(normed_a = {:?}, normed_b = {:?})", relation.tag(), a, b);
608+
debug!("{}.structurally_relate_consts(normed_a = {:?}, normed_b = {:?})", relation.tag(), a, b);
606609

607610
// Currently, the values that can be unified are primitive types,
608611
// and those that derive both `PartialEq` and `Eq`, corresponding
609612
// to structural-match types.
610613
let is_match = match (a.kind(), b.kind()) {
611614
(ty::ConstKind::Infer(_), _) | (_, ty::ConstKind::Infer(_)) => {
612615
// The caller should handle these cases!
613-
bug!("var types encountered in super_relate_consts: {:?} {:?}", a, b)
616+
bug!("var types encountered in structurally_relate_consts: {:?} {:?}", a, b)
614617
}
615618

616619
(ty::ConstKind::Error(_), _) => return Ok(a),

0 commit comments

Comments
 (0)