Skip to content

Commit d36bde7

Browse files
committed
Auto merge of rust-lang#109128 - chenyukang:yukang/remove-type-ascription, r=estebank
Remove type ascription from parser and diagnostics Mostly based on rust-lang#106826 Part of rust-lang#101728 r? `@estebank`
2 parents eac589b + d4baabe commit d36bde7

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

clippy_utils/src/sugg.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ impl<'a> Sugg<'a> {
163163
get_snippet(rhs.span),
164164
),
165165
hir::ExprKind::Cast(lhs, ty) => Sugg::BinOp(AssocOp::As, get_snippet(lhs.span), get_snippet(ty.span)),
166-
hir::ExprKind::Type(lhs, ty) => Sugg::BinOp(AssocOp::Colon, get_snippet(lhs.span), get_snippet(ty.span)),
166+
//FIXME(chenyukang), remove this after type ascription is removed from AST
167+
hir::ExprKind::Type(lhs, ty) => Sugg::BinOp(AssocOp::As, get_snippet(lhs.span), get_snippet(ty.span)),
167168
}
168169
}
169170

@@ -258,8 +259,9 @@ impl<'a> Sugg<'a> {
258259
snippet_with_context(cx, lhs.span, ctxt, default, app).0,
259260
snippet_with_context(cx, ty.span, ctxt, default, app).0,
260261
),
262+
//FIXME(chenyukang), remove this after type ascription is removed from AST
261263
ast::ExprKind::Type(ref lhs, ref ty) => Sugg::BinOp(
262-
AssocOp::Colon,
264+
AssocOp::As,
263265
snippet_with_context(cx, lhs.span, ctxt, default, app).0,
264266
snippet_with_context(cx, ty.span, ctxt, default, app).0,
265267
),
@@ -392,7 +394,6 @@ fn binop_to_string(op: AssocOp, lhs: &str, rhs: &str) -> String {
392394
AssocOp::As => format!("{lhs} as {rhs}"),
393395
AssocOp::DotDot => format!("{lhs}..{rhs}"),
394396
AssocOp::DotDotEq => format!("{lhs}..={rhs}"),
395-
AssocOp::Colon => format!("{lhs}: {rhs}"),
396397
}
397398
}
398399

@@ -602,13 +603,13 @@ enum Associativity {
602603
#[must_use]
603604
fn associativity(op: AssocOp) -> Associativity {
604605
use rustc_ast::util::parser::AssocOp::{
605-
Add, As, Assign, AssignOp, BitAnd, BitOr, BitXor, Colon, Divide, DotDot, DotDotEq, Equal, Greater,
606+
Add, As, Assign, AssignOp, BitAnd, BitOr, BitXor, Divide, DotDot, DotDotEq, Equal, Greater,
606607
GreaterEqual, LAnd, LOr, Less, LessEqual, Modulus, Multiply, NotEqual, ShiftLeft, ShiftRight, Subtract,
607608
};
608609

609610
match op {
610611
Assign | AssignOp(_) => Associativity::Right,
611-
Add | BitAnd | BitOr | BitXor | LAnd | LOr | Multiply | As | Colon => Associativity::Both,
612+
Add | BitAnd | BitOr | BitXor | LAnd | LOr | Multiply | As => Associativity::Both,
612613
Divide | Equal | Greater | GreaterEqual | Less | LessEqual | Modulus | NotEqual | ShiftLeft | ShiftRight
613614
| Subtract => Associativity::Left,
614615
DotDot | DotDotEq => Associativity::None,

0 commit comments

Comments
 (0)