Rename adjustment::PointerCast
and variants using it to PointerCoercion
It makes it sound like the `ExprKind` and `Rvalue` are supposed to represent all pointer related casts, when in reality their just used to share a some enum variants. Make it clear there these are only coercion to make it clear why only some pointer related "casts" are in the enum.
This commit is contained in:
parent
fd68a6ded9
commit
2beabbbf6f
85 changed files with 214 additions and 185 deletions
|
@ -535,7 +535,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
| ExprKind::Cast { .. }
|
||||
| ExprKind::Use { .. }
|
||||
| ExprKind::NeverToAny { .. }
|
||||
| ExprKind::Pointer { .. }
|
||||
| ExprKind::PointerCoercion { .. }
|
||||
| ExprKind::Repeat { .. }
|
||||
| ExprKind::Borrow { .. }
|
||||
| ExprKind::AddressOf { .. }
|
||||
|
|
|
@ -300,7 +300,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
let cast_kind = mir_cast_kind(ty, expr.ty);
|
||||
block.and(Rvalue::Cast(cast_kind, source, expr.ty))
|
||||
}
|
||||
ExprKind::Pointer { cast, source } => {
|
||||
ExprKind::PointerCoercion { cast, source } => {
|
||||
let source = unpack!(
|
||||
block = this.as_operand(
|
||||
block,
|
||||
|
@ -310,7 +310,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
NeedsTemporary::No
|
||||
)
|
||||
);
|
||||
block.and(Rvalue::Cast(CastKind::Pointer(cast), source, expr.ty))
|
||||
block.and(Rvalue::Cast(CastKind::PointerCoercion(cast), source, expr.ty))
|
||||
}
|
||||
ExprKind::Array { ref fields } => {
|
||||
// (*) We would (maybe) be closer to codegen if we
|
||||
|
|
|
@ -63,7 +63,7 @@ impl Category {
|
|||
| ExprKind::Binary { .. }
|
||||
| ExprKind::Box { .. }
|
||||
| ExprKind::Cast { .. }
|
||||
| ExprKind::Pointer { .. }
|
||||
| ExprKind::PointerCoercion { .. }
|
||||
| ExprKind::Repeat { .. }
|
||||
| ExprKind::Assign { .. }
|
||||
| ExprKind::AssignOp { .. }
|
||||
|
|
|
@ -556,7 +556,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
| ExprKind::Binary { .. }
|
||||
| ExprKind::Box { .. }
|
||||
| ExprKind::Cast { .. }
|
||||
| ExprKind::Pointer { .. }
|
||||
| ExprKind::PointerCoercion { .. }
|
||||
| ExprKind::Repeat { .. }
|
||||
| ExprKind::Array { .. }
|
||||
| ExprKind::Tuple { .. }
|
||||
|
|
|
@ -16,7 +16,7 @@ use rustc_middle::mir::*;
|
|||
use rustc_middle::thir::*;
|
||||
use rustc_middle::ty::util::IntTypeExt;
|
||||
use rustc_middle::ty::GenericArg;
|
||||
use rustc_middle::ty::{self, adjustment::PointerCast, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{self, adjustment::PointerCoercion, Ty, TyCtxt};
|
||||
use rustc_span::def_id::DefId;
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_span::Span;
|
||||
|
@ -423,7 +423,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
source_info,
|
||||
temp,
|
||||
Rvalue::Cast(
|
||||
CastKind::Pointer(PointerCast::Unsize),
|
||||
CastKind::PointerCoercion(PointerCoercion::Unsize),
|
||||
Operand::Copy(val),
|
||||
ty,
|
||||
),
|
||||
|
@ -436,7 +436,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
block,
|
||||
source_info,
|
||||
slice,
|
||||
Rvalue::Cast(CastKind::Pointer(PointerCast::Unsize), expect, ty),
|
||||
Rvalue::Cast(
|
||||
CastKind::PointerCoercion(PointerCoercion::Unsize),
|
||||
expect,
|
||||
ty,
|
||||
),
|
||||
);
|
||||
expect = Operand::Move(slice);
|
||||
}
|
||||
|
|
|
@ -303,7 +303,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
|
|||
| ExprKind::NeverToAny { .. }
|
||||
| ExprKind::PlaceTypeAscription { .. }
|
||||
| ExprKind::ValueTypeAscription { .. }
|
||||
| ExprKind::Pointer { .. }
|
||||
| ExprKind::PointerCoercion { .. }
|
||||
| ExprKind::Repeat { .. }
|
||||
| ExprKind::StaticRef { .. }
|
||||
| ExprKind::ThreadLocalRef { .. }
|
||||
|
|
|
@ -13,7 +13,7 @@ use rustc_middle::middle::region;
|
|||
use rustc_middle::mir::{self, BinOp, BorrowKind, UnOp};
|
||||
use rustc_middle::thir::*;
|
||||
use rustc_middle::ty::adjustment::{
|
||||
Adjust, Adjustment, AutoBorrow, AutoBorrowMutability, PointerCast,
|
||||
Adjust, Adjustment, AutoBorrow, AutoBorrowMutability, PointerCoercion,
|
||||
};
|
||||
use rustc_middle::ty::subst::InternalSubsts;
|
||||
use rustc_middle::ty::{
|
||||
|
@ -125,11 +125,16 @@ impl<'tcx> Cx<'tcx> {
|
|||
};
|
||||
|
||||
let kind = match adjustment.kind {
|
||||
Adjust::Pointer(PointerCast::Unsize) => {
|
||||
Adjust::Pointer(PointerCoercion::Unsize) => {
|
||||
adjust_span(&mut expr);
|
||||
ExprKind::Pointer { cast: PointerCast::Unsize, source: self.thir.exprs.push(expr) }
|
||||
ExprKind::PointerCoercion {
|
||||
cast: PointerCoercion::Unsize,
|
||||
source: self.thir.exprs.push(expr),
|
||||
}
|
||||
}
|
||||
Adjust::Pointer(cast) => {
|
||||
ExprKind::PointerCoercion { cast, source: self.thir.exprs.push(expr) }
|
||||
}
|
||||
Adjust::Pointer(cast) => ExprKind::Pointer { cast, source: self.thir.exprs.push(expr) },
|
||||
Adjust::NeverToAny if adjustment.target.is_never() => return expr,
|
||||
Adjust::NeverToAny => ExprKind::NeverToAny { source: self.thir.exprs.push(expr) },
|
||||
Adjust::Deref(None) => {
|
||||
|
@ -192,9 +197,9 @@ impl<'tcx> Cx<'tcx> {
|
|||
// Special cased so that we can type check that the element
|
||||
// type of the source matches the pointed to type of the
|
||||
// destination.
|
||||
ExprKind::Pointer {
|
||||
ExprKind::PointerCoercion {
|
||||
source: self.mirror_expr(source),
|
||||
cast: PointerCast::ArrayToPointer,
|
||||
cast: PointerCoercion::ArrayToPointer,
|
||||
}
|
||||
} else {
|
||||
// check whether this is casting an enum variant discriminant
|
||||
|
|
|
@ -301,7 +301,7 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
|
|||
self.print_expr(*source, depth_lvl + 2);
|
||||
print_indented!(self, "}", depth_lvl);
|
||||
}
|
||||
Pointer { cast, source } => {
|
||||
PointerCoercion { cast, source } => {
|
||||
print_indented!(self, "Pointer {", depth_lvl);
|
||||
print_indented!(self, format!("cast: {:?}", cast), depth_lvl + 1);
|
||||
print_indented!(self, "source:", depth_lvl + 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue