Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 537577f

Browse files
committed
Rename AssocOp::As as AssocOp::Cast.
To match `ExprKind::Cast`, and because a semantic name makes more sense here than a syntactic name.
1 parent 6db6a4f commit 537577f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

clippy_utils/src/sugg.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ impl<'a> Sugg<'a> {
163163
),
164164
ExprKind::Cast(lhs, ty) |
165165
//FIXME(chenyukang), remove this after type ascription is removed from AST
166-
ExprKind::Type(lhs, ty) => Sugg::BinOp(AssocOp::As, get_snippet(lhs.span), get_snippet(ty.span)),
166+
ExprKind::Type(lhs, ty) => Sugg::BinOp(AssocOp::Cast, get_snippet(lhs.span), get_snippet(ty.span)),
167167
}
168168
}
169169

@@ -246,7 +246,7 @@ impl<'a> Sugg<'a> {
246246
ast::ExprKind::Cast(ref lhs, ref ty) |
247247
//FIXME(chenyukang), remove this after type ascription is removed from AST
248248
ast::ExprKind::Type(ref lhs, ref ty) => Sugg::BinOp(
249-
AssocOp::As,
249+
AssocOp::Cast,
250250
snippet(lhs.span),
251251
snippet(ty.span),
252252
),
@@ -265,7 +265,7 @@ impl<'a> Sugg<'a> {
265265

266266
/// Convenience method to create the `<lhs> as <rhs>` suggestion.
267267
pub fn as_ty<R: Display>(self, rhs: R) -> Sugg<'static> {
268-
make_assoc(AssocOp::As, &self, &Sugg::NonParen(rhs.to_string().into()))
268+
make_assoc(AssocOp::Cast, &self, &Sugg::NonParen(rhs.to_string().into()))
269269
}
270270

271271
/// Convenience method to create the `&<expr>` suggestion.
@@ -356,7 +356,7 @@ fn binop_to_string(op: AssocOp, lhs: &str, rhs: &str) -> String {
356356
AssocOp::Binary(op) => format!("{lhs} {} {rhs}", op.as_str()),
357357
AssocOp::Assign => format!("{lhs} = {rhs}"),
358358
AssocOp::AssignOp(op) => format!("{lhs} {}= {rhs}", op.as_str()),
359-
AssocOp::As => format!("{lhs} as {rhs}"),
359+
AssocOp::Cast => format!("{lhs} as {rhs}"),
360360
AssocOp::Range(limits) => format!("{lhs}{}{rhs}", limits.as_str()),
361361
}
362362
}
@@ -432,7 +432,7 @@ impl Neg for Sugg<'_> {
432432
type Output = Sugg<'static>;
433433
fn neg(self) -> Sugg<'static> {
434434
match &self {
435-
Self::BinOp(AssocOp::As, ..) => Sugg::MaybeParen(format!("-({self})").into()),
435+
Self::BinOp(AssocOp::Cast, ..) => Sugg::MaybeParen(format!("-({self})").into()),
436436
_ => make_unop("-", self),
437437
}
438438
}
@@ -576,14 +576,14 @@ enum Associativity {
576576
/// associative.
577577
#[must_use]
578578
fn associativity(op: AssocOp) -> Associativity {
579-
use rustc_ast::util::parser::AssocOp::{As, Assign, AssignOp, Binary, Range};
579+
use rustc_ast::util::parser::AssocOp::{Assign, AssignOp, Binary, Cast, Range};
580580
use ast::BinOpKind::{
581581
Add, BitAnd, BitOr, BitXor, Div, Eq, Gt, Ge, And, Or, Lt, Le, Rem, Mul, Ne, Shl, Shr, Sub,
582582
};
583583

584584
match op {
585585
Assign | AssignOp(_) => Associativity::Right,
586-
Binary(Add | BitAnd | BitOr | BitXor | And | Or | Mul) | As => Associativity::Both,
586+
Binary(Add | BitAnd | BitOr | BitXor | And | Or | Mul) | Cast => Associativity::Both,
587587
Binary(Div | Eq | Gt | Ge | Lt | Le | Rem | Ne | Shl | Shr | Sub) => Associativity::Left,
588588
Range(_) => Associativity::None,
589589
}

0 commit comments

Comments
 (0)