about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-12-19 21:46:44 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2025-02-27 09:53:18 +1100
commit537577f79a694a289a4a7ae462a712fd76c18cf3 (patch)
tree98168fa92632157df4df323938ae9bc55f72b260
parent6db6a4f4a7b86e4444153ec1fcaac505ce919b87 (diff)
downloadrust-537577f79a694a289a4a7ae462a712fd76c18cf3.tar.gz
rust-537577f79a694a289a4a7ae462a712fd76c18cf3.zip
Rename `AssocOp::As` as `AssocOp::Cast`.
To match `ExprKind::Cast`, and because a semantic name makes more sense
here than a syntactic name.
-rw-r--r--clippy_utils/src/sugg.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/clippy_utils/src/sugg.rs b/clippy_utils/src/sugg.rs
index fe5ae54fe50..4a9ab17d4a6 100644
--- a/clippy_utils/src/sugg.rs
+++ b/clippy_utils/src/sugg.rs
@@ -163,7 +163,7 @@ impl<'a> Sugg<'a> {
             ),
             ExprKind::Cast(lhs, ty) |
             //FIXME(chenyukang), remove this after type ascription is removed from AST
-            ExprKind::Type(lhs, ty) => Sugg::BinOp(AssocOp::As, get_snippet(lhs.span), get_snippet(ty.span)),
+            ExprKind::Type(lhs, ty) => Sugg::BinOp(AssocOp::Cast, get_snippet(lhs.span), get_snippet(ty.span)),
         }
     }
 
@@ -246,7 +246,7 @@ impl<'a> Sugg<'a> {
             ast::ExprKind::Cast(ref lhs, ref ty) |
             //FIXME(chenyukang), remove this after type ascription is removed from AST
             ast::ExprKind::Type(ref lhs, ref ty) => Sugg::BinOp(
-                AssocOp::As,
+                AssocOp::Cast,
                 snippet(lhs.span),
                 snippet(ty.span),
             ),
@@ -265,7 +265,7 @@ impl<'a> Sugg<'a> {
 
     /// Convenience method to create the `<lhs> as <rhs>` suggestion.
     pub fn as_ty<R: Display>(self, rhs: R) -> Sugg<'static> {
-        make_assoc(AssocOp::As, &self, &Sugg::NonParen(rhs.to_string().into()))
+        make_assoc(AssocOp::Cast, &self, &Sugg::NonParen(rhs.to_string().into()))
     }
 
     /// Convenience method to create the `&<expr>` suggestion.
@@ -356,7 +356,7 @@ fn binop_to_string(op: AssocOp, lhs: &str, rhs: &str) -> String {
         AssocOp::Binary(op) => format!("{lhs} {} {rhs}", op.as_str()),
         AssocOp::Assign => format!("{lhs} = {rhs}"),
         AssocOp::AssignOp(op) => format!("{lhs} {}= {rhs}", op.as_str()),
-        AssocOp::As => format!("{lhs} as {rhs}"),
+        AssocOp::Cast => format!("{lhs} as {rhs}"),
         AssocOp::Range(limits) => format!("{lhs}{}{rhs}", limits.as_str()),
     }
 }
@@ -432,7 +432,7 @@ impl Neg for Sugg<'_> {
     type Output = Sugg<'static>;
     fn neg(self) -> Sugg<'static> {
         match &self {
-            Self::BinOp(AssocOp::As, ..) => Sugg::MaybeParen(format!("-({self})").into()),
+            Self::BinOp(AssocOp::Cast, ..) => Sugg::MaybeParen(format!("-({self})").into()),
             _ => make_unop("-", self),
         }
     }
@@ -576,14 +576,14 @@ enum Associativity {
 /// associative.
 #[must_use]
 fn associativity(op: AssocOp) -> Associativity {
-    use rustc_ast::util::parser::AssocOp::{As, Assign, AssignOp, Binary, Range};
+    use rustc_ast::util::parser::AssocOp::{Assign, AssignOp, Binary, Cast, Range};
     use ast::BinOpKind::{
         Add, BitAnd, BitOr, BitXor, Div, Eq, Gt, Ge, And, Or, Lt, Le, Rem, Mul, Ne, Shl, Shr, Sub,
     };
 
     match op {
         Assign | AssignOp(_) => Associativity::Right,
-        Binary(Add | BitAnd | BitOr | BitXor | And | Or | Mul) | As => Associativity::Both,
+        Binary(Add | BitAnd | BitOr | BitXor | And | Or | Mul) | Cast => Associativity::Both,
         Binary(Div | Eq | Gt | Ge | Lt | Le | Rem | Ne | Shl | Shr | Sub) => Associativity::Left,
         Range(_) => Associativity::None,
     }