@@ -923,6 +923,44 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
923
923
}
924
924
}
925
925
}
926
+ AggregateKind :: RawPtr ( pointee_ty, mutability) => {
927
+ if !matches ! ( self . mir_phase, MirPhase :: Runtime ( _) ) {
928
+ // It would probably be fine to support this in earlier phases,
929
+ // but at the time of writing it's only ever introduced from intrinsic lowering,
930
+ // so earlier things just `bug!` on it.
931
+ self . fail ( location, "RawPtr should be in runtime MIR only" ) ;
932
+ }
933
+
934
+ if fields. len ( ) != 2 {
935
+ self . fail ( location, "raw pointer aggregate must have 2 fields" ) ;
936
+ } else {
937
+ let data_ptr_ty = fields. raw [ 0 ] . ty ( self . body , self . tcx ) ;
938
+ let metadata_ty = fields. raw [ 1 ] . ty ( self . body , self . tcx ) ;
939
+ if let ty:: RawPtr ( in_pointee, in_mut) = data_ptr_ty. kind ( ) {
940
+ if * in_mut != mutability {
941
+ self . fail ( location, "input and output mutability must match" ) ;
942
+ }
943
+
944
+ // FIXME: check `Thin` instead of `Sized`
945
+ if !in_pointee. is_sized ( self . tcx , self . param_env ) {
946
+ self . fail ( location, "input pointer must be thin" ) ;
947
+ }
948
+ } else {
949
+ self . fail ( location, "first operand to raw pointer aggregate must be a raw pointer" ) ;
950
+ }
951
+
952
+ // FIXME: Check metadata more generally
953
+ if pointee_ty. is_slice ( ) {
954
+ if !self . mir_assign_valid_types ( metadata_ty, self . tcx . types . usize ) {
955
+ self . fail ( location, "slice metadata must be usize" ) ;
956
+ }
957
+ } else if pointee_ty. is_sized ( self . tcx , self . param_env ) {
958
+ if metadata_ty != self . tcx . types . unit {
959
+ self . fail ( location, "metadata for pointer-to-thin must be unit" ) ;
960
+ }
961
+ }
962
+ }
963
+ }
926
964
} ,
927
965
Rvalue :: Ref ( _, BorrowKind :: Fake , _) => {
928
966
if self . mir_phase >= MirPhase :: Runtime ( RuntimePhase :: Initial ) {
0 commit comments