Skip to content

Commit 94ee0f1

Browse files
Assert that ParamTy and ParamConst have identical names for identical indices
1 parent bf3c6c5 commit 94ee0f1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

compiler/rustc_middle/src/ty/relate.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,10 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>(
435435
Ok(a)
436436
}
437437

438-
(ty::Param(a_p), ty::Param(b_p)) if a_p.index == b_p.index => Ok(a),
438+
(ty::Param(a_p), ty::Param(b_p)) if a_p.index == b_p.index => {
439+
debug_assert_eq!(a_p.name, b_p.name, "param types with same index differ in name");
440+
Ok(a)
441+
},
439442

440443
(ty::Placeholder(p1), ty::Placeholder(p2)) if p1 == p2 => Ok(a),
441444

@@ -586,7 +589,10 @@ pub fn structurally_relate_consts<'tcx, R: TypeRelation<'tcx>>(
586589
(ty::ConstKind::Error(_), _) => return Ok(a),
587590
(_, ty::ConstKind::Error(_)) => return Ok(b),
588591

589-
(ty::ConstKind::Param(a_p), ty::ConstKind::Param(b_p)) => a_p.index == b_p.index,
592+
(ty::ConstKind::Param(a_p), ty::ConstKind::Param(b_p)) if a_p.index == b_p.index => {
593+
debug_assert_eq!(a_p.name, b_p.name, "param types with same index differ in name");
594+
true
595+
}
590596
(ty::ConstKind::Placeholder(p1), ty::ConstKind::Placeholder(p2)) => p1 == p2,
591597
(ty::ConstKind::Value(a_val), ty::ConstKind::Value(b_val)) => a_val == b_val,
592598

0 commit comments

Comments
 (0)