From 1e147b41775e21777b2925f95c5d9b7d34dca10d Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 13 Dec 2023 17:06:45 +0000 Subject: [PATCH] Remove LArrow --- compiler/rustc_ast/src/token.rs | 12 ++++-------- compiler/rustc_ast/src/util/parser.rs | 2 -- compiler/rustc_ast_pretty/src/pprust/state.rs | 1 - compiler/rustc_expand/src/proc_macro_server.rs | 1 - compiler/rustc_parse/src/parser/expr.rs | 8 -------- compiler/rustc_parse/src/parser/path.rs | 5 +---- 6 files changed, 5 insertions(+), 24 deletions(-) diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index b0cd2ec981592..1044c167a05e9 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -274,8 +274,6 @@ pub enum TokenKind { ModSep, /// `->` RArrow, - /// `<-` - LArrow, /// `=>` FatArrow, /// `#` @@ -376,7 +374,6 @@ impl TokenKind { DotDotDot => (Dot, DotDot), ModSep => (Colon, Colon), RArrow => (BinOp(Minus), Gt), - LArrow => (Lt, BinOp(Minus)), FatArrow => (Eq, Gt), _ => return None, }) @@ -435,7 +432,7 @@ impl Token { match self.kind { Eq | Lt | Le | EqEq | Ne | Ge | Gt | AndAnd | OrOr | Not | Tilde | BinOp(_) | BinOpEq(_) | At | Dot | DotDot | DotDotDot | DotDotEq | Comma | Semi | Colon - | ModSep | RArrow | LArrow | FatArrow | Pound | Dollar | Question | SingleQuote => true, + | ModSep | RArrow | FatArrow | Pound | Dollar | Question | SingleQuote => true, OpenDelim(..) | CloseDelim(..) | Literal(..) | DocComment(..) | Ident(..) | Lifetime(..) | Interpolated(..) | Eof => false, @@ -780,7 +777,6 @@ impl Token { Eq => Le, Lt => BinOp(Shl), Le => BinOpEq(Shl), - BinOp(Minus) => LArrow, _ => return None, }, Gt => match joint.kind { @@ -820,9 +816,9 @@ impl Token { }, Le | EqEq | Ne | Ge | AndAnd | OrOr | Tilde | BinOpEq(..) | At | DotDotDot - | DotDotEq | Comma | Semi | ModSep | RArrow | LArrow | FatArrow | Pound | Dollar - | Question | OpenDelim(..) | CloseDelim(..) | Literal(..) | Ident(..) - | Lifetime(..) | Interpolated(..) | DocComment(..) | Eof => return None, + | DotDotEq | Comma | Semi | ModSep | RArrow | FatArrow | Pound | Dollar | Question + | OpenDelim(..) | CloseDelim(..) | Literal(..) | Ident(..) | Lifetime(..) + | Interpolated(..) | DocComment(..) | Eof => return None, }; Some(Token::new(kind, self.span.to(joint.span))) diff --git a/compiler/rustc_ast/src/util/parser.rs b/compiler/rustc_ast/src/util/parser.rs index 13768c1201791..13a06b91af446 100644 --- a/compiler/rustc_ast/src/util/parser.rs +++ b/compiler/rustc_ast/src/util/parser.rs @@ -94,8 +94,6 @@ impl AssocOp { token::DotDotEq => Some(DotDotEq), // DotDotDot is no longer supported, but we need some way to display the error token::DotDotDot => Some(DotDotEq), - // `<-` should probably be `< -` - token::LArrow => Some(Less), _ if t.is_keyword(kw::As) => Some(As), _ => None, } diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index 4a2a693862b13..20bf9f4c58c9e 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -758,7 +758,6 @@ pub trait PrintState<'a>: std::ops::Deref + std::ops::Dere token::Colon => ":".into(), token::ModSep => "::".into(), token::RArrow => "->".into(), - token::LArrow => "<-".into(), token::FatArrow => "=>".into(), token::OpenDelim(Delimiter::Parenthesis) => "(".into(), token::CloseDelim(Delimiter::Parenthesis) => ")".into(), diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs index 5308e338d7f8b..77790f99d3667 100644 --- a/compiler/rustc_expand/src/proc_macro_server.rs +++ b/compiler/rustc_expand/src/proc_macro_server.rs @@ -195,7 +195,6 @@ impl FromInternal<(TokenStream, &mut Rustc<'_, '_>)> for Vec op(":"), ModSep => op("::"), RArrow => op("->"), - LArrow => op("<-"), FatArrow => op("=>"), Pound => op("#"), Dollar => op("$"), diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 509cef9826bb4..30c08fe19edee 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -214,10 +214,6 @@ impl<'a> Parser<'a> { self.err_dotdotdot_syntax(self.token.span); } - if self.token == token::LArrow { - self.err_larrow_operator(self.token.span); - } - self.bump(); if op.node.is_comparison() { if let Some(expr) = self.check_no_chained_comparison(&lhs, &op)? { @@ -3583,10 +3579,6 @@ impl<'a> Parser<'a> { self.sess.emit_err(errors::DotDotDot { span }); } - fn err_larrow_operator(&self, span: Span) { - self.sess.emit_err(errors::LeftArrowOperator { span }); - } - fn mk_assign_op(&self, binop: BinOp, lhs: P, rhs: P) -> ExprKind { ExprKind::AssignOp(binop, lhs, rhs) } diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index 0f4ba9617c687..93aba644e3347 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -272,10 +272,7 @@ impl<'a> Parser<'a> { let is_args_start = |token: &Token| { matches!( token.kind, - token::Lt - | token::BinOp(token::Shl) - | token::OpenDelim(Delimiter::Parenthesis) - | token::LArrow + token::Lt | token::BinOp(token::Shl) | token::OpenDelim(Delimiter::Parenthesis) ) }; let check_args_start = |this: &mut Self| {