Skip to content

Commit

Permalink
Remove ObsoleteInPlace
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed May 18, 2019
1 parent 0f40ad9 commit 650c1c3
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 81 deletions.
4 changes: 0 additions & 4 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4064,10 +4064,6 @@ impl<'a> LoweringContext<'a> {
fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
let kind = match e.node {
ExprKind::Box(ref inner) => hir::ExprKind::Box(P(self.lower_expr(inner))),
ExprKind::ObsoleteInPlace(..) => {
self.sess.abort_if_errors();
span_bug!(e.span, "encountered ObsoleteInPlace expr during lowering");
}
ExprKind::Array(ref exprs) => {
hir::ExprKind::Array(exprs.iter().map(|x| self.lower_expr(x)).collect())
}
Expand Down
23 changes: 0 additions & 23 deletions src/librustc_passes/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,29 +454,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
ExprKind::InlineAsm(..) if !self.session.target.target.options.allow_asm => {
span_err!(self.session, expr.span, E0472, "asm! is unsupported on this target");
}
ExprKind::ObsoleteInPlace(ref place, ref val) => {
let mut err = self.err_handler().struct_span_err(
expr.span,
"emplacement syntax is obsolete (for now, anyway)",
);
err.note(
"for more information, see \
<https://github.com/rust-lang/rust/issues/27779#issuecomment-378416911>"
);
match val.node {
ExprKind::Lit(ref v) if v.node.is_numeric() => {
err.span_suggestion(
place.span.between(val.span),
"if you meant to write a comparison against a negative value, add a \
space in between `<` and `-`",
"< -".to_string(),
Applicability::MaybeIncorrect
);
}
_ => {}
}
err.emit();
}
_ => {}
}

Expand Down
3 changes: 0 additions & 3 deletions src/libsyntax/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,6 @@ impl Expr {
pub fn precedence(&self) -> ExprPrecedence {
match self.node {
ExprKind::Box(_) => ExprPrecedence::Box,
ExprKind::ObsoleteInPlace(..) => ExprPrecedence::ObsoleteInPlace,
ExprKind::Array(_) => ExprPrecedence::Array,
ExprKind::Call(..) => ExprPrecedence::Call,
ExprKind::MethodCall(..) => ExprPrecedence::MethodCall,
Expand Down Expand Up @@ -1102,8 +1101,6 @@ pub enum RangeLimits {
pub enum ExprKind {
/// A `box x` expression.
Box(P<Expr>),
/// First expr is the place; second expr is the value.
ObsoleteInPlace(P<Expr>, P<Expr>),
/// An array (`[a, b, c, d]`)
Array(Vec<P<Expr>>),
/// A function call
Expand Down
3 changes: 0 additions & 3 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2110,9 +2110,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
"type ascription is experimental");
}
}
ast::ExprKind::ObsoleteInPlace(..) => {
// these get a hard error in ast-validation
}
ast::ExprKind::Yield(..) => {
gate_feature_post!(&self, generators,
e.span,
Expand Down
4 changes: 0 additions & 4 deletions src/libsyntax/mut_visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,10 +1096,6 @@ pub fn noop_visit_anon_const<T: MutVisitor>(AnonConst { id, value }: &mut AnonCo
pub fn noop_visit_expr<T: MutVisitor>(Expr { node, id, span, attrs }: &mut Expr, vis: &mut T) {
match node {
ExprKind::Box(expr) => vis.visit_expr(expr),
ExprKind::ObsoleteInPlace(a, b) => {
vis.visit_expr(a);
vis.visit_expr(b);
}
ExprKind::Array(exprs) => visit_exprs(exprs, vis),
ExprKind::Repeat(expr, count) => {
vis.visit_expr(expr);
Expand Down
24 changes: 1 addition & 23 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1058,8 +1058,7 @@ impl<'a> Parser<'a> {
}

/// Attempts to consume a `<`. If `<<` is seen, replaces it with a single
/// `<` and continue. If `<-` is seen, replaces it with a single `<`
/// and continue. If a `<` is not seen, returns false.
/// `<` and continue. If a `<` is not seen, returns false.
///
/// This is meant to be used when parsing generics on a path to get the
/// starting token.
Expand All @@ -1075,11 +1074,6 @@ impl<'a> Parser<'a> {
self.bump_with(token::Lt, span);
true
}
token::LArrow => {
let span = self.span.with_lo(self.span.lo() + BytePos(1));
self.bump_with(token::BinOp(token::Minus), span);
true
}
_ => false,
};

Expand Down Expand Up @@ -3250,17 +3244,6 @@ impl<'a> Parser<'a> {
let (span, e) = self.interpolated_or_expr_span(e)?;
(lo.to(span), ExprKind::AddrOf(m, e))
}
token::Ident(..) if self.token.is_keyword(keywords::In) => {
self.bump();
let place = self.parse_expr_res(
Restrictions::NO_STRUCT_LITERAL,
None,
)?;
let blk = self.parse_block()?;
let span = blk.span;
let blk_expr = self.mk_expr(span, ExprKind::Block(blk, None), ThinVec::new());
(lo.to(span), ExprKind::ObsoleteInPlace(place, blk_expr))
}
token::Ident(..) if self.token.is_keyword(keywords::Box) => {
self.bump();
let e = self.parse_prefix_expr(None);
Expand Down Expand Up @@ -3498,8 +3481,6 @@ impl<'a> Parser<'a> {
self.mk_expr(span, binary, ThinVec::new())
}
AssocOp::Assign => self.mk_expr(span, ExprKind::Assign(lhs, rhs), ThinVec::new()),
AssocOp::ObsoleteInPlace =>
self.mk_expr(span, ExprKind::ObsoleteInPlace(lhs, rhs), ThinVec::new()),
AssocOp::AssignOp(k) => {
let aop = match k {
token::Plus => BinOpKind::Add,
Expand Down Expand Up @@ -3818,9 +3799,6 @@ impl<'a> Parser<'a> {
String::new(),
Applicability::MachineApplicable,
);
err.note("if you meant to use emplacement syntax, it is obsolete (for now, anyway)");
err.note("for more information on the status of emplacement syntax, see <\
https://github.com/rust-lang/rust/issues/27779#issuecomment-378416911>");
err.emit();
}
let expr = self.parse_expr_res(Restrictions::NO_STRUCT_LITERAL, None)?;
Expand Down
7 changes: 0 additions & 7 deletions src/libsyntax/print/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2004,13 +2004,6 @@ impl<'a> State<'a> {
self.word_space("box")?;
self.print_expr_maybe_paren(expr, parser::PREC_PREFIX)?;
}
ast::ExprKind::ObsoleteInPlace(ref place, ref expr) => {
let prec = AssocOp::ObsoleteInPlace.precedence() as i8;
self.print_expr_maybe_paren(place, prec + 1)?;
self.s.space()?;
self.word_space("<-")?;
self.print_expr_maybe_paren(expr, prec)?;
}
ast::ExprKind::Array(ref exprs) => {
self.print_expr_vec(&exprs[..], attrs)?;
}
Expand Down
14 changes: 4 additions & 10 deletions src/libsyntax/util/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ pub enum AssocOp {
GreaterEqual,
/// `=`
Assign,
/// `<-`
ObsoleteInPlace,
/// `?=` where ? is one of the BinOpToken
AssignOp(BinOpToken),
/// `as`
Expand Down Expand Up @@ -75,7 +73,6 @@ impl AssocOp {
use AssocOp::*;
match *t {
Token::BinOpEq(k) => Some(AssignOp(k)),
Token::LArrow => Some(ObsoleteInPlace),
Token::Eq => Some(Assign),
Token::BinOp(BinOpToken::Star) => Some(Multiply),
Token::BinOp(BinOpToken::Slash) => Some(Divide),
Expand Down Expand Up @@ -145,7 +142,6 @@ impl AssocOp {
LAnd => 6,
LOr => 5,
DotDot | DotDotEq => 4,
ObsoleteInPlace => 3,
Assign | AssignOp(_) => 2,
}
}
Expand All @@ -155,7 +151,7 @@ impl AssocOp {
use AssocOp::*;
// NOTE: it is a bug to have an operators that has same precedence but different fixities!
match *self {
ObsoleteInPlace | Assign | AssignOp(_) => Fixity::Right,
Assign | AssignOp(_) => Fixity::Right,
As | Multiply | Divide | Modulus | Add | Subtract | ShiftLeft | ShiftRight | BitAnd |
BitXor | BitOr | Less | Greater | LessEqual | GreaterEqual | Equal | NotEqual |
LAnd | LOr | Colon => Fixity::Left,
Expand All @@ -167,7 +163,7 @@ impl AssocOp {
use AssocOp::*;
match *self {
Less | Greater | LessEqual | GreaterEqual | Equal | NotEqual => true,
ObsoleteInPlace | Assign | AssignOp(_) | As | Multiply | Divide | Modulus | Add |
Assign | AssignOp(_) | As | Multiply | Divide | Modulus | Add |
Subtract | ShiftLeft | ShiftRight | BitAnd | BitXor | BitOr | LAnd | LOr |
DotDot | DotDotEq | Colon => false
}
Expand All @@ -176,7 +172,7 @@ impl AssocOp {
pub fn is_assign_like(&self) -> bool {
use AssocOp::*;
match *self {
Assign | AssignOp(_) | ObsoleteInPlace => true,
Assign | AssignOp(_) => true,
Less | Greater | LessEqual | GreaterEqual | Equal | NotEqual | As | Multiply | Divide |
Modulus | Add | Subtract | ShiftLeft | ShiftRight | BitAnd | BitXor | BitOr | LAnd |
LOr | DotDot | DotDotEq | Colon => false
Expand Down Expand Up @@ -204,7 +200,7 @@ impl AssocOp {
BitOr => Some(BinOpKind::BitOr),
LAnd => Some(BinOpKind::And),
LOr => Some(BinOpKind::Or),
ObsoleteInPlace | Assign | AssignOp(_) | As | DotDot | DotDotEq | Colon => None
Assign | AssignOp(_) | As | DotDot | DotDotEq | Colon => None
}
}

Expand Down Expand Up @@ -256,7 +252,6 @@ pub enum ExprPrecedence {

Binary(BinOpKind),

ObsoleteInPlace,
Cast,
Type,

Expand Down Expand Up @@ -314,7 +309,6 @@ impl ExprPrecedence {

// Binop-like expr kinds, handled by `AssocOp`.
ExprPrecedence::Binary(op) => AssocOp::from_ast_binop(op).precedence() as i8,
ExprPrecedence::ObsoleteInPlace => AssocOp::ObsoleteInPlace.precedence() as i8,
ExprPrecedence::Cast => AssocOp::As.precedence() as i8,
ExprPrecedence::Type => AssocOp::Colon.precedence() as i8,

Expand Down
4 changes: 0 additions & 4 deletions src/libsyntax/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,10 +676,6 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
ExprKind::Box(ref subexpression) => {
visitor.visit_expr(subexpression)
}
ExprKind::ObsoleteInPlace(ref place, ref subexpression) => {
visitor.visit_expr(place);
visitor.visit_expr(subexpression)
}
ExprKind::Array(ref subexpressions) => {
walk_list!(visitor, visit_expr, subexpressions);
}
Expand Down

0 comments on commit 650c1c3

Please sign in to comment.