Skip to content

Commit d195f80

Browse files
committed
Revert "stabilize const_float_bits_conv" for src/tools/clippy/clippy_lints
This reverts the part of commit 19908ff in subdirectory src/tools/clippy/clippy_lints.
1 parent d0985bb commit d195f80

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

src/tools/clippy/clippy_lints/src/transmute/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -619,10 +619,10 @@ impl<'tcx> LateLintPass<'tcx> for Transmute {
619619
| transmute_ref_to_ref::check(cx, e, from_ty, to_ty, arg, const_context)
620620
| transmute_ptr_to_ptr::check(cx, e, from_ty, to_ty, arg, &self.msrv)
621621
| transmute_int_to_bool::check(cx, e, from_ty, to_ty, arg)
622-
| transmute_int_to_float::check(cx, e, from_ty, to_ty, arg)
622+
| transmute_int_to_float::check(cx, e, from_ty, to_ty, arg, const_context)
623623
| transmute_int_to_non_zero::check(cx, e, from_ty, to_ty, arg)
624-
| transmute_float_to_int::check(cx, e, from_ty, to_ty, arg)
625-
| transmute_num_to_bytes::check(cx, e, from_ty, to_ty, arg)
624+
| transmute_float_to_int::check(cx, e, from_ty, to_ty, arg, const_context)
625+
| transmute_num_to_bytes::check(cx, e, from_ty, to_ty, arg, const_context)
626626
| (unsound_collection_transmute::check(cx, e, from_ty, to_ty)
627627
|| transmute_undefined_repr::check(cx, e, from_ty, to_ty))
628628
| (eager_transmute::check(cx, e, arg, from_ty, to_ty));

src/tools/clippy/clippy_lints/src/transmute/transmute_float_to_int.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ pub(super) fn check<'tcx>(
1515
from_ty: Ty<'tcx>,
1616
to_ty: Ty<'tcx>,
1717
mut arg: &'tcx Expr<'_>,
18+
const_context: bool,
1819
) -> bool {
1920
match (&from_ty.kind(), &to_ty.kind()) {
20-
(ty::Float(float_ty), ty::Int(_) | ty::Uint(_)) => {
21+
(ty::Float(float_ty), ty::Int(_) | ty::Uint(_)) if !const_context => {
2122
span_lint_and_then(
2223
cx,
2324
TRANSMUTE_FLOAT_TO_INT,

src/tools/clippy/clippy_lints/src/transmute/transmute_int_to_float.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ pub(super) fn check<'tcx>(
1414
from_ty: Ty<'tcx>,
1515
to_ty: Ty<'tcx>,
1616
arg: &'tcx Expr<'_>,
17+
const_context: bool,
1718
) -> bool {
1819
match (&from_ty.kind(), &to_ty.kind()) {
19-
(ty::Int(_) | ty::Uint(_), ty::Float(_)) => {
20+
(ty::Int(_) | ty::Uint(_), ty::Float(_)) if !const_context => {
2021
span_lint_and_then(
2122
cx,
2223
TRANSMUTE_INT_TO_FLOAT,

src/tools/clippy/clippy_lints/src/transmute/transmute_num_to_bytes.rs

+6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@ pub(super) fn check<'tcx>(
1414
from_ty: Ty<'tcx>,
1515
to_ty: Ty<'tcx>,
1616
arg: &'tcx Expr<'_>,
17+
const_context: bool,
1718
) -> bool {
1819
match (&from_ty.kind(), &to_ty.kind()) {
1920
(ty::Int(_) | ty::Uint(_) | ty::Float(_), ty::Array(arr_ty, _)) => {
2021
if !matches!(arr_ty.kind(), ty::Uint(UintTy::U8)) {
2122
return false;
2223
}
24+
if matches!(from_ty.kind(), ty::Float(_)) && const_context {
25+
// TODO: Remove when const_float_bits_conv is stabilized
26+
// rust#72447
27+
return false;
28+
}
2329

2430
span_lint_and_then(
2531
cx,

0 commit comments

Comments
 (0)