Skip to content

Commit b7eab00

Browse files
committed
fmt
1 parent 8293ca6 commit b7eab00

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -630,11 +630,8 @@ fn codegen_stmt<'tcx>(
630630
let to_ty = fx.monomorphize(to_ty);
631631

632632
fn is_fat_ptr<'tcx>(fx: &FunctionCx<'_, '_, 'tcx>, ty: Ty<'tcx>) -> bool {
633-
ty.builtin_deref(true).is_some_and(
634-
|(pointee_ty, _)| {
635-
has_ptr_meta(fx.tcx, pointee_ty)
636-
},
637-
)
633+
ty.builtin_deref(true)
634+
.is_some_and(|(pointee_ty, _)| has_ptr_meta(fx.tcx, pointee_ty))
638635
}
639636

640637
if is_fat_ptr(fx, from_ty) {

compiler/rustc_hir_analysis/src/autoderef.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,13 @@ impl<'a, 'tcx> Iterator for Autoderef<'a, 'tcx> {
6666
}
6767

6868
// Otherwise, deref if type is derefable:
69-
let (kind, new_ty) = if let Some((ty, _)) =
70-
self.state.cur_ty.builtin_deref(self.include_raw_pointers)
71-
{
72-
debug_assert_eq!(ty, self.infcx.resolve_vars_if_possible(ty));
73-
// NOTE: we may still need to normalize the built-in deref in case
74-
// we have some type like `&<Ty as Trait>::Assoc`, since users of
75-
// autoderef expect this type to have been structurally normalized.
76-
if self.infcx.tcx.trait_solver_next()
69+
let (kind, new_ty) =
70+
if let Some((ty, _)) = self.state.cur_ty.builtin_deref(self.include_raw_pointers) {
71+
debug_assert_eq!(ty, self.infcx.resolve_vars_if_possible(ty));
72+
// NOTE: we may still need to normalize the built-in deref in case
73+
// we have some type like `&<Ty as Trait>::Assoc`, since users of
74+
// autoderef expect this type to have been structurally normalized.
75+
if self.infcx.tcx.trait_solver_next()
7776
&& let ty::Alias(ty::Projection, _) = ty.kind()
7877
{
7978
let (normalized_ty, obligations) = self.structurally_normalize(ty)?;
@@ -82,11 +81,11 @@ impl<'a, 'tcx> Iterator for Autoderef<'a, 'tcx> {
8281
} else {
8382
(AutoderefKind::Builtin, ty)
8483
}
85-
} else if let Some(ty) = self.overloaded_deref_ty(self.state.cur_ty) {
86-
(AutoderefKind::Overloaded, ty)
87-
} else {
88-
return None;
89-
};
84+
} else if let Some(ty) = self.overloaded_deref_ty(self.state.cur_ty) {
85+
(AutoderefKind::Overloaded, ty)
86+
} else {
87+
return None;
88+
};
9089

9190
if new_ty.references_error() {
9291
return None;

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2099,9 +2099,7 @@ impl<'tcx> Ty<'tcx> {
20992099
/// Some types -- notably unsafe ptrs -- can only be dereferenced explicitly.
21002100
pub fn builtin_deref(self, explicit: bool) -> Option<(Ty<'tcx>, rustc_type_ir::Mutability)> {
21012101
match self.kind() {
2102-
Adt(def, _) if def.is_box() => {
2103-
Some((self.boxed_ty(), rustc_type_ir::Mutability::Not))
2104-
}
2102+
Adt(def, _) if def.is_box() => Some((self.boxed_ty(), rustc_type_ir::Mutability::Not)),
21052103
Ref(_, ty, mutbl) => Some((*ty, *mutbl)),
21062104
RawPtr(mt) if explicit => Some((mt.ty, mt.mutbl)),
21072105
_ => None,

0 commit comments

Comments
 (0)