Skip to content

Commit

Permalink
Assert that ParamTy and ParamConst have identical names for identical…
Browse files Browse the repository at this point in the history
… indices
  • Loading branch information
compiler-errors committed Feb 5, 2024
1 parent 86eaa89 commit 8411eae
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions compiler/rustc_middle/src/ty/relate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,10 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>(
Ok(a)
}

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

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

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

(ty::ConstKind::Param(a_p), ty::ConstKind::Param(b_p)) => a_p.index == b_p.index,
(ty::ConstKind::Param(a_p), ty::ConstKind::Param(b_p)) if a_p.index == b_p.index => {
debug_assert_eq!(a_p.name, b_p.name, "param types with same index differ in name");
true
}
(ty::ConstKind::Placeholder(p1), ty::ConstKind::Placeholder(p2)) => p1 == p2,
(ty::ConstKind::Value(a_val), ty::ConstKind::Value(b_val)) => a_val == b_val,

Expand Down

0 comments on commit 8411eae

Please sign in to comment.