@@ -31,39 +31,7 @@ impl OffloadMetadata {
3131// TODO(Sa4dUs): WIP, rn we just have a naive logic for references
3232fn get_payload_size < ' tcx > ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > ) -> u64 {
3333 match ty. kind ( ) {
34- /*
35- rustc_middle::infer::canonical::ir::TyKind::Bool => todo!(),
36- rustc_middle::infer::canonical::ir::TyKind::Char => todo!(),
37- rustc_middle::infer::canonical::ir::TyKind::Int(int_ty) => todo!(),
38- rustc_middle::infer::canonical::ir::TyKind::Uint(uint_ty) => todo!(),
39- rustc_middle::infer::canonical::ir::TyKind::Float(float_ty) => todo!(),
40- rustc_middle::infer::canonical::ir::TyKind::Adt(_, _) => todo!(),
41- rustc_middle::infer::canonical::ir::TyKind::Foreign(_) => todo!(),
42- rustc_middle::infer::canonical::ir::TyKind::Str => todo!(),
43- rustc_middle::infer::canonical::ir::TyKind::Array(_, _) => todo!(),
44- rustc_middle::infer::canonical::ir::TyKind::Pat(_, _) => todo!(),
45- rustc_middle::infer::canonical::ir::TyKind::Slice(_) => todo!(),
46- rustc_middle::infer::canonical::ir::TyKind::RawPtr(_, mutability) => todo!(),
47- */
48- ty:: Ref ( _, inner, _) => get_payload_size ( tcx, * inner) ,
49- /*
50- rustc_middle::infer::canonical::ir::TyKind::FnDef(_, _) => todo!(),
51- rustc_middle::infer::canonical::ir::TyKind::FnPtr(binder, fn_header) => todo!(),
52- rustc_middle::infer::canonical::ir::TyKind::UnsafeBinder(unsafe_binder_inner) => todo!(),
53- rustc_middle::infer::canonical::ir::TyKind::Dynamic(_, _) => todo!(),
54- rustc_middle::infer::canonical::ir::TyKind::Closure(_, _) => todo!(),
55- rustc_middle::infer::canonical::ir::TyKind::CoroutineClosure(_, _) => todo!(),
56- rustc_middle::infer::canonical::ir::TyKind::Coroutine(_, _) => todo!(),
57- rustc_middle::infer::canonical::ir::TyKind::CoroutineWitness(_, _) => todo!(),
58- rustc_middle::infer::canonical::ir::TyKind::Never => todo!(),
59- rustc_middle::infer::canonical::ir::TyKind::Tuple(_) => todo!(),
60- rustc_middle::infer::canonical::ir::TyKind::Alias(alias_ty_kind, alias_ty) => todo!(),
61- rustc_middle::infer::canonical::ir::TyKind::Param(_) => todo!(),
62- rustc_middle::infer::canonical::ir::TyKind::Bound(bound_var_index_kind, _) => todo!(),
63- rustc_middle::infer::canonical::ir::TyKind::Placeholder(_) => todo!(),
64- rustc_middle::infer::canonical::ir::TyKind::Infer(infer_ty) => todo!(),
65- rustc_middle::infer::canonical::ir::TyKind::Error(_) => todo!(),
66- */
34+ ty:: RawPtr ( inner, _) | ty:: Ref ( _, inner, _) => get_payload_size ( tcx, * inner) ,
6735 _ => tcx
6836 . layout_of ( PseudoCanonicalInput {
6937 typing_env : TypingEnv :: fully_monomorphized ( ) ,
@@ -79,44 +47,44 @@ impl TransferKind {
7947 pub fn from_ty < ' tcx > ( _tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > ) -> Self {
8048 // TODO(Sa4dUs): this logic is probs not fully correct, but it works for now
8149 match ty. kind ( ) {
82- rustc_type_ir :: TyKind :: Bool
83- | rustc_type_ir :: TyKind :: Char
84- | rustc_type_ir :: TyKind :: Int ( _)
85- | rustc_type_ir :: TyKind :: Uint ( _)
86- | rustc_type_ir :: TyKind :: Float ( _) => TransferKind :: ToGpu ,
50+ ty :: Bool
51+ | ty :: Char
52+ | ty :: Int ( _)
53+ | ty :: Uint ( _)
54+ | ty :: Float ( _) => TransferKind :: ToGpu ,
8755
88- rustc_type_ir :: TyKind :: Adt ( _, _)
89- | rustc_type_ir :: TyKind :: Tuple ( _)
90- | rustc_type_ir :: TyKind :: Array ( _, _) => TransferKind :: ToGpu ,
56+ ty :: Adt ( _, _)
57+ | ty :: Tuple ( _)
58+ | ty :: Array ( _, _) => TransferKind :: ToGpu ,
9159
92- rustc_type_ir :: TyKind :: RawPtr ( _, rustc_ast:: Mutability :: Not )
93- | rustc_type_ir :: TyKind :: Ref ( _, _, rustc_ast:: Mutability :: Not ) => TransferKind :: ToGpu ,
60+ ty :: RawPtr ( _, rustc_ast:: Mutability :: Not )
61+ | ty :: Ref ( _, _, rustc_ast:: Mutability :: Not ) => TransferKind :: ToGpu ,
9462
95- rustc_type_ir :: TyKind :: RawPtr ( _, rustc_ast:: Mutability :: Mut )
96- | rustc_type_ir :: TyKind :: Ref ( _, _, rustc_ast:: Mutability :: Mut ) => TransferKind :: Both ,
63+ ty :: RawPtr ( _, rustc_ast:: Mutability :: Mut )
64+ | ty :: Ref ( _, _, rustc_ast:: Mutability :: Mut ) => TransferKind :: Both ,
9765
98- rustc_type_ir :: TyKind :: Slice ( _)
99- | rustc_type_ir :: TyKind :: Str
100- | rustc_type_ir :: TyKind :: Dynamic ( _, _) => TransferKind :: Both ,
66+ ty :: Slice ( _)
67+ | ty :: Str
68+ | ty :: Dynamic ( _, _) => TransferKind :: Both ,
10169
102- rustc_type_ir :: TyKind :: FnDef ( _, _)
103- | rustc_type_ir :: TyKind :: FnPtr ( _, _)
104- | rustc_type_ir :: TyKind :: Closure ( _, _)
105- | rustc_type_ir :: TyKind :: CoroutineClosure ( _, _)
106- | rustc_type_ir :: TyKind :: Coroutine ( _, _)
107- | rustc_type_ir :: TyKind :: CoroutineWitness ( _, _) => TransferKind :: ToGpu ,
70+ ty :: FnDef ( _, _)
71+ | ty :: FnPtr ( _, _)
72+ | ty :: Closure ( _, _)
73+ | ty :: CoroutineClosure ( _, _)
74+ | ty :: Coroutine ( _, _)
75+ | ty :: CoroutineWitness ( _, _) => TransferKind :: ToGpu ,
10876
109- rustc_type_ir :: TyKind :: Alias ( _, _)
110- | rustc_type_ir :: TyKind :: Param ( _)
111- | rustc_type_ir :: TyKind :: Bound ( _, _)
112- | rustc_type_ir :: TyKind :: Placeholder ( _)
113- | rustc_type_ir :: TyKind :: Infer ( _)
114- | rustc_type_ir :: TyKind :: Error ( _) => TransferKind :: ToGpu ,
77+ ty :: Alias ( _, _)
78+ | ty :: Param ( _)
79+ | ty :: Bound ( _, _)
80+ | ty :: Placeholder ( _)
81+ | ty :: Infer ( _)
82+ | ty :: Error ( _) => TransferKind :: ToGpu ,
11583
116- rustc_type_ir :: TyKind :: Never => TransferKind :: ToGpu ,
117- rustc_type_ir :: TyKind :: Foreign ( _) => TransferKind :: Both ,
118- rustc_type_ir :: TyKind :: Pat ( _, _) => TransferKind :: Both ,
119- rustc_type_ir :: TyKind :: UnsafeBinder ( _) => TransferKind :: Both ,
84+ ty :: Never => TransferKind :: ToGpu ,
85+ ty :: Foreign ( _) => TransferKind :: Both ,
86+ ty :: Pat ( _, _) => TransferKind :: Both ,
87+ ty :: UnsafeBinder ( _) => TransferKind :: Both ,
12088 }
12189 }
12290}
0 commit comments