Skip to content

Commit a316ec5

Browse files
committed
Updated rustc
1 parent d97f0ce commit a316ec5

File tree

7 files changed

+24
-29
lines changed

7 files changed

+24
-29
lines changed

src/basic_block.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use cilly::basic_block::Handler;
2-
use rustc_middle::mir::BasicBlockData;
2+
use rustc_middle::mir::{BasicBlockData,BasicBlock};
33
use rustc_middle::mir::UnwindAction;
44
use rustc_middle::{
55
mir::{BasicBlocks, Body, TerminatorKind},
@@ -35,10 +35,10 @@ fn simplify_handler<'tcx>(
3535
return None;
3636
}
3737
let handler = handler?;
38-
if !blocks[handler.into()].statements.is_empty() {
38+
if !blocks[BasicBlock::from_u32(handler)].statements.is_empty() {
3939
return Some(handler);
4040
}
41-
match blocks[handler.into()].terminator.as_ref()?.kind {
41+
match blocks[BasicBlock::from_u32(handler)].terminator.as_ref()?.kind {
4242
TerminatorKind::TailCall { .. } => None,
4343
TerminatorKind::Goto { target } => {
4444
simplify_handler(Some(target.as_u32()), blocks, tcx, method_instance, method)

src/place/body.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ use cilly::{
1010
call,
1111
cil_node::CILNode,
1212
conv_usize, ld_field,
13-
v2::{cilnode::MethodKind, FieldDesc, Int, MethodRef},
13+
v2::{FieldDesc, Int},
1414
Const, IntoAsmIndex, NodeIdx, Type,
1515
};
16-
use rustc_middle::mir::PlaceElem;
16+
use rustc_middle::mir::{Local,PlaceElem};
1717
use rustc_middle::ty::{Ty, TyKind};
1818
pub fn local_body<'tcx>(local: usize, ctx: &mut MethodCompileCtx<'tcx, '_>) -> (NodeIdx, Ty<'tcx>) {
19-
let ty = ctx.body().local_decls[local.into()].ty;
19+
let ty = ctx.body().local_decls[Local::from_usize(local)].ty;
2020
let ty = ctx.monomorphize(ty);
2121
if body_ty_is_by_adress(ty, ctx) {
2222
(super::adress::local_adress(local, ctx.body(), ctx), ty)

src/terminator/intrinsics/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ pub fn handle_intrinsic<'tcx>(
689689
"truncf32" => float_unop(args, destination, ctx, Float::F32, "Truncate"),
690690
"truncf64" => float_unop(args, destination, ctx, Float::F64, "Truncate"),
691691
// `roundf32` should be a differnt intrinsics, but it requires some .NET fuckery to implement(.NET enums are **wierd**)
692-
"nearbyintf32" | "rintf32" | "roundevenf32" => {
692+
"nearbyintf32" | "rintf32" | "round_ties_even_f32" => {
693693
let round = MethodRef::new(
694694
ClassRef::mathf(ctx),
695695
ctx.alloc_string("Round"),
@@ -705,7 +705,7 @@ pub fn handle_intrinsic<'tcx>(
705705
}
706706
"roundf32" => vec![roundf32(args, destination, ctx)],
707707
"roundf64" => vec![roundf64(args, destination, ctx)],
708-
"nearbyintf64" | "rintf64" | "roundevenf64" => {
708+
"nearbyintf64" | "rintf64" | "round_ties_even_f64" => {
709709
let round = MethodRef::new(
710710
ClassRef::math(ctx),
711711
ctx.alloc_string("Round"),

src/unsize.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use rustc_middle::{
1313
mir::{Operand, Place},
1414
ty::{layout::TyAndLayout, ExistentialTraitRef, Ty, TyKind, UintTy},
1515
};
16+
use rustc_abi::FieldIdx;
1617

1718
/// Preforms an unsizing cast on operand `operand`, converting it to the `target` type.
1819
pub fn unsize2<'tcx>(
@@ -228,8 +229,8 @@ fn unsize_metadata<'tcx>(
228229
assert_eq!(def_a, def_b);
229230

230231
for i in 0..def_a.variant(FIRST_VARIANT).fields.len() {
231-
let src_f = &def_a.variant(FIRST_VARIANT).fields[i.into()];
232-
let dst_f = &def_b.variant(FIRST_VARIANT).fields[i.into()];
232+
let src_f = &def_a.variant(FIRST_VARIANT).fields[FieldIdx::from_usize(i)];
233+
let dst_f = &def_b.variant(FIRST_VARIANT).fields[FieldIdx::from_usize(i)];
233234
let src_f_ty = fx.layout_of(src_f.ty(fx.tcx(), subst_a));
234235
let dst_f_ty = fx.layout_of(dst_f.ty(fx.tcx(), subst_b));
235236
if src_f_ty.layout.is_zst() {

src/utilis/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use cilly::{
44
v2::{FieldDesc, FieldIdx},
55
};
66
use rustc_hir::def_id::DefId;
7+
use rustc_abi::VariantIdx;
78
use rustc_middle::{
89
mir::interpret::AllocId,
910
ty::{
@@ -81,7 +82,7 @@ pub fn field_name(ty: Ty, idx: u32) -> crate::IString {
8182
pub fn variant_name(ty: Ty, idx: u32) -> crate::IString {
8283
match ty.kind() {
8384
TyKind::Adt(adt_def, _subst) => {
84-
let variant_def = &adt_def.variants()[idx.into()];
85+
let variant_def = &adt_def.variants()[VariantIdx::from_u32(idx)];
8586
variant_def.name.to_string().into()
8687
}
8788
_ => todo!("Can't yet get fields of typr {ty:?}"),

test/arthm/ptr.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
#![feature(ptr_sub_ptr)]
21
use core::ptr::NonNull;
32
fn main(){
43
let mut arr:[u8;10] = [0_u8;10];
54
let offset = NonNull::new(&mut arr[9] as *mut _).unwrap();
65
let start = NonNull::new(&mut arr[0] as *mut _).unwrap();
7-
unsafe{assert_eq!(offset.sub_ptr(start),9)};
6+
unsafe{assert_eq!(offset.offset_from_unsigned(start),9)};
87
}

test/intrinsics/round.rs

+10-16
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ use core::intrinsics::fabsf32;
1515
use core::intrinsics::fabsf64;
1616
use core::intrinsics::floorf32;
1717
use core::intrinsics::floorf64;
18-
use core::intrinsics::nearbyintf32;
19-
use core::intrinsics::nearbyintf64;
2018
use core::intrinsics::rintf32;
2119
use core::intrinsics::rintf64;
22-
use core::intrinsics::roundevenf32;
23-
use core::intrinsics::roundevenf64;
20+
use core::intrinsics::round_ties_even_f32;
21+
use core::intrinsics::round_ties_even_f64;
2422
use core::intrinsics::roundf32;
2523
use core::intrinsics::roundf64;
2624
use core::intrinsics::truncf32;
@@ -37,10 +35,6 @@ fn main() {
3735
test_eq!(unsafe { fabsf64(x) }, black_box(x));
3836
test_eq!(unsafe { fabsf64(y) }, black_box(-y));
3937
test!(unsafe { fabsf64(f64::NAN) }.is_nan());
40-
test_eq!(unsafe { nearbyintf32(2.5f32) }, black_box(2.0));
41-
test_eq!(unsafe { nearbyintf32(3.5f32) }, black_box(4.0));
42-
test_eq!(unsafe { nearbyintf64(2.5f64) }, black_box(2.0));
43-
test_eq!(unsafe { nearbyintf64(3.5f64) }, black_box(4.0));
4438
let f = 3.3_f32;
4539
let g = -3.3_f32;
4640
let h = 3.5_f32;
@@ -61,18 +55,18 @@ fn main() {
6155
let g = -3.3_f32;
6256
let h = 3.5_f32;
6357
let i = 4.5_f32;
64-
test_eq!(unsafe { roundevenf32(f) }, black_box(3.0));
65-
test_eq!(unsafe { roundevenf32(g) }, black_box(-3.0));
66-
test_eq!(unsafe { roundevenf32(h) }, black_box(4.0));
67-
test_eq!(unsafe { roundevenf32(i) }, black_box(4.0));
58+
test_eq!(unsafe { round_ties_even_f32(f) }, black_box(3.0));
59+
test_eq!(unsafe { round_ties_even_f32(g) }, black_box(-3.0));
60+
test_eq!(unsafe { round_ties_even_f32(h) }, black_box(4.0));
61+
test_eq!(unsafe { round_ties_even_f32(i) }, black_box(4.0));
6862
let f = 3.3_f64;
6963
let g = -3.3_f64;
7064
let h = 3.5_f64;
7165
let i = 4.5_f64;
72-
test_eq!(unsafe { roundevenf64(f) }, black_box(3.0));
73-
test_eq!(unsafe { roundevenf64(g) }, black_box(-3.0));
74-
test_eq!(unsafe { roundevenf64(h) }, black_box(4.0));
75-
test_eq!(unsafe { roundevenf64(i) }, black_box(4.0));
66+
test_eq!(unsafe { round_ties_even_f64(f) }, black_box(3.0));
67+
test_eq!(unsafe { round_ties_even_f64(g) }, black_box(-3.0));
68+
test_eq!(unsafe { round_ties_even_f64(h) }, black_box(4.0));
69+
test_eq!(unsafe { round_ties_even_f64(i) }, black_box(4.0));
7670
let f = 3.3_f32;
7771
let g = -3.3_f32;
7872
let h = -3.7_f32;

0 commit comments

Comments
 (0)