Skip to content

Commit c92b350

Browse files
Programmatically convert some of the pat ctors
1 parent 0b81086 commit c92b350

19 files changed

+29
-29
lines changed

clippy_lints/src/casts/cast_slice_different_sizes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ fn is_child_of_cast(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
8787
/// the type is one of those slices
8888
fn get_raw_slice_ty_mut(ty: Ty<'_>) -> Option<TypeAndMut<'_>> {
8989
match ty.kind() {
90-
ty::RawPtr(TypeAndMut { ty: slice_ty, mutbl }) => match slice_ty.kind() {
90+
ty::RawPtr(slice_ty, mutbl) => match slice_ty.kind() {
9191
ty::Slice(ty) => Some(TypeAndMut { ty: *ty, mutbl: *mutbl }),
9292
_ => None,
9393
},

clippy_lints/src/casts/ptr_as_ptr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, msrv: &Msrv) {
3333

3434
if let ExprKind::Cast(cast_expr, cast_to_hir_ty) = expr.kind
3535
&& let (cast_from, cast_to) = (cx.typeck_results().expr_ty(cast_expr), cx.typeck_results().expr_ty(expr))
36-
&& let ty::RawPtr(TypeAndMut { mutbl: from_mutbl, .. }) = cast_from.kind()
37-
&& let ty::RawPtr(TypeAndMut { ty: to_pointee_ty, mutbl: to_mutbl }) = cast_to.kind()
36+
&& let ty::RawPtr(_, from_mutbl) = cast_from.kind()
37+
&& let ty::RawPtr(to_pointee_ty, to_mutbl) = cast_to.kind()
3838
&& matches!((from_mutbl, to_mutbl),
3939
(Mutability::Not, Mutability::Not) | (Mutability::Mut, Mutability::Mut))
4040
// The `U` in `pointer::cast` have to be `Sized`

clippy_lints/src/casts/ref_as_ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub(super) fn check<'tcx>(
2121
);
2222

2323
if matches!(cast_from.kind(), ty::Ref(..))
24-
&& let ty::RawPtr(TypeAndMut { mutbl: to_mutbl, .. }) = cast_to.kind()
24+
&& let ty::RawPtr(_, to_mutbl) = cast_to.kind()
2525
&& let Some(use_cx) = expr_use_ctxt(cx, expr)
2626
// TODO: only block the lint if `cast_expr` is a temporary
2727
&& !matches!(use_cx.node, ExprUseNode::Local(_) | ExprUseNode::ConstStatic(_))

clippy_lints/src/from_raw_with_void_ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl LateLintPass<'_> for FromRawWithVoidPtr {
4444
&& seg.ident.name == sym!(from_raw)
4545
&& let Some(type_str) = path_def_id(cx, ty).and_then(|id| def_id_matches_type(cx, id))
4646
&& let arg_kind = cx.typeck_results().expr_ty(arg).kind()
47-
&& let RawPtr(TypeAndMut { ty, .. }) = arg_kind
47+
&& let ty::RawPtr(ty, _) = arg_kind
4848
&& is_c_void(cx, *ty)
4949
{
5050
let msg = format!("creating a `{type_str}` from a void raw pointer");

clippy_lints/src/functions/must_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ fn is_mutable_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, tys: &mut DefIdSet)
207207
},
208208
ty::Tuple(args) => args.iter().any(|ty| is_mutable_ty(cx, ty, tys)),
209209
ty::Array(ty, _) | ty::Slice(ty) => is_mutable_ty(cx, ty, tys),
210-
ty::RawPtr(ty::TypeAndMut { ty, mutbl }) | ty::Ref(_, ty, mutbl) => {
210+
ty::RawPtr(ty, mutbl) | ty::Ref(_, ty, mutbl) => {
211211
mutbl == hir::Mutability::Mut || is_mutable_ty(cx, ty, tys)
212212
},
213213
// calling something constitutes a side effect, so return true on all callables

clippy_lints/src/functions/not_unsafe_ptr_arg_deref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fn check_raw_ptr<'tcx>(
7575
}
7676

7777
fn raw_ptr_arg(cx: &LateContext<'_>, arg: &hir::Param<'_>) -> Option<hir::HirId> {
78-
if let (&hir::PatKind::Binding(_, id, _, _), Some(&ty::RawPtr(_))) = (
78+
if let (&hir::PatKind::Binding(_, id, _, _), Some(&ty::RawPtr(_, _))) = (
7979
&arg.pat.kind,
8080
cx.maybe_typeck_results()
8181
.map(|typeck_results| typeck_results.pat_ty(arg.pat).kind()),

clippy_lints/src/matches/significant_drop_in_scrutinee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl<'a, 'tcx> SigDropChecker<'a, 'tcx> {
149149
false
150150
},
151151
rustc_middle::ty::Array(ty, _)
152-
| rustc_middle::ty::RawPtr(TypeAndMut { ty, .. })
152+
| rustc_middle::ty::RawPtr(ty, _)
153153
| rustc_middle::ty::Ref(_, ty, _)
154154
| rustc_middle::ty::Slice(ty) => self.has_sig_drop_attr(cx, *ty),
155155
_ => false,

clippy_lints/src/methods/zst_offset.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_middle::ty;
66
use super::ZST_OFFSET;
77

88
pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr<'_>) {
9-
if let ty::RawPtr(ty::TypeAndMut { ty, .. }) = cx.typeck_results().expr_ty(recv).kind()
9+
if let ty::RawPtr(ty, _) = cx.typeck_results().expr_ty(recv).kind()
1010
&& let Ok(layout) = cx.tcx.layout_of(cx.param_env.and(*ty))
1111
&& layout.is_zst()
1212
{

clippy_lints/src/mutex_atomic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ fn get_atomic_name(ty: Ty<'_>) -> Option<&'static str> {
127127
IntTy::I128 => None,
128128
}
129129
},
130-
ty::RawPtr(_) => Some("AtomicPtr"),
130+
ty::RawPtr(_, _) => Some("AtomicPtr"),
131131
_ => None,
132132
}
133133
}

clippy_lints/src/non_send_fields_in_send_ty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ fn ty_allowed_with_raw_pointer_heuristic<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'t
219219
}
220220
},
221221
// Raw pointers are `!Send` but allowed by the heuristic
222-
ty::RawPtr(_) => true,
222+
ty::RawPtr(_, _) => true,
223223
_ => false,
224224
}
225225
}
@@ -229,7 +229,7 @@ fn contains_pointer_like<'tcx>(cx: &LateContext<'tcx>, target_ty: Ty<'tcx>) -> b
229229
for ty_node in target_ty.walk() {
230230
if let GenericArgKind::Type(inner_ty) = ty_node.unpack() {
231231
match inner_ty.kind() {
232-
ty::RawPtr(_) => {
232+
ty::RawPtr(_, _) => {
233233
return true;
234234
},
235235
ty::Adt(adt_def, _) => {

0 commit comments

Comments
 (0)