@@ -25,18 +25,18 @@ pub enum CExprKind {
2525 Literal ( CQualTypeId , CLiteral ) ,
2626
2727 /// Unary operator.
28- Unary ( CQualTypeId , UnOp , CExprId , LRValue ) ,
28+ Unary ( CQualTypeId , CUnOp , CExprId , LRValue ) ,
2929
3030 /// Unary type operator.
31- UnaryType ( CQualTypeId , UnTypeOp , Option < CExprId > , CQualTypeId ) ,
31+ UnaryType ( CQualTypeId , CUnTypeOp , Option < CExprId > , CQualTypeId ) ,
3232
3333 /// `offsetof` expression.
3434 OffsetOf ( CQualTypeId , OffsetOfKind ) ,
3535
3636 /// Binary operator.
3737 Binary (
3838 CQualTypeId ,
39- BinOp ,
39+ CBinOp ,
4040 CExprId ,
4141 CExprId ,
4242 Option < CQualTypeId > ,
@@ -307,7 +307,7 @@ impl CastKind {
307307
308308/// Represents a unary operator in C (6.5.3 Unary operators) and GNU C extensions
309309#[ derive( Debug , Clone , Copy ) ]
310- pub enum UnOp {
310+ pub enum CUnOp {
311311 AddressOf , // &x
312312 Deref , // *x
313313 Plus , // +x
@@ -324,9 +324,9 @@ pub enum UnOp {
324324 Coawait , // [C++ Coroutines] co_await x
325325}
326326
327- impl UnOp {
327+ impl CUnOp {
328328 pub fn as_str ( & self ) -> & ' static str {
329- use UnOp :: * ;
329+ use CUnOp :: * ;
330330 match self {
331331 AddressOf => "&" ,
332332 Deref => "*" ,
@@ -351,7 +351,7 @@ impl UnOp {
351351 ast_context : & TypedAstContext ,
352352 arg_type : CQualTypeId ,
353353 ) -> Option < CQualTypeId > {
354- use UnOp :: * ;
354+ use CUnOp :: * ;
355355 let resolved_ty = ast_context. resolve_type ( arg_type. ctype ) ;
356356 Some ( match self {
357357 // We could construct CTypeKind::Pointer here, but it is not guaranteed to have a
@@ -382,23 +382,23 @@ impl UnOp {
382382 }
383383}
384384
385- impl Display for UnOp {
385+ impl Display for CUnOp {
386386 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
387387 write ! ( f, "{}" , self . as_str( ) )
388388 }
389389}
390390
391391/// Represents a unary type operator in C
392392#[ derive( Debug , Clone , Copy ) ]
393- pub enum UnTypeOp {
393+ pub enum CUnTypeOp {
394394 SizeOf ,
395395 AlignOf ,
396396 PreferredAlignOf ,
397397}
398398
399- impl UnTypeOp {
399+ impl CUnTypeOp {
400400 pub fn as_str ( & self ) -> & ' static str {
401- use UnTypeOp :: * ;
401+ use CUnTypeOp :: * ;
402402 match self {
403403 SizeOf => "sizeof" ,
404404 AlignOf => "alignof" ,
@@ -407,22 +407,22 @@ impl UnTypeOp {
407407 }
408408}
409409
410- impl Display for UnTypeOp {
410+ impl Display for CUnTypeOp {
411411 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
412412 write ! ( f, "{}" , self . as_str( ) )
413413 }
414414}
415415
416- impl UnOp {
416+ impl CUnOp {
417417 /// Check is the operator is rendered before or after is operand.
418418 pub fn is_prefix ( & self ) -> bool {
419- !matches ! ( * self , UnOp :: PostIncrement | UnOp :: PostDecrement )
419+ !matches ! ( * self , CUnOp :: PostIncrement | CUnOp :: PostDecrement )
420420 }
421421}
422422
423423/// Represents a binary operator in C (6.5.5 Multiplicative operators - 6.5.14 Logical OR operator)
424424#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
425- pub enum BinOp {
425+ pub enum CBinOp {
426426 Multiply , // *
427427 Divide , // /
428428 Modulus , // %
@@ -457,9 +457,9 @@ pub enum BinOp {
457457 Comma , // ,
458458}
459459
460- impl BinOp {
460+ impl CBinOp {
461461 pub fn as_str ( & self ) -> & ' static str {
462- use BinOp :: * ;
462+ use CBinOp :: * ;
463463 match self {
464464 Multiply => "*" ,
465465 Divide => "/" ,
@@ -499,7 +499,7 @@ impl BinOp {
499499 /// Does the rust equivalent of this operator have type (T, T) -> U?
500500 #[ rustfmt:: skip]
501501 pub fn input_types_same ( & self ) -> bool {
502- use BinOp :: * ;
502+ use CBinOp :: * ;
503503 self . all_types_same ( ) || matches ! ( self ,
504504 Less | Greater | LessEqual | GreaterEqual | EqualEqual | NotEqual
505505 | And | Or
@@ -512,27 +512,27 @@ impl BinOp {
512512 /// Does the rust equivalent of this operator have type (T, T) -> T?
513513 /// This ignores cases where one argument is a pointer and we translate to `.offset()`.
514514 pub fn all_types_same ( & self ) -> bool {
515- use BinOp :: * ;
515+ use CBinOp :: * ;
516516 matches ! (
517517 self ,
518518 Multiply | Divide | Modulus | Add | Subtract | BitAnd | BitXor | BitOr
519519 )
520520 }
521521}
522522
523- impl Display for BinOp {
523+ impl Display for CBinOp {
524524 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
525525 write ! ( f, "{}" , self . as_str( ) )
526526 }
527527}
528528
529- impl BinOp {
529+ impl CBinOp {
530530 /// Maps compound assignment operators to operator underlying them, and returns `None` for all
531531 /// other operators.
532532 ///
533533 /// For example, `AssignAdd` maps to `Some(Add)` but `Add` maps to `None`.
534- pub fn underlying_assignment ( & self ) -> Option < BinOp > {
535- use BinOp :: * ;
534+ pub fn underlying_assignment ( & self ) -> Option < CBinOp > {
535+ use CBinOp :: * ;
536536 Some ( match * self {
537537 AssignAdd => Add ,
538538 AssignSubtract => Subtract ,
@@ -623,7 +623,7 @@ impl TypedAstContext {
623623
624624 /// Returns the expression inside an `__extension__` operator.
625625 pub fn resolve_extension ( & self , expr_id : CExprId ) -> CExprId {
626- if let CExprKind :: Unary ( _, UnOp :: Extension , subexpr, _) = self . index ( expr_id) . kind {
626+ if let CExprKind :: Unary ( _, CUnOp :: Extension , subexpr, _) = self . index ( expr_id) . kind {
627627 subexpr
628628 } else {
629629 expr_id
@@ -730,11 +730,11 @@ impl TypedAstContext {
730730 ShuffleVector ( ..) |
731731 ConvertVector ( ..) |
732732 Call ( ..) |
733- Unary ( _, UnOp :: PreIncrement , _, _) |
734- Unary ( _, UnOp :: PostIncrement , _, _) |
735- Unary ( _, UnOp :: PreDecrement , _, _) |
736- Unary ( _, UnOp :: PostDecrement , _, _) |
737- Binary ( _, BinOp :: Assign , _, _, _, _) |
733+ Unary ( _, CUnOp :: PreIncrement , _, _) |
734+ Unary ( _, CUnOp :: PostIncrement , _, _) |
735+ Unary ( _, CUnOp :: PreDecrement , _, _) |
736+ Unary ( _, CUnOp :: PostDecrement , _, _) |
737+ Binary ( _, CBinOp :: Assign , _, _, _, _) |
738738 InitList { .. } |
739739 ImplicitValueInit { .. } |
740740 Predefined ( ..) |
@@ -810,8 +810,8 @@ impl TypedAstContext {
810810 UnaryType ( _, _, expr, _) => expr. map_or ( true , is_const) ,
811811 // Not sure what a `OffsetOfKind::Variable` means.
812812 OffsetOf ( _, _) => true ,
813- // `ptr::offset` (ptr `BinOp ::Add`) was `const` stabilized in `1.61.0`.
814- // `ptr::offset_from` (ptr `BinOp ::Subtract`) was `const` stabilized in `1.65.0`.
813+ // `ptr::offset` (ptr `CBinOp ::Add`) was `const` stabilized in `1.61.0`.
814+ // `ptr::offset_from` (ptr `CBinOp ::Subtract`) was `const` stabilized in `1.65.0`.
815815 // TODO `f128` is not yet handled, as we should eventually
816816 // switch to the (currently unstable) `f128` primitive type (#1262).
817817 Binary ( _, _, lhs, rhs, _, _) => is_const ( lhs) && is_const ( rhs) ,
0 commit comments