Skip to content

Commit d2b7ab0

Browse files
committed
Auto merge of rust-lang#15304 - HKalbasi:mir, r=HKalbasi
Use `.kind(Interner)` instead of `.data(Interner).kind`
2 parents 37f84c1 + e64a10f commit d2b7ab0

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

crates/hir-ty/src/mir.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl<V, T> ProjectionElem<V, T> {
142142
closure_field: impl FnOnce(ClosureId, &Substitution, usize) -> Ty,
143143
krate: CrateId,
144144
) -> Ty {
145-
if matches!(base.data(Interner).kind, TyKind::Alias(_) | TyKind::AssociatedType(..)) {
145+
if matches!(base.kind(Interner), TyKind::Alias(_) | TyKind::AssociatedType(..)) {
146146
base = normalize(
147147
db,
148148
// FIXME: we should get this from caller
@@ -151,7 +151,7 @@ impl<V, T> ProjectionElem<V, T> {
151151
);
152152
}
153153
match self {
154-
ProjectionElem::Deref => match &base.data(Interner).kind {
154+
ProjectionElem::Deref => match &base.kind(Interner) {
155155
TyKind::Raw(_, inner) | TyKind::Ref(_, _, inner) => inner.clone(),
156156
TyKind::Adt(adt, subst) if is_box(db, adt.0) => {
157157
subst.at(Interner, 0).assert_ty_ref(Interner).clone()
@@ -161,7 +161,7 @@ impl<V, T> ProjectionElem<V, T> {
161161
return TyKind::Error.intern(Interner);
162162
}
163163
},
164-
ProjectionElem::Field(f) => match &base.data(Interner).kind {
164+
ProjectionElem::Field(f) => match &base.kind(Interner) {
165165
TyKind::Adt(_, subst) => {
166166
db.field_types(f.parent)[f.local_id].clone().substitute(Interner, subst)
167167
}
@@ -170,7 +170,7 @@ impl<V, T> ProjectionElem<V, T> {
170170
return TyKind::Error.intern(Interner);
171171
}
172172
},
173-
ProjectionElem::TupleOrClosureField(f) => match &base.data(Interner).kind {
173+
ProjectionElem::TupleOrClosureField(f) => match &base.kind(Interner) {
174174
TyKind::Tuple(_, subst) => subst
175175
.as_slice(Interner)
176176
.get(*f)
@@ -187,15 +187,15 @@ impl<V, T> ProjectionElem<V, T> {
187187
}
188188
},
189189
ProjectionElem::ConstantIndex { .. } | ProjectionElem::Index(_) => {
190-
match &base.data(Interner).kind {
190+
match &base.kind(Interner) {
191191
TyKind::Array(inner, _) | TyKind::Slice(inner) => inner.clone(),
192192
_ => {
193193
never!("Overloaded index is not a projection");
194194
return TyKind::Error.intern(Interner);
195195
}
196196
}
197197
}
198-
&ProjectionElem::Subslice { from, to } => match &base.data(Interner).kind {
198+
&ProjectionElem::Subslice { from, to } => match &base.kind(Interner) {
199199
TyKind::Array(inner, c) => {
200200
let next_c = usize_const(
201201
db,

crates/hir-ty/src/mir/eval.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ impl Evaluator<'_> {
634634
addr = addr.offset(ty_size * offset);
635635
}
636636
&ProjectionElem::Subslice { from, to } => {
637-
let inner_ty = match &ty.data(Interner).kind {
637+
let inner_ty = match &ty.kind(Interner) {
638638
TyKind::Array(inner, _) | TyKind::Slice(inner) => inner.clone(),
639639
_ => TyKind::Error.intern(Interner),
640640
};
@@ -793,7 +793,7 @@ impl Evaluator<'_> {
793793
.iter()
794794
.map(|it| self.operand_ty_and_eval(it, &mut locals))
795795
.collect::<Result<Vec<_>>>()?;
796-
let stack_frame = match &fn_ty.data(Interner).kind {
796+
let stack_frame = match &fn_ty.kind(Interner) {
797797
TyKind::Function(_) => {
798798
let bytes = self.eval_operand(func, &mut locals)?;
799799
self.exec_fn_pointer(
@@ -1255,7 +1255,7 @@ impl Evaluator<'_> {
12551255
PointerCast::ReifyFnPointer | PointerCast::ClosureFnPointer(_) => {
12561256
let current_ty = self.operand_ty(operand, locals)?;
12571257
if let TyKind::FnDef(_, _) | TyKind::Closure(_, _) =
1258-
&current_ty.data(Interner).kind
1258+
&current_ty.kind(Interner)
12591259
{
12601260
let id = self.vtable_map.id(current_ty);
12611261
let ptr_size = self.ptr_size();
@@ -1408,8 +1408,8 @@ impl Evaluator<'_> {
14081408
addr: Interval,
14091409
) -> Result<IntervalOrOwned> {
14101410
use IntervalOrOwned::*;
1411-
Ok(match &target_ty.data(Interner).kind {
1412-
TyKind::Slice(_) => match &current_ty.data(Interner).kind {
1411+
Ok(match &target_ty.kind(Interner) {
1412+
TyKind::Slice(_) => match &current_ty.kind(Interner) {
14131413
TyKind::Array(_, size) => {
14141414
let len = match try_const_usize(self.db, size) {
14151415
None => {
@@ -1435,7 +1435,7 @@ impl Evaluator<'_> {
14351435
r.extend(vtable.to_le_bytes().into_iter());
14361436
Owned(r)
14371437
}
1438-
TyKind::Adt(id, target_subst) => match &current_ty.data(Interner).kind {
1438+
TyKind::Adt(id, target_subst) => match &current_ty.kind(Interner) {
14391439
TyKind::Adt(current_id, current_subst) => {
14401440
if id != current_id {
14411441
not_supported!("unsizing struct with different type");
@@ -1931,7 +1931,7 @@ impl Evaluator<'_> {
19311931
) -> Result<Option<StackFrame>> {
19321932
let id = from_bytes!(usize, bytes.get(self)?);
19331933
let next_ty = self.vtable_map.ty(id)?.clone();
1934-
match &next_ty.data(Interner).kind {
1934+
match &next_ty.kind(Interner) {
19351935
TyKind::FnDef(def, generic_args) => {
19361936
self.exec_fn_def(*def, generic_args, destination, args, &locals, target_bb, span)
19371937
}
@@ -2182,7 +2182,7 @@ impl Evaluator<'_> {
21822182
let size = self.size_of_sized(&func_ty, locals, "self type of fn trait")?;
21832183
func_data = Interval { addr: Address::from_bytes(func_data.get(self)?)?, size };
21842184
}
2185-
match &func_ty.data(Interner).kind {
2185+
match &func_ty.kind(Interner) {
21862186
TyKind::FnDef(def, subst) => {
21872187
return self.exec_fn_def(
21882188
*def,

crates/hir-ty/src/mir/lower.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
633633
);
634634
}
635635
let callee_ty = self.expr_ty_after_adjustments(*callee);
636-
match &callee_ty.data(Interner).kind {
636+
match &callee_ty.kind(Interner) {
637637
chalk_ir::TyKind::FnDef(..) => {
638638
let func = Operand::from_bytes(vec![], callee_ty.clone());
639639
self.lower_call_and_args(
@@ -1229,7 +1229,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
12291229
}
12301230
Expr::Array(l) => match l {
12311231
Array::ElementList { elements, .. } => {
1232-
let elem_ty = match &self.expr_ty_without_adjust(expr_id).data(Interner).kind {
1232+
let elem_ty = match &self.expr_ty_without_adjust(expr_id).kind(Interner) {
12331233
TyKind::Array(ty, _) => ty.clone(),
12341234
_ => {
12351235
return Err(MirLowerError::TypeError(
@@ -1260,7 +1260,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
12601260
else {
12611261
return Ok(None);
12621262
};
1263-
let len = match &self.expr_ty_without_adjust(expr_id).data(Interner).kind {
1263+
let len = match &self.expr_ty_without_adjust(expr_id).kind(Interner) {
12641264
TyKind::Array(_, len) => len.clone(),
12651265
_ => {
12661266
return Err(MirLowerError::TypeError(

0 commit comments

Comments
 (0)