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

+1-1
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

+1-1
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

+6-10
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

+2-2
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

+2-4
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

+2-7
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

+1-1
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

+4-4
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

+2-2
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

+1-1
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$<"),

compiler/rustc_const_eval/src/const_eval/valtrees.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ fn const_to_valtree_inner<'tcx>(
9898
Ok(ty::ValTree::Leaf(val.assert_int()))
9999
}
100100

101-
ty::RawPtr(_) => {
101+
ty::RawPtr(_, _) => {
102102
// Not all raw pointers are allowed, as we cannot properly test them for
103103
// equality at compile-time (see `ptr_guaranteed_cmp`).
104104
// However we allow those that are just integers in disguise.
@@ -278,7 +278,7 @@ pub fn valtree_to_const_value<'tcx>(
278278
assert!(valtree.unwrap_branch().is_empty());
279279
mir::ConstValue::ZeroSized
280280
}
281-
ty::Bool | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Char | ty::RawPtr(_) => {
281+
ty::Bool | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Char | ty::RawPtr(_, _) => {
282282
match valtree {
283283
ty::ValTree::Leaf(scalar_int) => mir::ConstValue::Scalar(Scalar::Int(scalar_int)),
284284
ty::ValTree::Branch(_) => bug!(

compiler/rustc_const_eval/src/interpret/cast.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
230230
src: &ImmTy<'tcx, M::Provenance>,
231231
cast_to: TyAndLayout<'tcx>,
232232
) -> InterpResult<'tcx, ImmTy<'tcx, M::Provenance>> {
233-
assert_matches!(src.layout.ty.kind(), ty::RawPtr(_) | ty::FnPtr(_));
233+
assert_matches!(src.layout.ty.kind(), ty::RawPtr(_, _) | ty::FnPtr(_));
234234
assert!(cast_to.ty.is_integral());
235235

236236
let scalar = src.to_scalar();
@@ -248,7 +248,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
248248
cast_to: TyAndLayout<'tcx>,
249249
) -> InterpResult<'tcx, ImmTy<'tcx, M::Provenance>> {
250250
assert!(src.layout.ty.is_integral());
251-
assert_matches!(cast_to.ty.kind(), ty::RawPtr(_));
251+
assert_matches!(cast_to.ty.kind(), ty::RawPtr(_, _));
252252

253253
// First cast to usize.
254254
let scalar = src.to_scalar();
@@ -435,10 +435,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
435435
) -> InterpResult<'tcx> {
436436
trace!("Unsizing {:?} of type {} into {}", *src, src.layout.ty, cast_ty.ty);
437437
match (&src.layout.ty.kind(), &cast_ty.ty.kind()) {
438-
(&ty::Ref(_, s, _), &ty::Ref(_, c, _) | &ty::RawPtr(TypeAndMut { ty: c, .. }))
439-
| (&ty::RawPtr(TypeAndMut { ty: s, .. }), &ty::RawPtr(TypeAndMut { ty: c, .. })) => {
440-
self.unsize_into_ptr(src, dest, *s, *c)
441-
}
438+
(&ty::Ref(_, s, _), &ty::Ref(_, c, _) | &ty::RawPtr(c, _))
439+
| (&ty::RawPtr(s, _), &ty::RawPtr(c, _)) => self.unsize_into_ptr(src, dest, *s, *c),
442440
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => {
443441
assert_eq!(def_a, def_b); // implies same number of fields
444442

compiler/rustc_const_eval/src/interpret/intrinsics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub(crate) fn eval_nullary_intrinsic<'tcx>(
7979
| ty::Str
8080
| ty::Array(_, _)
8181
| ty::Slice(_)
82-
| ty::RawPtr(_)
82+
| ty::RawPtr(_, _)
8383
| ty::Ref(_, _, _)
8484
| ty::FnDef(_, _)
8585
| ty::FnPtr(_)

compiler/rustc_const_eval/src/util/type_name.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
3333
| ty::Str
3434
| ty::Array(_, _)
3535
| ty::Slice(_)
36-
| ty::RawPtr(_)
36+
| ty::RawPtr(_, _)
3737
| ty::Ref(_, _, _)
3838
| ty::FnPtr(_)
3939
| ty::Never

compiler/rustc_hir_analysis/src/check/check.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ fn is_enum_of_nonnullable_ptr<'tcx>(
499499
fn check_static_linkage(tcx: TyCtxt<'_>, def_id: LocalDefId) {
500500
if tcx.codegen_fn_attrs(def_id).import_linkage.is_some() {
501501
if match tcx.type_of(def_id).instantiate_identity().kind() {
502-
ty::RawPtr(_) => false,
502+
ty::RawPtr(_, _) => false,
503503
ty::Adt(adt_def, args) => !is_enum_of_nonnullable_ptr(tcx, *adt_def, *args),
504504
_ => true,
505505
} {
@@ -934,10 +934,10 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
934934
// No: char, "fat" pointers, compound types
935935
match e.kind() {
936936
ty::Param(_) => (), // pass struct<T>(T, T, T, T) through, let monomorphization catch errors
937-
ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::RawPtr(_) => (), // struct(u8, u8, u8, u8) is ok
937+
ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::RawPtr(_, _) => (), // struct(u8, u8, u8, u8) is ok
938938
ty::Array(t, _) if matches!(t.kind(), ty::Param(_)) => (), // pass struct<T>([T; N]) through, let monomorphization catch errors
939939
ty::Array(t, _clen)
940-
if matches!(t.kind(), ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::RawPtr(_)) =>
940+
if matches!(t.kind(), ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::RawPtr(_, _)) =>
941941
{ /* struct([f32; 4]) is ok */ }
942942
_ => {
943943
struct_span_code_err!(

compiler/rustc_hir_analysis/src/check/intrinsicck.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
6262
ty::Float(FloatTy::F32) => Some(InlineAsmType::F32),
6363
ty::Float(FloatTy::F64) => Some(InlineAsmType::F64),
6464
ty::FnPtr(_) => Some(asm_ty_isize),
65-
ty::RawPtr(ty::TypeAndMut { ty, mutbl: _ }) if self.is_thin_ptr_ty(ty) => {
66-
Some(asm_ty_isize)
67-
}
65+
ty::RawPtr(ty, _) if self.is_thin_ptr_ty(ty) => Some(asm_ty_isize),
6866
ty::Adt(adt, args) if adt.repr().simd() => {
6967
let fields = &adt.non_enum_variant().fields;
7068
let elem_ty = fields[FieldIdx::from_u32(0)].ty(self.tcx, args);

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(),
954954
hir_ty.span,
955955
"using function pointers as const generic parameters is forbidden",
956956
),
957-
ty::RawPtr(_) => tcx.dcx().struct_span_err(
957+
ty::RawPtr(_, _) => tcx.dcx().struct_span_err(
958958
hir_ty.span,
959959
"using raw pointers as const generic parameters is forbidden",
960960
),

compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl<'tcx> InherentCollect<'tcx> {
162162
| ty::Str
163163
| ty::Array(..)
164164
| ty::Slice(_)
165-
| ty::RawPtr(_)
165+
| ty::RawPtr(_, _)
166166
| ty::Ref(..)
167167
| ty::Never
168168
| ty::FnPtr(_)

compiler/rustc_hir_typeck/src/cast.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
128128
| ty::Float(_)
129129
| ty::Array(..)
130130
| ty::CoroutineWitness(..)
131-
| ty::RawPtr(_)
131+
| ty::RawPtr(_, _)
132132
| ty::Ref(..)
133133
| ty::FnDef(..)
134134
| ty::FnPtr(..)
@@ -332,7 +332,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
332332
let mut sugg = None;
333333
let mut sugg_mutref = false;
334334
if let ty::Ref(reg, cast_ty, mutbl) = *self.cast_ty.kind() {
335-
if let ty::RawPtr(TypeAndMut { ty: expr_ty, .. }) = *self.expr_ty.kind()
335+
if let ty::RawPtr(expr_ty, _) = *self.expr_ty.kind()
336336
&& fcx.can_coerce(
337337
Ty::new_ref(fcx.tcx, fcx.tcx.lifetimes.re_erased, expr_ty, mutbl),
338338
self.cast_ty,
@@ -356,7 +356,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
356356
{
357357
sugg = Some((format!("&{}", mutbl.prefix_str()), false));
358358
}
359-
} else if let ty::RawPtr(TypeAndMut { mutbl, .. }) = *self.cast_ty.kind()
359+
} else if let ty::RawPtr(mutbl, _) = *self.cast_ty.kind()
360360
&& fcx.can_coerce(
361361
Ty::new_ref(fcx.tcx, fcx.tcx.lifetimes.re_erased, self.expr_ty, mutbl),
362362
self.cast_ty,

compiler/rustc_hir_typeck/src/coercion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
560560
},
561561
))
562562
}
563-
(&ty::Ref(_, ty_a, mt_a), &ty::RawPtr(ty::TypeAndMut { mutbl: mt_b, .. })) => {
563+
(&ty::Ref(_, ty_a, mt_a), &ty::RawPtr(_, mt_b)) => {
564564
coerce_mutbls(mt_a, mt_b)?;
565565

566566
Some((

compiler/rustc_hir_typeck/src/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
426426
) -> Ty<'tcx> {
427427
let hint = expected.only_has_type(self).map_or(NoExpectation, |ty| {
428428
match ty.kind() {
429-
ty::Ref(_, ty, _) | ty::RawPtr(ty::TypeAndMut { ty, .. }) => {
429+
ty::Ref(_, ty, _) | ty::RawPtr(ty, _) => {
430430
if oprnd.is_syntactic_place_expr() {
431431
// Places may legitimately have unsized types.
432432
// For example, dereferences of a fat pointer and

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14791479
expected_ty: Ty<'tcx>,
14801480
) -> bool {
14811481
// Expected type needs to be a raw pointer.
1482-
let ty::RawPtr(ty::TypeAndMut { mutbl, .. }) = expected_ty.kind() else {
1482+
let ty::RawPtr(mutbl, _) = expected_ty.kind() else {
14831483
return false;
14841484
};
14851485

@@ -2509,11 +2509,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
25092509
return make_sugg(sp, expr.span.lo());
25102510
}
25112511
}
2512-
(
2513-
_,
2514-
&ty::RawPtr(TypeAndMut { ty: ty_b, mutbl: mutbl_b }),
2515-
&ty::Ref(_, ty_a, mutbl_a),
2516-
) => {
2512+
(_, &ty::RawPtr(ty_b, mutbl_b), &ty::Ref(_, ty_a, mutbl_a)) => {
25172513
if let Some(steps) = self.deref_steps(ty_a, ty_b)
25182514
// Only suggest valid if dereferencing needed.
25192515
&& steps > 0

compiler/rustc_hir_typeck/src/method/confirm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
217217
}
218218
Some(probe::AutorefOrPtrAdjustment::ToConstPtr) => {
219219
target = match target.kind() {
220-
&ty::RawPtr(ty::TypeAndMut { ty, mutbl }) => {
220+
&ty::RawPtr(ty, mutbl) => {
221221
assert!(mutbl.is_mut());
222222
Ty::new_imm_ptr(self.tcx, ty)
223223
}

compiler/rustc_hir_typeck/src/method/probe.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ fn method_autoderef_steps<'tcx>(
528528
from_unsafe_deref: reached_raw_pointer,
529529
unsize: false,
530530
};
531-
if let ty::RawPtr(_) = ty.kind() {
531+
if let ty::RawPtr(_, _) = ty.kind() {
532532
// all the subsequent steps will be from_unsafe_deref
533533
reached_raw_pointer = true;
534534
}
@@ -696,7 +696,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
696696
| ty::Str
697697
| ty::Array(..)
698698
| ty::Slice(_)
699-
| ty::RawPtr(_)
699+
| ty::RawPtr(_, _)
700700
| ty::Ref(..)
701701
| ty::Never
702702
| ty::Tuple(..) => self.assemble_inherent_candidates_for_incoherent_ty(raw_self_ty),

compiler/rustc_hir_typeck/src/method/suggest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
530530
Applicability::MachineApplicable,
531531
);
532532
}
533-
if let ty::RawPtr(_) = &rcvr_ty.kind() {
533+
if let ty::RawPtr(_, _) = &rcvr_ty.kind() {
534534
err.note(
535535
"try using `<*const T>::as_ref()` to get a reference to the \
536536
type behind the pointer: https://doc.rust-lang.org/std/\

compiler/rustc_hir_typeck/src/upvar.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17191719
for pointer_ty in place.deref_tys() {
17201720
match pointer_ty.kind() {
17211721
// We don't capture derefs of raw ptrs
1722-
ty::RawPtr(_) => unreachable!(),
1722+
ty::RawPtr(_, _) => unreachable!(),
17231723

17241724
// Dereferencing a mut-ref allows us to mut the Place if we don't deref
17251725
// an immut-ref after on top of this.

0 commit comments

Comments
 (0)