mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
Use .kind(Interner)
instead of .data(Interner).kind
This commit is contained in:
parent
832eb0d94c
commit
e64a10fc4d
3 changed files with 17 additions and 17 deletions
|
@ -142,7 +142,7 @@ impl<V, T> ProjectionElem<V, T> {
|
||||||
closure_field: impl FnOnce(ClosureId, &Substitution, usize) -> Ty,
|
closure_field: impl FnOnce(ClosureId, &Substitution, usize) -> Ty,
|
||||||
krate: CrateId,
|
krate: CrateId,
|
||||||
) -> Ty {
|
) -> Ty {
|
||||||
if matches!(base.data(Interner).kind, TyKind::Alias(_) | TyKind::AssociatedType(..)) {
|
if matches!(base.kind(Interner), TyKind::Alias(_) | TyKind::AssociatedType(..)) {
|
||||||
base = normalize(
|
base = normalize(
|
||||||
db,
|
db,
|
||||||
// FIXME: we should get this from caller
|
// FIXME: we should get this from caller
|
||||||
|
@ -151,7 +151,7 @@ impl<V, T> ProjectionElem<V, T> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
match self {
|
match self {
|
||||||
ProjectionElem::Deref => match &base.data(Interner).kind {
|
ProjectionElem::Deref => match &base.kind(Interner) {
|
||||||
TyKind::Raw(_, inner) | TyKind::Ref(_, _, inner) => inner.clone(),
|
TyKind::Raw(_, inner) | TyKind::Ref(_, _, inner) => inner.clone(),
|
||||||
TyKind::Adt(adt, subst) if is_box(db, adt.0) => {
|
TyKind::Adt(adt, subst) if is_box(db, adt.0) => {
|
||||||
subst.at(Interner, 0).assert_ty_ref(Interner).clone()
|
subst.at(Interner, 0).assert_ty_ref(Interner).clone()
|
||||||
|
@ -161,7 +161,7 @@ impl<V, T> ProjectionElem<V, T> {
|
||||||
return TyKind::Error.intern(Interner);
|
return TyKind::Error.intern(Interner);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ProjectionElem::Field(f) => match &base.data(Interner).kind {
|
ProjectionElem::Field(f) => match &base.kind(Interner) {
|
||||||
TyKind::Adt(_, subst) => {
|
TyKind::Adt(_, subst) => {
|
||||||
db.field_types(f.parent)[f.local_id].clone().substitute(Interner, subst)
|
db.field_types(f.parent)[f.local_id].clone().substitute(Interner, subst)
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ impl<V, T> ProjectionElem<V, T> {
|
||||||
return TyKind::Error.intern(Interner);
|
return TyKind::Error.intern(Interner);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ProjectionElem::TupleOrClosureField(f) => match &base.data(Interner).kind {
|
ProjectionElem::TupleOrClosureField(f) => match &base.kind(Interner) {
|
||||||
TyKind::Tuple(_, subst) => subst
|
TyKind::Tuple(_, subst) => subst
|
||||||
.as_slice(Interner)
|
.as_slice(Interner)
|
||||||
.get(*f)
|
.get(*f)
|
||||||
|
@ -187,7 +187,7 @@ impl<V, T> ProjectionElem<V, T> {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ProjectionElem::ConstantIndex { .. } | ProjectionElem::Index(_) => {
|
ProjectionElem::ConstantIndex { .. } | ProjectionElem::Index(_) => {
|
||||||
match &base.data(Interner).kind {
|
match &base.kind(Interner) {
|
||||||
TyKind::Array(inner, _) | TyKind::Slice(inner) => inner.clone(),
|
TyKind::Array(inner, _) | TyKind::Slice(inner) => inner.clone(),
|
||||||
_ => {
|
_ => {
|
||||||
never!("Overloaded index is not a projection");
|
never!("Overloaded index is not a projection");
|
||||||
|
@ -195,7 +195,7 @@ impl<V, T> ProjectionElem<V, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&ProjectionElem::Subslice { from, to } => match &base.data(Interner).kind {
|
&ProjectionElem::Subslice { from, to } => match &base.kind(Interner) {
|
||||||
TyKind::Array(inner, c) => {
|
TyKind::Array(inner, c) => {
|
||||||
let next_c = usize_const(
|
let next_c = usize_const(
|
||||||
db,
|
db,
|
||||||
|
|
|
@ -634,7 +634,7 @@ impl Evaluator<'_> {
|
||||||
addr = addr.offset(ty_size * offset);
|
addr = addr.offset(ty_size * offset);
|
||||||
}
|
}
|
||||||
&ProjectionElem::Subslice { from, to } => {
|
&ProjectionElem::Subslice { from, to } => {
|
||||||
let inner_ty = match &ty.data(Interner).kind {
|
let inner_ty = match &ty.kind(Interner) {
|
||||||
TyKind::Array(inner, _) | TyKind::Slice(inner) => inner.clone(),
|
TyKind::Array(inner, _) | TyKind::Slice(inner) => inner.clone(),
|
||||||
_ => TyKind::Error.intern(Interner),
|
_ => TyKind::Error.intern(Interner),
|
||||||
};
|
};
|
||||||
|
@ -793,7 +793,7 @@ impl Evaluator<'_> {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|it| self.operand_ty_and_eval(it, &mut locals))
|
.map(|it| self.operand_ty_and_eval(it, &mut locals))
|
||||||
.collect::<Result<Vec<_>>>()?;
|
.collect::<Result<Vec<_>>>()?;
|
||||||
let stack_frame = match &fn_ty.data(Interner).kind {
|
let stack_frame = match &fn_ty.kind(Interner) {
|
||||||
TyKind::Function(_) => {
|
TyKind::Function(_) => {
|
||||||
let bytes = self.eval_operand(func, &mut locals)?;
|
let bytes = self.eval_operand(func, &mut locals)?;
|
||||||
self.exec_fn_pointer(
|
self.exec_fn_pointer(
|
||||||
|
@ -1255,7 +1255,7 @@ impl Evaluator<'_> {
|
||||||
PointerCast::ReifyFnPointer | PointerCast::ClosureFnPointer(_) => {
|
PointerCast::ReifyFnPointer | PointerCast::ClosureFnPointer(_) => {
|
||||||
let current_ty = self.operand_ty(operand, locals)?;
|
let current_ty = self.operand_ty(operand, locals)?;
|
||||||
if let TyKind::FnDef(_, _) | TyKind::Closure(_, _) =
|
if let TyKind::FnDef(_, _) | TyKind::Closure(_, _) =
|
||||||
¤t_ty.data(Interner).kind
|
¤t_ty.kind(Interner)
|
||||||
{
|
{
|
||||||
let id = self.vtable_map.id(current_ty);
|
let id = self.vtable_map.id(current_ty);
|
||||||
let ptr_size = self.ptr_size();
|
let ptr_size = self.ptr_size();
|
||||||
|
@ -1408,8 +1408,8 @@ impl Evaluator<'_> {
|
||||||
addr: Interval,
|
addr: Interval,
|
||||||
) -> Result<IntervalOrOwned> {
|
) -> Result<IntervalOrOwned> {
|
||||||
use IntervalOrOwned::*;
|
use IntervalOrOwned::*;
|
||||||
Ok(match &target_ty.data(Interner).kind {
|
Ok(match &target_ty.kind(Interner) {
|
||||||
TyKind::Slice(_) => match ¤t_ty.data(Interner).kind {
|
TyKind::Slice(_) => match ¤t_ty.kind(Interner) {
|
||||||
TyKind::Array(_, size) => {
|
TyKind::Array(_, size) => {
|
||||||
let len = match try_const_usize(self.db, size) {
|
let len = match try_const_usize(self.db, size) {
|
||||||
None => {
|
None => {
|
||||||
|
@ -1435,7 +1435,7 @@ impl Evaluator<'_> {
|
||||||
r.extend(vtable.to_le_bytes().into_iter());
|
r.extend(vtable.to_le_bytes().into_iter());
|
||||||
Owned(r)
|
Owned(r)
|
||||||
}
|
}
|
||||||
TyKind::Adt(id, target_subst) => match ¤t_ty.data(Interner).kind {
|
TyKind::Adt(id, target_subst) => match ¤t_ty.kind(Interner) {
|
||||||
TyKind::Adt(current_id, current_subst) => {
|
TyKind::Adt(current_id, current_subst) => {
|
||||||
if id != current_id {
|
if id != current_id {
|
||||||
not_supported!("unsizing struct with different type");
|
not_supported!("unsizing struct with different type");
|
||||||
|
@ -1931,7 +1931,7 @@ impl Evaluator<'_> {
|
||||||
) -> Result<Option<StackFrame>> {
|
) -> Result<Option<StackFrame>> {
|
||||||
let id = from_bytes!(usize, bytes.get(self)?);
|
let id = from_bytes!(usize, bytes.get(self)?);
|
||||||
let next_ty = self.vtable_map.ty(id)?.clone();
|
let next_ty = self.vtable_map.ty(id)?.clone();
|
||||||
match &next_ty.data(Interner).kind {
|
match &next_ty.kind(Interner) {
|
||||||
TyKind::FnDef(def, generic_args) => {
|
TyKind::FnDef(def, generic_args) => {
|
||||||
self.exec_fn_def(*def, generic_args, destination, args, &locals, target_bb, span)
|
self.exec_fn_def(*def, generic_args, destination, args, &locals, target_bb, span)
|
||||||
}
|
}
|
||||||
|
@ -2182,7 +2182,7 @@ impl Evaluator<'_> {
|
||||||
let size = self.size_of_sized(&func_ty, locals, "self type of fn trait")?;
|
let size = self.size_of_sized(&func_ty, locals, "self type of fn trait")?;
|
||||||
func_data = Interval { addr: Address::from_bytes(func_data.get(self)?)?, size };
|
func_data = Interval { addr: Address::from_bytes(func_data.get(self)?)?, size };
|
||||||
}
|
}
|
||||||
match &func_ty.data(Interner).kind {
|
match &func_ty.kind(Interner) {
|
||||||
TyKind::FnDef(def, subst) => {
|
TyKind::FnDef(def, subst) => {
|
||||||
return self.exec_fn_def(
|
return self.exec_fn_def(
|
||||||
*def,
|
*def,
|
||||||
|
|
|
@ -633,7 +633,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let callee_ty = self.expr_ty_after_adjustments(*callee);
|
let callee_ty = self.expr_ty_after_adjustments(*callee);
|
||||||
match &callee_ty.data(Interner).kind {
|
match &callee_ty.kind(Interner) {
|
||||||
chalk_ir::TyKind::FnDef(..) => {
|
chalk_ir::TyKind::FnDef(..) => {
|
||||||
let func = Operand::from_bytes(vec![], callee_ty.clone());
|
let func = Operand::from_bytes(vec![], callee_ty.clone());
|
||||||
self.lower_call_and_args(
|
self.lower_call_and_args(
|
||||||
|
@ -1229,7 +1229,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
|
||||||
}
|
}
|
||||||
Expr::Array(l) => match l {
|
Expr::Array(l) => match l {
|
||||||
Array::ElementList { elements, .. } => {
|
Array::ElementList { elements, .. } => {
|
||||||
let elem_ty = match &self.expr_ty_without_adjust(expr_id).data(Interner).kind {
|
let elem_ty = match &self.expr_ty_without_adjust(expr_id).kind(Interner) {
|
||||||
TyKind::Array(ty, _) => ty.clone(),
|
TyKind::Array(ty, _) => ty.clone(),
|
||||||
_ => {
|
_ => {
|
||||||
return Err(MirLowerError::TypeError(
|
return Err(MirLowerError::TypeError(
|
||||||
|
@ -1260,7 +1260,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
|
||||||
else {
|
else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
let len = match &self.expr_ty_without_adjust(expr_id).data(Interner).kind {
|
let len = match &self.expr_ty_without_adjust(expr_id).kind(Interner) {
|
||||||
TyKind::Array(_, len) => len.clone(),
|
TyKind::Array(_, len) => len.clone(),
|
||||||
_ => {
|
_ => {
|
||||||
return Err(MirLowerError::TypeError(
|
return Err(MirLowerError::TypeError(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue