Skip to content

Commit 9db7c3a

Browse files
Programmatically convert some of the pat ctors
1 parent 2fbd0ec commit 9db7c3a

File tree

77 files changed

+136
-168
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+136
-168
lines changed

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
366366
Some(variant.fields[field].name.to_string())
367367
}
368368
ty::Tuple(_) => Some(field.index().to_string()),
369-
ty::Ref(_, ty, _) | ty::RawPtr(ty::TypeAndMut { ty, .. }) => {
369+
ty::Ref(_, ty, _) | ty::RawPtr(ty, _) => {
370370
self.describe_field_from_ty(ty, field, variant_index, including_tuple_field)
371371
}
372372
ty::Array(ty, _) | ty::Slice(ty) => {

compiler/rustc_borrowck/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1649,7 +1649,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
16491649
| ty::Str
16501650
| ty::Array(_, _)
16511651
| ty::Slice(_)
1652-
| ty::RawPtr(_)
1652+
| ty::RawPtr(_, _)
16531653
| ty::Ref(_, _, _)
16541654
| ty::FnDef(_, _)
16551655
| ty::FnPtr(_)

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2190,12 +2190,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
21902190
let ty_from = op.ty(body, tcx);
21912191

21922192
let opt_ty_elem_mut = match ty_from.kind() {
2193-
ty::RawPtr(ty::TypeAndMut { mutbl: array_mut, ty: array_ty }) => {
2194-
match array_ty.kind() {
2195-
ty::Array(ty_elem, _) => Some((ty_elem, *array_mut)),
2196-
_ => None,
2197-
}
2198-
}
2193+
ty::RawPtr(array_ty, array_mut) => match array_ty.kind() {
2194+
ty::Array(ty_elem, _) => Some((ty_elem, *array_mut)),
2195+
_ => None,
2196+
},
21992197
_ => None,
22002198
};
22012199

@@ -2210,9 +2208,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
22102208
};
22112209

22122210
let (ty_to, ty_to_mut) = match ty.kind() {
2213-
ty::RawPtr(ty::TypeAndMut { mutbl: ty_to_mut, ty: ty_to }) => {
2214-
(ty_to, *ty_to_mut)
2215-
}
2211+
ty::RawPtr(ty_to, ty_to_mut) => (ty_to, *ty_to_mut),
22162212
_ => {
22172213
span_mirbug!(
22182214
self,
@@ -2413,7 +2409,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
24132409
let ty_left = left.ty(body, tcx);
24142410
match ty_left.kind() {
24152411
// Types with regions are comparable if they have a common super-type.
2416-
ty::RawPtr(_) | ty::FnPtr(_) => {
2412+
ty::RawPtr(_, _) | ty::FnPtr(_) => {
24172413
let ty_right = right.ty(body, tcx);
24182414
let common_ty = self.infcx.next_ty_var(TypeVariableOrigin {
24192415
kind: TypeVariableOriginKind::MiscVariable,

compiler/rustc_codegen_cranelift/src/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<types::Typ
6969
FloatTy::F128 => unimplemented!("f16_f128"),
7070
},
7171
ty::FnPtr(_) => pointer_ty(tcx),
72-
ty::RawPtr(TypeAndMut { ty: pointee_ty, mutbl: _ }) | ty::Ref(_, pointee_ty, _) => {
72+
ty::RawPtr(pointee_ty, _) | ty::Ref(_, pointee_ty, _) => {
7373
if has_ptr_meta(tcx, *pointee_ty) {
7474
return None;
7575
} else {
@@ -89,7 +89,7 @@ fn clif_pair_type_from_ty<'tcx>(
8989
ty::Tuple(types) if types.len() == 2 => {
9090
(clif_type_from_ty(tcx, types[0])?, clif_type_from_ty(tcx, types[1])?)
9191
}
92-
ty::RawPtr(TypeAndMut { ty: pointee_ty, mutbl: _ }) | ty::Ref(_, pointee_ty, _) => {
92+
ty::RawPtr(pointee_ty, _) | ty::Ref(_, pointee_ty, _) => {
9393
if has_ptr_meta(tcx, *pointee_ty) {
9494
(pointer_ty(tcx), pointer_ty(tcx))
9595
} else {

compiler/rustc_codegen_cranelift/src/unsize.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,8 @@ fn unsize_ptr<'tcx>(
7070
) -> (Value, Value) {
7171
match (&src_layout.ty.kind(), &dst_layout.ty.kind()) {
7272
(&ty::Ref(_, a, _), &ty::Ref(_, b, _))
73-
| (&ty::Ref(_, a, _), &ty::RawPtr(ty::TypeAndMut { ty: b, .. }))
74-
| (&ty::RawPtr(ty::TypeAndMut { ty: a, .. }), &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) => {
75-
(src, unsized_info(fx, *a, *b, old_info))
76-
}
73+
| (&ty::Ref(_, a, _), &ty::RawPtr(b, _))
74+
| (&ty::RawPtr(a, _), &ty::RawPtr(b, _)) => (src, unsized_info(fx, *a, *b, old_info)),
7775
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => {
7876
assert_eq!(def_a, def_b);
7977

compiler/rustc_codegen_cranelift/src/value_and_place.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -865,15 +865,10 @@ pub(crate) fn assert_assignable<'tcx>(
865865
return;
866866
}
867867
match (from_ty.kind(), to_ty.kind()) {
868-
(ty::Ref(_, a, _), ty::Ref(_, b, _))
869-
| (
870-
ty::RawPtr(TypeAndMut { ty: a, mutbl: _ }),
871-
ty::RawPtr(TypeAndMut { ty: b, mutbl: _ }),
872-
) => {
868+
(ty::Ref(_, a, _), ty::Ref(_, b, _)) | (ty::RawPtr(a, _), ty::RawPtr(b, _)) => {
873869
assert_assignable(fx, *a, *b, limit - 1);
874870
}
875-
(ty::Ref(_, a, _), ty::RawPtr(TypeAndMut { ty: b, mutbl: _ }))
876-
| (ty::RawPtr(TypeAndMut { ty: a, mutbl: _ }), ty::Ref(_, b, _)) => {
871+
(ty::Ref(_, a, _), ty::RawPtr(b, _)) | (ty::RawPtr(a, _), ty::Ref(_, b, _)) => {
877872
assert_assignable(fx, *a, *b, limit - 1);
878873
}
879874
(ty::FnPtr(_), ty::FnPtr(_)) => {

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ pub fn type_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll D
452452
ty::Slice(_) | ty::Str => build_slice_type_di_node(cx, t, unique_type_id),
453453
ty::Dynamic(..) => build_dyn_type_di_node(cx, t, unique_type_id),
454454
ty::Foreign(..) => build_foreign_type_di_node(cx, t, unique_type_id),
455-
ty::RawPtr(ty::TypeAndMut { ty: pointee_type, .. }) | ty::Ref(_, pointee_type, _) => {
455+
ty::RawPtr(pointee_type, _) | ty::Ref(_, pointee_type, _) => {
456456
build_pointer_or_reference_di_node(cx, t, pointee_type, unique_type_id)
457457
}
458458
// Some `Box` are newtyped pointers, make debuginfo aware of that.

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
14831483
v.normalize(bx.target_spec().pointer_width).bit_width().unwrap()
14841484
),
14851485
ty::Float(v) => format!("v{}f{}", vec_len, v.bit_width()),
1486-
ty::RawPtr(_) => format!("v{}p0", vec_len),
1486+
ty::RawPtr(_, _) => format!("v{}p0", vec_len),
14871487
_ => unreachable!(),
14881488
}
14891489
}
@@ -1493,7 +1493,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
14931493
ty::Int(v) => cx.type_int_from_ty(v),
14941494
ty::Uint(v) => cx.type_uint_from_ty(v),
14951495
ty::Float(v) => cx.type_float_from_ty(v),
1496-
ty::RawPtr(_) => cx.type_ptr(),
1496+
ty::RawPtr(_, _) => cx.type_ptr(),
14971497
_ => unreachable!(),
14981498
};
14991499
cx.type_vector(elem_ty, vec_len)
@@ -2120,7 +2120,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
21202120
);
21212121

21222122
match in_elem.kind() {
2123-
ty::RawPtr(_) => {}
2123+
ty::RawPtr(_, _) => {}
21242124
_ => {
21252125
return_error!(InvalidMonomorphization::ExpectedPointer { span, name, ty: in_elem })
21262126
}
@@ -2152,7 +2152,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
21522152
_ => return_error!(InvalidMonomorphization::ExpectedUsize { span, name, ty: in_elem }),
21532153
}
21542154
match out_elem.kind() {
2155-
ty::RawPtr(_) => {}
2155+
ty::RawPtr(_, _) => {}
21562156
_ => {
21572157
return_error!(InvalidMonomorphization::ExpectedPointer { span, name, ty: out_elem })
21582158
}

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ pub fn unsize_ptr<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
193193
) -> (Bx::Value, Bx::Value) {
194194
debug!("unsize_ptr: {:?} => {:?}", src_ty, dst_ty);
195195
match (src_ty.kind(), dst_ty.kind()) {
196-
(&ty::Ref(_, a, _), &ty::Ref(_, b, _) | &ty::RawPtr(ty::TypeAndMut { ty: b, .. }))
197-
| (&ty::RawPtr(ty::TypeAndMut { ty: a, .. }), &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) => {
196+
(&ty::Ref(_, a, _), &ty::Ref(_, b, _) | &ty::RawPtr(b, _))
197+
| (&ty::RawPtr(a, _), &ty::RawPtr(b, _)) => {
198198
assert_eq!(bx.cx().type_is_sized(a), old_info.is_none());
199199
(src, unsized_info(bx, a, b, old_info))
200200
}

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ fn push_debuginfo_type_name<'tcx>(
138138
output.push(')');
139139
}
140140
}
141-
ty::RawPtr(ty::TypeAndMut { ty: inner_type, mutbl }) => {
141+
ty::RawPtr(inner_type, mutbl) => {
142142
if cpp_like_debuginfo {
143143
match mutbl {
144144
Mutability::Not => output.push_str("ptr_const$<"),

0 commit comments

Comments
 (0)