diff options
| author | Michael Goulet <michael@errs.io> | 2024-03-21 17:11:06 -0400 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-03-22 11:13:29 -0400 |
| commit | ff0c31e6b9bc8e847c3b1b9d61793325edfacf47 (patch) | |
| tree | 366bdcf6c869a19f56b8b3c2d42bf8ac6a5cf3a1 /compiler/rustc_middle/src/ty | |
| parent | f0f224a37f117104358f4d807d71037256f5a646 (diff) | |
| download | rust-ff0c31e6b9bc8e847c3b1b9d61793325edfacf47.tar.gz rust-ff0c31e6b9bc8e847c3b1b9d61793325edfacf47.zip | |
Programmatically convert some of the pat ctors
Diffstat (limited to 'compiler/rustc_middle/src/ty')
| -rw-r--r-- | compiler/rustc_middle/src/ty/error.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/layout.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/print/pretty.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/relate.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/sty.rs | 12 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/util.rs | 12 |
6 files changed, 17 insertions, 20 deletions
diff --git a/compiler/rustc_middle/src/ty/error.rs b/compiler/rustc_middle/src/ty/error.rs index e15f0378846..fdd7bb9c31f 100644 --- a/compiler/rustc_middle/src/ty/error.rs +++ b/compiler/rustc_middle/src/ty/error.rs @@ -286,7 +286,7 @@ impl<'tcx> Ty<'tcx> { ty::Foreign(_) => "extern type".into(), ty::Array(..) => "array".into(), ty::Slice(_) => "slice".into(), - ty::RawPtr(_) => "raw pointer".into(), + ty::RawPtr(_, _) => "raw pointer".into(), ty::Ref(.., mutbl) => match mutbl { hir::Mutability::Mut => "mutable reference", _ => "reference", diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 595ef71cc32..c8ea2dbf4c9 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -328,7 +328,7 @@ impl<'tcx> SizeSkeleton<'tcx> { }; match *ty.kind() { - ty::Ref(_, pointee, _) | ty::RawPtr(ty::TypeAndMut { ty: pointee, .. }) => { + ty::Ref(_, pointee, _) | ty::RawPtr(pointee, _) => { let non_zero = !ty.is_unsafe_ptr(); let tail = tcx.struct_tail_erasing_lifetimes(pointee, param_env); match tail.kind() { @@ -742,7 +742,7 @@ where } // Potentially-fat pointers. - ty::Ref(_, pointee, _) | ty::RawPtr(ty::TypeAndMut { ty: pointee, .. }) => { + ty::Ref(_, pointee, _) | ty::RawPtr(pointee, _) => { assert!(i < this.fields.count()); // Reuse the fat `*T` type as its own thin pointer data field. diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 995b439d10a..9feba6b0018 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -1752,7 +1752,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { p!(write("{:?}", char::try_from(int).unwrap())) } // Pointer types - ty::Ref(..) | ty::RawPtr(_) | ty::FnPtr(_) => { + ty::Ref(..) | ty::RawPtr(_, _) | ty::FnPtr(_) => { let data = int.assert_bits(self.tcx().data_layout.pointer_size); self.typed_value( |this| { diff --git a/compiler/rustc_middle/src/ty/relate.rs b/compiler/rustc_middle/src/ty/relate.rs index a04a0d17d00..27c4a48052b 100644 --- a/compiler/rustc_middle/src/ty/relate.rs +++ b/compiler/rustc_middle/src/ty/relate.rs @@ -443,10 +443,7 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>( Ok(Ty::new_coroutine_closure(tcx, a_id, args)) } - ( - &ty::RawPtr(ty::TypeAndMut { ty: a_ty, mutbl: a_mutbl }), - &ty::RawPtr(ty::TypeAndMut { ty: b_ty, mutbl: b_mutbl }), - ) => { + (&ty::RawPtr(a_ty, a_mutbl), &ty::RawPtr(b_ty, b_mutbl)) => { if a_mutbl != b_mutbl { return Err(TypeError::Mutability); } diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 113e0c29c08..f53bce54075 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -1608,7 +1608,7 @@ impl<'tcx> Ty<'tcx> { #[inline] pub fn new_ptr(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, mutbl: ty::Mutability) -> Ty<'tcx> { - Ty::new(tcx, RawPtr(ty::TypeAndMut { ty, mutbl })) + Ty::new(tcx, ty::RawPtr(ty, mutbl)) } #[inline] @@ -1915,7 +1915,7 @@ impl<'tcx> Ty<'tcx> { pub fn is_array_slice(self) -> bool { match self.kind() { Slice(_) => true, - RawPtr(TypeAndMut { ty, .. }) | Ref(_, ty, _) => matches!(ty.kind(), Slice(_)), + ty::RawPtr(ty, _) | Ref(_, ty, _) => matches!(ty.kind(), Slice(_)), _ => false, } } @@ -1987,7 +1987,7 @@ impl<'tcx> Ty<'tcx> { #[inline] pub fn is_unsafe_ptr(self) -> bool { - matches!(self.kind(), RawPtr(_)) + matches!(self.kind(), RawPtr(_, _)) } /// Tests if this is any kind of primitive pointer type (reference, raw pointer, fn pointer). @@ -2043,7 +2043,7 @@ impl<'tcx> Ty<'tcx> { | Uint(_) | FnDef(..) | FnPtr(_) - | RawPtr(_) + | RawPtr(_, _) | Infer(IntVar(_) | FloatVar(_)) ) } @@ -2298,7 +2298,7 @@ impl<'tcx> Ty<'tcx> { | ty::Str | ty::Array(..) | ty::Slice(_) - | ty::RawPtr(_) + | ty::RawPtr(_, _) | ty::Ref(..) | ty::FnDef(..) | ty::FnPtr(..) @@ -2641,7 +2641,7 @@ impl<'tcx> Ty<'tcx> { | Str | Array(_, _) | Slice(_) - | RawPtr(_) + | RawPtr(_, _) | Ref(_, _, _) | FnDef(_, _) | FnPtr(_) diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index e1081423489..f74bba134ab 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -1237,7 +1237,7 @@ impl<'tcx> Ty<'tcx> { | ty::Str | ty::Never | ty::Ref(..) - | ty::RawPtr(_) + | ty::RawPtr(_, _) | ty::FnDef(..) | ty::Error(_) | ty::FnPtr(_) => true, @@ -1277,7 +1277,7 @@ impl<'tcx> Ty<'tcx> { | ty::Str | ty::Never | ty::Ref(..) - | ty::RawPtr(_) + | ty::RawPtr(_, _) | ty::FnDef(..) | ty::Error(_) | ty::FnPtr(_) => true, @@ -1401,7 +1401,7 @@ impl<'tcx> Ty<'tcx> { ty::Ref(..) | ty::Array(..) | ty::Slice(_) | ty::Tuple(..) => true, // Raw pointers use bitwise comparison. - ty::RawPtr(_) | ty::FnPtr(_) => true, + ty::RawPtr(_, _) | ty::FnPtr(_) => true, // Floating point numbers are not `Eq`. ty::Float(_) => false, @@ -1494,7 +1494,7 @@ impl<'tcx> ExplicitSelf<'tcx> { match *self_arg_ty.kind() { _ if is_self_ty(self_arg_ty) => ByValue, ty::Ref(region, ty, mutbl) if is_self_ty(ty) => ByReference(region, mutbl), - ty::RawPtr(ty::TypeAndMut { ty, mutbl }) if is_self_ty(ty) => ByRawPointer(mutbl), + ty::RawPtr(ty, mutbl) if is_self_ty(ty) => ByRawPointer(mutbl), ty::Adt(def, _) if def.is_box() && is_self_ty(self_arg_ty.boxed_ty()) => ByBox, _ => Other, } @@ -1519,7 +1519,7 @@ pub fn needs_drop_components<'tcx>( | ty::FnDef(..) | ty::FnPtr(_) | ty::Char - | ty::RawPtr(_) + | ty::RawPtr(_, _) | ty::Ref(..) | ty::Str => Ok(SmallVec::new()), @@ -1574,7 +1574,7 @@ pub fn is_trivially_const_drop(ty: Ty<'_>) -> bool { | ty::Infer(ty::IntVar(_)) | ty::Infer(ty::FloatVar(_)) | ty::Str - | ty::RawPtr(_) + | ty::RawPtr(_, _) | ty::Ref(..) | ty::FnDef(..) | ty::FnPtr(_) |
