Skip to content

Commit 4f50e6f

Browse files
Remove CastCheckResult since it's unused
1 parent c3f077c commit 4f50e6f

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

clippy_lints/src/transmute/utils.rs

+17-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
use rustc_hir::Expr;
2-
use rustc_hir_analysis::check::{
3-
cast::{self, CastCheckResult},
4-
FnCtxt, Inherited,
5-
};
2+
use rustc_hir_analysis::check::{cast, FnCtxt, Inherited};
63
use rustc_lint::LateContext;
74
use rustc_middle::ty::{cast::CastKind, Ty};
85
use rustc_span::DUMMY_SP;
96

107
// check if the component types of the transmuted collection and the result have different ABI,
118
// size or alignment
12-
pub(super) fn is_layout_incompatible<'tcx>(cx: &LateContext<'tcx>, from: Ty<'tcx>, to: Ty<'tcx>) -> bool {
9+
pub(super) fn is_layout_incompatible<'tcx>(
10+
cx: &LateContext<'tcx>,
11+
from: Ty<'tcx>,
12+
to: Ty<'tcx>,
13+
) -> bool {
1314
if let Ok(from) = cx.tcx.try_normalize_erasing_regions(cx.param_env, from)
1415
&& let Ok(to) = cx.tcx.try_normalize_erasing_regions(cx.param_env, to)
1516
&& let Ok(from_layout) = cx.tcx.layout_of(cx.param_env.and(from))
@@ -32,7 +33,9 @@ pub(super) fn can_be_expressed_as_pointer_cast<'tcx>(
3233
from_ty: Ty<'tcx>,
3334
to_ty: Ty<'tcx>,
3435
) -> bool {
35-
use CastKind::{AddrPtrCast, ArrayPtrCast, FnPtrAddrCast, FnPtrPtrCast, PtrAddrCast, PtrPtrCast};
36+
use CastKind::{
37+
AddrPtrCast, ArrayPtrCast, FnPtrAddrCast, FnPtrPtrCast, PtrAddrCast, PtrPtrCast,
38+
};
3639
matches!(
3740
check_cast(cx, e, from_ty, to_ty),
3841
Some(PtrPtrCast | PtrAddrCast | AddrPtrCast | ArrayPtrCast | FnPtrPtrCast | FnPtrAddrCast)
@@ -43,20 +46,22 @@ pub(super) fn can_be_expressed_as_pointer_cast<'tcx>(
4346
/// the cast. In certain cases, including some invalid casts from array references
4447
/// to pointers, this may cause additional errors to be emitted and/or ICE error
4548
/// messages. This function will panic if that occurs.
46-
fn check_cast<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, from_ty: Ty<'tcx>, to_ty: Ty<'tcx>) -> Option<CastKind> {
49+
fn check_cast<'tcx>(
50+
cx: &LateContext<'tcx>,
51+
e: &'tcx Expr<'_>,
52+
from_ty: Ty<'tcx>,
53+
to_ty: Ty<'tcx>,
54+
) -> Option<CastKind> {
4755
let hir_id = e.hir_id;
4856
let local_def_id = hir_id.owner.def_id;
4957

5058
Inherited::build(cx.tcx, local_def_id).enter(|inherited| {
5159
let fn_ctxt = FnCtxt::new(&inherited, cx.param_env, hir_id);
5260

5361
// If we already have errors, we can't be sure we can pointer cast.
54-
assert!(
55-
!fn_ctxt.errors_reported_since_creation(),
56-
"Newly created FnCtxt contained errors"
57-
);
62+
assert!(!fn_ctxt.errors_reported_since_creation(), "Newly created FnCtxt contained errors");
5863

59-
if let CastCheckResult::Deferred(check) = cast::check_cast(
64+
if let Ok(check) = cast::CastCheck::new(
6065
&fn_ctxt, e, from_ty, to_ty,
6166
// We won't show any error to the user, so we don't care what the span is here.
6267
DUMMY_SP, DUMMY_SP,

0 commit comments

Comments
 (0)