File tree Expand file tree Collapse file tree
c2rust-transpile/src/translator Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2967,7 +2967,11 @@ impl<'c> Translation<'c> {
29672967 if ctx. is_pattern
29682968 && !matches ! (
29692969 expr_kind,
2970- CExprKind :: Paren ( ..) | CExprKind :: ConstantExpr ( ..) | CExprKind :: Literal ( ..)
2970+ CExprKind :: Paren ( ..)
2971+ | CExprKind :: ConstantExpr ( ..)
2972+ | CExprKind :: Literal ( ..)
2973+ | CExprKind :: ImplicitCast ( ..)
2974+ | CExprKind :: ExplicitCast ( ..)
29712975 )
29722976 {
29732977 return Err ( TranslationError :: generic (
@@ -3698,6 +3702,12 @@ impl<'c> Translation<'c> {
36983702 return Ok ( val) ;
36993703 }
37003704
3705+ if ctx. is_pattern && !matches ! ( kind, CastKind :: ToVoid | CastKind :: ConstCast ) {
3706+ return Err ( TranslationError :: generic (
3707+ "cast kind is not supported in patterns" ,
3708+ ) ) ;
3709+ }
3710+
37013711 match kind {
37023712 CastKind :: BitCast | CastKind :: NoOp => {
37033713 self . convert_pointer_to_pointer_cast ( source_cty. ctype , target_cty. ctype , val)
You can’t perform that action at this time.
0 commit comments