Skip to content

Commit 90c4b94

Browse files
committed
fix wrong evaluation in clippy
1 parent 773d8b2 commit 90c4b94

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/test/mir-opt/inline/inline_into_box_place.main.Inline.32bit.diff

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
StorageLive(_1); // scope 0 at $DIR/inline-into-box-place.rs:8:9: 8:11
2424
_2 = SizeOf(std::vec::Vec<u32>); // scope 2 at $DIR/inline-into-box-place.rs:8:29: 8:43
2525
_3 = AlignOf(std::vec::Vec<u32>); // scope 2 at $DIR/inline-into-box-place.rs:8:29: 8:43
26-
_4 = : unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}(move _2, move _3) -> bb1; // scope 2 at $DIR/inline-into-box-place.rs:8:29: 8:43
26+
_4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 2 at $DIR/inline-into-box-place.rs:8:29: 8:43
2727
// mir::Constant
2828
// + span: $DIR/inline-into-box-place.rs:8:29: 8:43
29-
// + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(ValTree::Branch(..)) }
29+
// + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(Scalar(<ZST>)) }
3030
}
3131

3232
bb1: {
@@ -71,10 +71,10 @@
7171
- }
7272
-
7373
- bb5 (cleanup): {
74-
- _6 = : unsafe fn(Unique::<Vec<u32>>, std::alloc::Global) {alloc::alloc::box_free::<Vec<u32>, std::alloc::Global>}(move (_5.0: std::ptr::Unique<std::vec::Vec<u32>>), move (_5.1: std::alloc::Global)) -> bb4; // scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43
74+
- _6 = alloc::alloc::box_free::<Vec<u32>, std::alloc::Global>(move (_5.0: std::ptr::Unique<std::vec::Vec<u32>>), move (_5.1: std::alloc::Global)) -> bb4; // scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43
7575
- // mir::Constant
7676
- // + span: $DIR/inline-into-box-place.rs:8:42: 8:43
77-
- // + literal: Const { ty: unsafe fn(Unique<Vec<u32>>, std::alloc::Global) {alloc::alloc::box_free::<Vec<u32>, std::alloc::Global>}, val: Value(ValTree::Branch(..)) }
77+
- // + literal: Const { ty: unsafe fn(Unique<Vec<u32>>, std::alloc::Global) {alloc::alloc::box_free::<Vec<u32>, std::alloc::Global>}, val: Value(Scalar(<ZST>)) }
7878
}
7979
}
8080

src/test/mir-opt/unusual_item_types.core.ptr-drop_in_place.Vec_i32_.AddMovesForPackedDrops.before.32bit.mir

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ fn std::ptr::drop_in_place(_1: *mut Vec<i32>) -> () {
3131

3232
bb6: {
3333
_2 = &mut (*_1); // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
34-
_3 = : for<'r> fn(&'r mut Vec::<i32>) {<Vec<i32> as Drop>::drop}(move _2) -> [return: bb5, unwind: bb4]; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
34+
_3 = <Vec<i32> as Drop>::drop(move _2) -> [return: bb5, unwind: bb4]; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
3535
// mir::Constant
3636
// + span: $SRC_DIR/core/src/ptr/mod.rs:LL:COL
37-
// + literal: Const { ty: for<'r> fn(&'r mut Vec<i32>) {<Vec<i32> as Drop>::drop}, val: Value(ValTree::Branch(..)) }
37+
// + literal: Const { ty: for<'r> fn(&'r mut Vec<i32>) {<Vec<i32> as Drop>::drop}, val: Value(Scalar(<ZST>)) }
3838
}
3939
}

src/tools/clippy/clippy_utils/src/consts.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ pub fn miri_to_const<'tcx>(tcx: TyCtxt<'tcx>, result: mir::ConstantKind<'tcx>) -
619619
},
620620
mir::ConstantKind::Val(ConstValue::ByRef { alloc, offset: _ }, _) => match result.ty().kind() {
621621
ty::Array(sub_type, len) => match sub_type.kind() {
622-
ty::Float(FloatTy::F32) => match len.try_eval_usize(tcx, ty::ParamEnv::empty()) {
622+
ty::Float(FloatTy::F32) => match len.to_valtree().try_to_machine_usize(tcx) {
623623
Some(len) => alloc
624624
.inner()
625625
.inspect_with_uninit_and_ptr_outside_interpreter(0..(4 * len as usize))
@@ -634,7 +634,7 @@ pub fn miri_to_const<'tcx>(tcx: TyCtxt<'tcx>, result: mir::ConstantKind<'tcx>) -
634634
.map(Constant::Vec),
635635
_ => None,
636636
},
637-
ty::Float(FloatTy::F64) => match len.try_eval_usize(tcx, ty::ParamEnv::empty()) {
637+
ty::Float(FloatTy::F64) => match len.to_valtree().try_to_machine_usize(tcx) {
638638
Some(len) => alloc
639639
.inner()
640640
.inspect_with_uninit_and_ptr_outside_interpreter(0..(8 * len as usize))

0 commit comments

Comments
 (0)