Rollup merge of #81131 - pierwill:edit-rustc_middle-cast, r=varkor
Edit rustc_middle::ty::cast docs Link to RFC 401 and add missing punctuation.
This commit is contained in:
commit
d3cc598a02
@ -22,15 +22,16 @@ pub enum CastTy<'tcx> {
|
|||||||
/// Various types that are represented as ints and handled mostly
|
/// Various types that are represented as ints and handled mostly
|
||||||
/// in the same way, merged for easier matching.
|
/// in the same way, merged for easier matching.
|
||||||
Int(IntTy),
|
Int(IntTy),
|
||||||
/// Floating-Point types
|
/// Floating-point types.
|
||||||
Float,
|
Float,
|
||||||
/// Function Pointers
|
/// Function pointers.
|
||||||
FnPtr,
|
FnPtr,
|
||||||
/// Raw pointers
|
/// Raw pointers.
|
||||||
Ptr(ty::TypeAndMut<'tcx>),
|
Ptr(ty::TypeAndMut<'tcx>),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cast Kind. See RFC 401 (or librustc_typeck/check/cast.rs)
|
/// Cast Kind. See [RFC 401](https://rust-lang.github.io/rfcs/0401-coercions.html)
|
||||||
|
/// (or librustc_typeck/check/cast.rs).
|
||||||
#[derive(Copy, Clone, Debug, TyEncodable, TyDecodable, HashStable)]
|
#[derive(Copy, Clone, Debug, TyEncodable, TyDecodable, HashStable)]
|
||||||
pub enum CastKind {
|
pub enum CastKind {
|
||||||
CoercionCast,
|
CoercionCast,
|
||||||
@ -48,7 +49,7 @@ pub enum CastKind {
|
|||||||
|
|
||||||
impl<'tcx> CastTy<'tcx> {
|
impl<'tcx> CastTy<'tcx> {
|
||||||
/// Returns `Some` for integral/pointer casts.
|
/// Returns `Some` for integral/pointer casts.
|
||||||
/// casts like unsizing casts will return `None`
|
/// Casts like unsizing casts will return `None`.
|
||||||
pub fn from_ty(t: Ty<'tcx>) -> Option<CastTy<'tcx>> {
|
pub fn from_ty(t: Ty<'tcx>) -> Option<CastTy<'tcx>> {
|
||||||
match *t.kind() {
|
match *t.kind() {
|
||||||
ty::Bool => Some(CastTy::Int(IntTy::Bool)),
|
ty::Bool => Some(CastTy::Int(IntTy::Bool)),
|
||||||
|
Loading…
Reference in New Issue
Block a user