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
40de0c2765
commit
1cae70145c
18
src/base.rs
18
src/base.rs
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use rustc_ast::InlineAsmOptions;
|
use rustc_ast::InlineAsmOptions;
|
||||||
use rustc_index::IndexVec;
|
use rustc_index::IndexVec;
|
||||||
use rustc_middle::ty::adjustment::PointerCast;
|
use rustc_middle::ty::adjustment::PointerCoercion;
|
||||||
use rustc_middle::ty::layout::FnAbiOf;
|
use rustc_middle::ty::layout::FnAbiOf;
|
||||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||||
|
|
||||||
@ -571,7 +571,7 @@ fn codegen_stmt<'tcx>(
|
|||||||
lval.write_cvalue(fx, res);
|
lval.write_cvalue(fx, res);
|
||||||
}
|
}
|
||||||
Rvalue::Cast(
|
Rvalue::Cast(
|
||||||
CastKind::Pointer(PointerCast::ReifyFnPointer),
|
CastKind::PointerCoercion(PointerCoercion::ReifyFnPointer),
|
||||||
ref operand,
|
ref operand,
|
||||||
to_ty,
|
to_ty,
|
||||||
) => {
|
) => {
|
||||||
@ -596,17 +596,17 @@ fn codegen_stmt<'tcx>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Rvalue::Cast(
|
Rvalue::Cast(
|
||||||
CastKind::Pointer(PointerCast::UnsafeFnPointer),
|
CastKind::PointerCoercion(PointerCoercion::UnsafeFnPointer),
|
||||||
ref operand,
|
ref operand,
|
||||||
to_ty,
|
to_ty,
|
||||||
)
|
)
|
||||||
| Rvalue::Cast(
|
| Rvalue::Cast(
|
||||||
CastKind::Pointer(PointerCast::MutToConstPointer),
|
CastKind::PointerCoercion(PointerCoercion::MutToConstPointer),
|
||||||
ref operand,
|
ref operand,
|
||||||
to_ty,
|
to_ty,
|
||||||
)
|
)
|
||||||
| Rvalue::Cast(
|
| Rvalue::Cast(
|
||||||
CastKind::Pointer(PointerCast::ArrayToPointer),
|
CastKind::PointerCoercion(PointerCoercion::ArrayToPointer),
|
||||||
ref operand,
|
ref operand,
|
||||||
to_ty,
|
to_ty,
|
||||||
) => {
|
) => {
|
||||||
@ -662,7 +662,7 @@ fn is_fat_ptr<'tcx>(fx: &FunctionCx<'_, '_, 'tcx>, ty: Ty<'tcx>) -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Rvalue::Cast(
|
Rvalue::Cast(
|
||||||
CastKind::Pointer(PointerCast::ClosureFnPointer(_)),
|
CastKind::PointerCoercion(PointerCoercion::ClosureFnPointer(_)),
|
||||||
ref operand,
|
ref operand,
|
||||||
_to_ty,
|
_to_ty,
|
||||||
) => {
|
) => {
|
||||||
@ -684,7 +684,11 @@ fn is_fat_ptr<'tcx>(fx: &FunctionCx<'_, '_, 'tcx>, ty: Ty<'tcx>) -> bool {
|
|||||||
_ => bug!("{} cannot be cast to a fn ptr", operand.layout().ty),
|
_ => bug!("{} cannot be cast to a fn ptr", operand.layout().ty),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Rvalue::Cast(CastKind::Pointer(PointerCast::Unsize), ref operand, _to_ty) => {
|
Rvalue::Cast(
|
||||||
|
CastKind::PointerCoercion(PointerCoercion::Unsize),
|
||||||
|
ref operand,
|
||||||
|
_to_ty,
|
||||||
|
) => {
|
||||||
let operand = codegen_operand(fx, operand);
|
let operand = codegen_operand(fx, operand);
|
||||||
crate::unsize::coerce_unsized_into(fx, operand, lval);
|
crate::unsize::coerce_unsized_into(fx, operand, lval);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//! Codegen of the [`PointerCast::Unsize`] operation.
|
//! Codegen of the [`PointerCoercion::Unsize`] operation.
|
||||||
//!
|
//!
|
||||||
//! [`PointerCast::Unsize`]: `rustc_middle::ty::adjustment::PointerCast::Unsize`
|
//! [`PointerCoercion::Unsize`]: `rustc_middle::ty::adjustment::PointerCoercion::Unsize`
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user