Skip to content

Commit 44c29bd

Browse files
authored
Rollup merge of rust-lang#124957 - compiler-errors:builtin-deref, r=michaelwoerister
Make `Ty::builtin_deref` just return a `Ty` Nowhere in the compiler are we using the mutability part of the `TyAndMut` that we used to return.
2 parents ff931a7 + 51145a2 commit 44c29bd

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

clippy_lints/src/matches/significant_drop_in_scrutinee.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_errors::{Applicability, Diag};
66
use rustc_hir::intravisit::{walk_expr, Visitor};
77
use rustc_hir::{Arm, Expr, ExprKind, MatchSource};
88
use rustc_lint::{LateContext, LintContext};
9-
use rustc_middle::ty::{GenericArgKind, Ty, TypeAndMut};
9+
use rustc_middle::ty::{GenericArgKind, Ty};
1010
use rustc_span::Span;
1111

1212
use super::SIGNIFICANT_DROP_IN_SCRUTINEE;
@@ -234,9 +234,9 @@ impl<'a, 'tcx> SigDropHelper<'a, 'tcx> {
234234
}
235235
let ty = self.sig_drop_checker.get_type(expr);
236236
if ty.is_ref() {
237-
// We checked that the type was ref, so builtin_deref will return Some TypeAndMut,
238-
// but let's avoid any chance of an ICE
239-
if let Some(TypeAndMut { ty, .. }) = ty.builtin_deref(true) {
237+
// We checked that the type was ref, so builtin_deref will return Some,
238+
// but let's avoid any chance of an ICE.
239+
if let Some(ty) = ty.builtin_deref(true) {
240240
if ty.is_trivially_pure_clone_copy() {
241241
self.replace_current_sig_drop(expr.span, false, LintSuggestion::MoveAndDerefToCopy);
242242
} else if allow_move_and_clone {

clippy_lints/src/operators/cmp_owned.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fn check_op(cx: &LateContext<'_>, expr: &Expr<'_>, other: &Expr<'_>, left: bool)
7070
let without_deref = symmetric_partial_eq(cx, arg_ty, other_ty).unwrap_or_default();
7171
let with_deref = arg_ty
7272
.builtin_deref(true)
73-
.and_then(|tam| symmetric_partial_eq(cx, tam.ty, other_ty))
73+
.and_then(|ty| symmetric_partial_eq(cx, ty, other_ty))
7474
.unwrap_or_default();
7575

7676
if !with_deref.is_implemented() && !without_deref.is_implemented() {

clippy_utils/src/qualify_min_const_fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ fn check_rvalue<'tcx>(
134134
) => Err((span, "function pointer casts are not allowed in const fn".into())),
135135
Rvalue::Cast(CastKind::PointerCoercion(PointerCoercion::Unsize), op, cast_ty) => {
136136
let pointee_ty = if let Some(deref_ty) = cast_ty.builtin_deref(true) {
137-
deref_ty.ty
137+
deref_ty
138138
} else {
139139
// We cannot allow this for now.
140140
return Err((span, "unsizing casts are only allowed for references right now".into()));

0 commit comments

Comments
 (0)