Skip to content

Commit 1cae701

Browse files
committed
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.
1 parent 40de0c2 commit 1cae701

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/base.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use rustc_ast::InlineAsmOptions;
44
use rustc_index::IndexVec;
5-
use rustc_middle::ty::adjustment::PointerCast;
5+
use rustc_middle::ty::adjustment::PointerCoercion;
66
use rustc_middle::ty::layout::FnAbiOf;
77
use rustc_middle::ty::print::with_no_trimmed_paths;
88

@@ -571,7 +571,7 @@ fn codegen_stmt<'tcx>(
571571
lval.write_cvalue(fx, res);
572572
}
573573
Rvalue::Cast(
574-
CastKind::Pointer(PointerCast::ReifyFnPointer),
574+
CastKind::PointerCoercion(PointerCoercion::ReifyFnPointer),
575575
ref operand,
576576
to_ty,
577577
) => {
@@ -596,17 +596,17 @@ fn codegen_stmt<'tcx>(
596596
}
597597
}
598598
Rvalue::Cast(
599-
CastKind::Pointer(PointerCast::UnsafeFnPointer),
599+
CastKind::PointerCoercion(PointerCoercion::UnsafeFnPointer),
600600
ref operand,
601601
to_ty,
602602
)
603603
| Rvalue::Cast(
604-
CastKind::Pointer(PointerCast::MutToConstPointer),
604+
CastKind::PointerCoercion(PointerCoercion::MutToConstPointer),
605605
ref operand,
606606
to_ty,
607607
)
608608
| Rvalue::Cast(
609-
CastKind::Pointer(PointerCast::ArrayToPointer),
609+
CastKind::PointerCoercion(PointerCoercion::ArrayToPointer),
610610
ref operand,
611611
to_ty,
612612
) => {
@@ -662,7 +662,7 @@ fn codegen_stmt<'tcx>(
662662
}
663663
}
664664
Rvalue::Cast(
665-
CastKind::Pointer(PointerCast::ClosureFnPointer(_)),
665+
CastKind::PointerCoercion(PointerCoercion::ClosureFnPointer(_)),
666666
ref operand,
667667
_to_ty,
668668
) => {
@@ -684,7 +684,11 @@ fn codegen_stmt<'tcx>(
684684
_ => bug!("{} cannot be cast to a fn ptr", operand.layout().ty),
685685
}
686686
}
687-
Rvalue::Cast(CastKind::Pointer(PointerCast::Unsize), ref operand, _to_ty) => {
687+
Rvalue::Cast(
688+
CastKind::PointerCoercion(PointerCoercion::Unsize),
689+
ref operand,
690+
_to_ty,
691+
) => {
688692
let operand = codegen_operand(fx, operand);
689693
crate::unsize::coerce_unsized_into(fx, operand, lval);
690694
}

src/unsize.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
//! Codegen of the [`PointerCast::Unsize`] operation.
1+
//! Codegen of the [`PointerCoercion::Unsize`] operation.
22
//!
3-
//! [`PointerCast::Unsize`]: `rustc_middle::ty::adjustment::PointerCast::Unsize`
3+
//! [`PointerCoercion::Unsize`]: `rustc_middle::ty::adjustment::PointerCoercion::Unsize`
44
55
use crate::prelude::*;
66

0 commit comments

Comments
 (0)