|
1 | 1 | use super::SubregionOrigin; |
2 | | -use super::combine::{CombineFields, RelationDir, const_unification_error}; |
| 2 | +use super::combine::{CombineFields, RelationDir}; |
3 | 3 |
|
4 | 4 | use crate::traits::Obligation; |
5 | | -use crate::ty::{self, Ty, TyCtxt, InferConst}; |
| 5 | +use crate::ty::{self, Ty, TyCtxt}; |
6 | 6 | use crate::ty::TyVar; |
7 | 7 | use crate::ty::fold::TypeFoldable; |
8 | 8 | use crate::ty::relate::{Cause, Relate, RelateResult, TypeRelation}; |
9 | | -use crate::infer::unify_key::replace_if_possible; |
10 | | -use crate::mir::interpret::ConstValue; |
11 | 9 | use std::mem; |
12 | 10 |
|
13 | 11 | /// Ensures `a` is made a subtype of `b`. Returns `a` on success. |
@@ -142,41 +140,7 @@ impl TypeRelation<'tcx> for Sub<'combine, 'infcx, 'tcx> { |
142 | 140 | a: &'tcx ty::Const<'tcx>, |
143 | 141 | b: &'tcx ty::Const<'tcx>, |
144 | 142 | ) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>> { |
145 | | - debug!("{}.consts({:?}, {:?})", self.tag(), a, b); |
146 | | - if a == b { return Ok(a); } |
147 | | - |
148 | | - let infcx = self.fields.infcx; |
149 | | - let a = replace_if_possible(infcx.const_unification_table.borrow_mut(), a); |
150 | | - let b = replace_if_possible(infcx.const_unification_table.borrow_mut(), b); |
151 | | - |
152 | | - // Consts can only be equal or unequal to each other: there's no subtyping |
153 | | - // relation, so we're just going to perform equating here instead. |
154 | | - let a_is_expected = self.a_is_expected(); |
155 | | - match (a.val, b.val) { |
156 | | - (ConstValue::Infer(InferConst::Var(a_vid)), |
157 | | - ConstValue::Infer(InferConst::Var(b_vid))) => { |
158 | | - infcx.const_unification_table |
159 | | - .borrow_mut() |
160 | | - .unify_var_var(a_vid, b_vid) |
161 | | - .map_err(|e| const_unification_error(a_is_expected, e))?; |
162 | | - return Ok(a); |
163 | | - } |
164 | | - |
165 | | - (ConstValue::Infer(InferConst::Var(a_id)), _) => { |
166 | | - self.fields.infcx.unify_const_variable(a_is_expected, a_id, b)?; |
167 | | - return Ok(a); |
168 | | - } |
169 | | - |
170 | | - (_, ConstValue::Infer(InferConst::Var(b_id))) => { |
171 | | - self.fields.infcx.unify_const_variable(!a_is_expected, b_id, a)?; |
172 | | - return Ok(a); |
173 | | - } |
174 | | - |
175 | | - _ => {} |
176 | | - } |
177 | | - |
178 | | - self.fields.infcx.super_combine_consts(self, a, b)?; |
179 | | - Ok(a) |
| 143 | + self.fields.infcx.super_combine_consts(self, a, b) |
180 | 144 | } |
181 | 145 |
|
182 | 146 | fn binders<T>(&mut self, a: &ty::Binder<T>, b: &ty::Binder<T>) |
|
0 commit comments