Skip to content

Commit c6ba527

Browse files
Make RawPtr take Ty and Mutbl separately
1 parent 9db7c3a commit c6ba527

File tree

36 files changed

+106
-107
lines changed

36 files changed

+106
-107
lines changed

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -503,10 +503,10 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
503503
ty::VarianceDiagInfo::None => {}
504504
ty::VarianceDiagInfo::Invariant { ty, param_index } => {
505505
let (desc, note) = match ty.kind() {
506-
ty::RawPtr(ty_mut) => {
507-
assert_eq!(ty_mut.mutbl, rustc_hir::Mutability::Mut);
506+
ty::RawPtr(ty, mutbl) => {
507+
assert_eq!(*mutbl, rustc_hir::Mutability::Mut);
508508
(
509-
format!("a mutable pointer to `{}`", ty_mut.ty),
509+
format!("a mutable pointer to `{}`", ty),
510510
"mutable pointers are invariant over their type parameter".to_string(),
511511
)
512512
}

compiler/rustc_borrowck/src/diagnostics/region_name.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,8 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
555555
search_stack.push((*elem_ty, elem_hir_ty));
556556
}
557557

558-
(ty::RawPtr(mut_ty), hir::TyKind::Ptr(mut_hir_ty)) => {
559-
search_stack.push((mut_ty.ty, &mut_hir_ty.ty));
558+
(ty::RawPtr(mut_ty, _), hir::TyKind::Ptr(mut_hir_ty)) => {
559+
search_stack.push((*mut_ty, &mut_hir_ty.ty));
560560
}
561561

562562
_ => {

compiler/rustc_borrowck/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2284,8 +2284,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
22842284
}
22852285
}
22862286
}
2287-
ty::RawPtr(tnm) => {
2288-
match tnm.mutbl {
2287+
ty::RawPtr(_, mutbl) => {
2288+
match mutbl {
22892289
// `*const` raw pointers are not mutable
22902290
hir::Mutability::Not => Err(place),
22912291
// `*mut` raw pointers are always mutable, regardless of

compiler/rustc_borrowck/src/type_check/mod.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -2157,15 +2157,12 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
21572157
}
21582158

21592159
CastKind::PointerCoercion(PointerCoercion::MutToConstPointer) => {
2160-
let ty::RawPtr(ty::TypeAndMut { ty: ty_from, mutbl: hir::Mutability::Mut }) =
2161-
op.ty(body, tcx).kind()
2160+
let ty::RawPtr(ty_from, hir::Mutability::Mut) = op.ty(body, tcx).kind()
21622161
else {
21632162
span_mirbug!(self, rvalue, "unexpected base type for cast {:?}", ty,);
21642163
return;
21652164
};
2166-
let ty::RawPtr(ty::TypeAndMut { ty: ty_to, mutbl: hir::Mutability::Not }) =
2167-
ty.kind()
2168-
else {
2165+
let ty::RawPtr(ty_to, hir::Mutability::Not) = ty.kind() else {
21692166
span_mirbug!(self, rvalue, "unexpected target type for cast {:?}", ty,);
21702167
return;
21712168
};

compiler/rustc_codegen_gcc/src/intrinsic/simd.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -797,15 +797,15 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
797797
// This counts how many pointers
798798
fn ptr_count(t: Ty<'_>) -> usize {
799799
match t.kind() {
800-
ty::RawPtr(p) => 1 + ptr_count(p.ty),
800+
ty::RawPtr(p_ty, _) => 1 + ptr_count(p_ty),
801801
_ => 0,
802802
}
803803
}
804804

805805
// Non-ptr type
806806
fn non_ptr(t: Ty<'_>) -> Ty<'_> {
807807
match t.kind() {
808-
ty::RawPtr(p) => non_ptr(p.ty),
808+
ty::RawPtr(p_ty, _) => non_ptr(p_ty),
809809
_ => t,
810810
}
811811
}
@@ -815,7 +815,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
815815
let (_, element_ty0) = arg_tys[0].simd_size_and_type(bx.tcx());
816816
let (_, element_ty1) = arg_tys[1].simd_size_and_type(bx.tcx());
817817
let (pointer_count, underlying_ty) = match element_ty1.kind() {
818-
ty::RawPtr(p) if p.ty == in_elem => (ptr_count(element_ty1), non_ptr(element_ty1)),
818+
ty::RawPtr(p_ty, _) if p_ty == in_elem => (ptr_count(element_ty1), non_ptr(element_ty1)),
819819
_ => {
820820
require!(
821821
false,
@@ -911,15 +911,15 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
911911
// This counts how many pointers
912912
fn ptr_count(t: Ty<'_>) -> usize {
913913
match t.kind() {
914-
ty::RawPtr(p) => 1 + ptr_count(p.ty),
914+
ty::RawPtr(p_ty, _) => 1 + ptr_count(p_ty),
915915
_ => 0,
916916
}
917917
}
918918

919919
// Non-ptr type
920920
fn non_ptr(t: Ty<'_>) -> Ty<'_> {
921921
match t.kind() {
922-
ty::RawPtr(p) => non_ptr(p.ty),
922+
ty::RawPtr(p_ty, _) => non_ptr(p_ty),
923923
_ => t,
924924
}
925925
}
@@ -930,7 +930,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
930930
let (_, element_ty1) = arg_tys[1].simd_size_and_type(bx.tcx());
931931
let (_, element_ty2) = arg_tys[2].simd_size_and_type(bx.tcx());
932932
let (pointer_count, underlying_ty) = match element_ty1.kind() {
933-
ty::RawPtr(p) if p.ty == in_elem && p.mutbl == hir::Mutability::Mut => {
933+
ty::RawPtr(p_ty, _) if p_ty == in_elem && p.mutbl == hir::Mutability::Mut => {
934934
(ptr_count(element_ty1), non_ptr(element_ty1))
935935
}
936936
_ => {

compiler/rustc_codegen_llvm/src/intrinsic.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -1548,8 +1548,8 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
15481548

15491549
require!(
15501550
matches!(
1551-
element_ty1.kind(),
1552-
ty::RawPtr(p) if p.ty == in_elem && p.ty.kind() == element_ty0.kind()
1551+
*element_ty1.kind(),
1552+
ty::RawPtr(p_ty, _) if p_ty == in_elem && p_ty.kind() == element_ty0.kind()
15531553
),
15541554
InvalidMonomorphization::ExpectedElementType {
15551555
span,
@@ -1654,8 +1654,8 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
16541654

16551655
require!(
16561656
matches!(
1657-
pointer_ty.kind(),
1658-
ty::RawPtr(p) if p.ty == values_elem && p.ty.kind() == values_elem.kind()
1657+
*pointer_ty.kind(),
1658+
ty::RawPtr(p_ty, _) if p_ty == values_elem && p_ty.kind() == values_elem.kind()
16591659
),
16601660
InvalidMonomorphization::ExpectedElementType {
16611661
span,
@@ -1746,8 +1746,8 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
17461746
// The second argument must be a mutable pointer type matching the element type
17471747
require!(
17481748
matches!(
1749-
pointer_ty.kind(),
1750-
ty::RawPtr(p) if p.ty == values_elem && p.ty.kind() == values_elem.kind() && p.mutbl.is_mut()
1749+
*pointer_ty.kind(),
1750+
ty::RawPtr(p_ty, p_mutbl) if p_ty == values_elem && p_ty.kind() == values_elem.kind() && p_mutbl.is_mut()
17511751
),
17521752
InvalidMonomorphization::ExpectedElementType {
17531753
span,
@@ -1843,9 +1843,9 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
18431843

18441844
require!(
18451845
matches!(
1846-
element_ty1.kind(),
1847-
ty::RawPtr(p)
1848-
if p.ty == in_elem && p.mutbl.is_mut() && p.ty.kind() == element_ty0.kind()
1846+
*element_ty1.kind(),
1847+
ty::RawPtr(p_ty, p_mutbl)
1848+
if p_ty == in_elem && p_mutbl.is_mut() && p_ty.kind() == element_ty0.kind()
18491849
),
18501850
InvalidMonomorphization::ExpectedElementType {
18511851
span,
@@ -2074,8 +2074,8 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
20742074
);
20752075

20762076
match in_elem.kind() {
2077-
ty::RawPtr(p) => {
2078-
let metadata = p.ty.ptr_metadata_ty(bx.tcx, |ty| {
2077+
ty::RawPtr(p_ty, _) => {
2078+
let metadata = p_ty.ptr_metadata_ty(bx.tcx, |ty| {
20792079
bx.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), ty)
20802080
});
20812081
require!(
@@ -2088,8 +2088,8 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
20882088
}
20892089
}
20902090
match out_elem.kind() {
2091-
ty::RawPtr(p) => {
2092-
let metadata = p.ty.ptr_metadata_ty(bx.tcx, |ty| {
2091+
ty::RawPtr(p_ty, _) => {
2092+
let metadata = p_ty.ptr_metadata_ty(bx.tcx, |ty| {
20932093
bx.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), ty)
20942094
});
20952095
require!(

compiler/rustc_const_eval/src/interpret/cast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_middle::mir::interpret::{InterpResult, PointerArithmetic, Scalar};
66
use rustc_middle::mir::CastKind;
77
use rustc_middle::ty::adjustment::PointerCoercion;
88
use rustc_middle::ty::layout::{IntegerExt, LayoutOf, TyAndLayout};
9-
use rustc_middle::ty::{self, FloatTy, Ty, TypeAndMut};
9+
use rustc_middle::ty::{self, FloatTy, Ty};
1010
use rustc_target::abi::Integer;
1111
use rustc_type_ir::TyKind::*;
1212

compiler/rustc_const_eval/src/interpret/terminator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
375375
// We cannot use `builtin_deref` here since we need to reject `Box<T, MyAlloc>`.
376376
Ok(Some(match ty.kind() {
377377
ty::Ref(_, ty, _) => *ty,
378-
ty::RawPtr(mt) => mt.ty,
378+
ty::RawPtr(ty, _) => *ty,
379379
// We only accept `Box` with the default allocator.
380380
_ if ty.is_box_global(*self.tcx) => ty.boxed_ty(),
381381
_ => return Ok(None),

compiler/rustc_hir_analysis/src/check/check.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,10 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
937937
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!(
941+
t.kind(),
942+
ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::RawPtr(_, _)
943+
) =>
941944
{ /* struct([f32; 4]) is ok */ }
942945
_ => {
943946
struct_span_code_err!(

compiler/rustc_hir_analysis/src/coherence/builtin.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ fn visit_implementation_of_dispatch_from_dyn(checker: &Checker<'_>) -> Result<()
195195
{
196196
Ok(())
197197
}
198-
(&RawPtr(tm_a), &RawPtr(tm_b)) if tm_a.mutbl == tm_b.mutbl => Ok(()),
198+
(&RawPtr(_, a_mutbl), &RawPtr(_, b_mutbl)) if a_mutbl == b_mutbl => Ok(()),
199199
(&Adt(def_a, args_a), &Adt(def_b, args_b)) if def_a.is_struct() && def_b.is_struct() => {
200200
if def_a != def_b {
201201
let source_path = tcx.def_path_str(def_a.did());
@@ -351,14 +351,17 @@ pub fn coerce_unsized_info<'tcx>(
351351
check_mutbl(mt_a, mt_b, &|ty| Ty::new_imm_ref(tcx, r_b, ty))
352352
}
353353

354-
(&ty::Ref(_, ty_a, mutbl_a), &ty::RawPtr(mt_b)) => {
355-
let mt_a = ty::TypeAndMut { ty: ty_a, mutbl: mutbl_a };
356-
check_mutbl(mt_a, mt_b, &|ty| Ty::new_imm_ptr(tcx, ty))
357-
}
358-
359-
(&ty::RawPtr(mt_a), &ty::RawPtr(mt_b)) => {
360-
check_mutbl(mt_a, mt_b, &|ty| Ty::new_imm_ptr(tcx, ty))
361-
}
354+
(&ty::Ref(_, ty_a, mutbl_a), &ty::RawPtr(ty_b, mutbl_b)) => check_mutbl(
355+
ty::TypeAndMut { ty: ty_a, mutbl: mutbl_a },
356+
ty::TypeAndMut { ty: ty_b, mutbl: mutbl_b },
357+
&|ty| Ty::new_imm_ptr(tcx, ty),
358+
),
359+
360+
(&ty::RawPtr(ty_a, mutbl_a), &ty::RawPtr(ty_b, mutbl_b)) => check_mutbl(
361+
ty::TypeAndMut { ty: ty_a, mutbl: mutbl_a },
362+
ty::TypeAndMut { ty: ty_b, mutbl: mutbl_b },
363+
&|ty| Ty::new_imm_ptr(tcx, ty),
364+
),
362365

363366
(&ty::Adt(def_a, args_a), &ty::Adt(def_b, args_b))
364367
if def_a.is_struct() && def_b.is_struct() =>

compiler/rustc_hir_analysis/src/coherence/orphan.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ fn emit_orphan_check_error<'tcx>(
323323
let is_foreign =
324324
!trait_ref.def_id.is_local() && matches!(is_target_ty, IsFirstInputType::No);
325325

326-
match &ty.kind() {
326+
match *ty.kind() {
327327
ty::Slice(_) => {
328328
push_to_foreign_or_name(
329329
is_foreign,
@@ -354,14 +354,14 @@ fn emit_orphan_check_error<'tcx>(
354354
ty::Alias(ty::Opaque, ..) => {
355355
opaque.push(errors::OnlyCurrentTraitsOpaque { span })
356356
}
357-
ty::RawPtr(ptr_ty) => {
357+
ty::RawPtr(ptr_ty, mutbl) => {
358358
if !self_ty.has_param() {
359-
let mut_key = ptr_ty.mutbl.prefix_str();
359+
let mut_key = mutbl.prefix_str();
360360
sugg = Some(errors::OnlyCurrentTraitsPointerSugg {
361361
wrapper_span: self_ty_span,
362362
struct_span: full_impl_span.shrink_to_lo(),
363363
mut_key,
364-
ptr_ty: ptr_ty.ty,
364+
ptr_ty,
365365
});
366366
}
367367
pointer.push(errors::OnlyCurrentTraitsPointer { span, pointer: ty });

compiler/rustc_hir_analysis/src/variance/constraints.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
253253
self.add_constraints_from_ty(current, typ, variance);
254254
}
255255

256-
ty::RawPtr(ref mt) => {
257-
self.add_constraints_from_mt(current, mt, variance);
256+
ty::RawPtr(ty, mutbl) => {
257+
self.add_constraints_from_mt(current, &ty::TypeAndMut { ty, mutbl }, variance);
258258
}
259259

260260
ty::Tuple(subtys) => {

compiler/rustc_hir_typeck/src/cast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -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(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

+3-3
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
222222

223223
// Examine the supertype and consider auto-borrowing.
224224
match *b.kind() {
225-
ty::RawPtr(mt_b) => {
226-
return self.coerce_unsafe_ptr(a, b, mt_b.mutbl);
225+
ty::RawPtr(_, b_mutbl) => {
226+
return self.coerce_unsafe_ptr(a, b, b_mutbl);
227227
}
228228
ty::Ref(r_b, _, mutbl_b) => {
229229
return self.coerce_borrowed_pointer(a, b, r_b, mutbl_b);
@@ -978,7 +978,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
978978

979979
let (is_ref, mt_a) = match *a.kind() {
980980
ty::Ref(_, ty, mutbl) => (true, ty::TypeAndMut { ty, mutbl }),
981-
ty::RawPtr(mt) => (false, mt),
981+
ty::RawPtr(ty, mutbl) => (false, ty::TypeAndMut { ty, mutbl }),
982982
_ => return self.unify_and(a, b, identity),
983983
};
984984
coerce_mutbls(mt_a.mutbl, mutbl_b)?;

compiler/rustc_hir_typeck/src/expr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2685,8 +2685,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
26852685
expr,
26862686
Some(span),
26872687
);
2688-
} else if let ty::RawPtr(ty_and_mut) = expr_t.kind()
2689-
&& let ty::Adt(adt_def, _) = ty_and_mut.ty.kind()
2688+
} else if let ty::RawPtr(ptr_ty, _) = expr_t.kind()
2689+
&& let ty::Adt(adt_def, _) = ptr_ty.kind()
26902690
&& let ExprKind::Field(base_expr, _) = expr.kind
26912691
&& adt_def.variants().len() == 1
26922692
&& adt_def

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1371,9 +1371,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13711371
arg: &hir::Expr<'tcx>,
13721372
err: &mut Diag<'tcx>,
13731373
) {
1374-
if let ty::RawPtr(ty::TypeAndMut { mutbl: hir::Mutability::Mut, .. }) = expected_ty.kind()
1375-
&& let ty::RawPtr(ty::TypeAndMut { mutbl: hir::Mutability::Not, .. }) =
1376-
provided_ty.kind()
1374+
if let ty::RawPtr(_, hir::Mutability::Mut) = expected_ty.kind()
1375+
&& let ty::RawPtr(_, hir::Mutability::Not) = provided_ty.kind()
13771376
&& let hir::ExprKind::Call(callee, _) = arg.kind
13781377
&& let hir::ExprKind::Path(hir::QPath::Resolved(_, path)) = callee.kind
13791378
&& let Res::Def(_, def_id) = path.res

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::hir::is_range_literal;
77
use crate::method::probe;
88
use crate::method::probe::{IsSuggestion, Mode, ProbeScope};
99
use crate::rustc_middle::ty::Article;
10-
use crate::ty::TypeAndMut;
1110
use core::cmp::min;
1211
use core::iter;
1312
use rustc_ast::util::parser::{ExprPrecedence, PREC_POSTFIX};
@@ -1479,7 +1478,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14791478
expected_ty: Ty<'tcx>,
14801479
) -> bool {
14811480
// Expected type needs to be a raw pointer.
1482-
let ty::RawPtr(mutbl, _) = expected_ty.kind() else {
1481+
let ty::RawPtr(_, mutbl) = expected_ty.kind() else {
14831482
return false;
14841483
};
14851484

compiler/rustc_hir_typeck/src/method/probe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
12381238
return None;
12391239
}
12401240

1241-
let &ty::RawPtr(ty::TypeAndMut { ty, mutbl: hir::Mutability::Mut }) = self_ty.kind() else {
1241+
let &ty::RawPtr(ty, hir::Mutability::Mut) = self_ty.kind() else {
12421242
return None;
12431243
};
12441244

compiler/rustc_lint/src/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2477,7 +2477,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue {
24772477
Adt(..) if ty.is_box() => Some("`Box` must be non-null".into()),
24782478
FnPtr(..) => Some("function pointers must be non-null".into()),
24792479
Never => Some("the `!` type has no valid value".into()),
2480-
RawPtr(tm) if matches!(tm.ty.kind(), Dynamic(..)) =>
2480+
RawPtr(ty, _) if matches!(ty.kind(), Dynamic(..)) =>
24812481
// raw ptr to dyn Trait
24822482
{
24832483
Some("the vtable of a wide raw pointer must be non-null".into())

compiler/rustc_lint/src/foreign_modules.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,10 @@ fn structurally_same_type_impl<'tcx>(
322322
(Slice(a_ty), Slice(b_ty)) => {
323323
structurally_same_type_impl(seen_types, tcx, param_env, *a_ty, *b_ty, ckind)
324324
}
325-
(RawPtr(a_tymut), RawPtr(b_tymut)) => {
326-
a_tymut.mutbl == b_tymut.mutbl
325+
(RawPtr(a_ty, a_mutbl), RawPtr(b_ty, b_mutbl)) => {
326+
a_mutbl == b_mutbl
327327
&& structurally_same_type_impl(
328-
seen_types, tcx, param_env, a_tymut.ty, b_tymut.ty, ckind,
328+
seen_types, tcx, param_env, *a_ty, *b_ty, ckind,
329329
)
330330
}
331331
(Ref(_a_region, a_ty, a_mut), Ref(_b_region, b_ty, b_mut)) => {

compiler/rustc_lint/src/reference_casting.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_ast::Mutability;
22
use rustc_hir::{Expr, ExprKind, UnOp};
33
use rustc_middle::ty::layout::LayoutOf as _;
4-
use rustc_middle::ty::{self, layout::TyAndLayout, TypeAndMut};
4+
use rustc_middle::ty::{self, layout::TyAndLayout};
55
use rustc_span::sym;
66

77
use crate::{lints::InvalidReferenceCastingDiag, LateContext, LateLintPass, LintContext};
@@ -153,7 +153,7 @@ fn is_cast_from_ref_to_mut_ptr<'tcx>(
153153
let end_ty = cx.typeck_results().node_type(orig_expr.hir_id);
154154

155155
// Bail out early if the end type is **not** a mutable pointer.
156-
if !matches!(end_ty.kind(), ty::RawPtr(TypeAndMut { ty: _, mutbl: Mutability::Mut })) {
156+
if !matches!(end_ty.kind(), ty::RawPtr(_, Mutability::Mut)) {
157157
return None;
158158
}
159159

0 commit comments

Comments
 (0)