From 4e2afb0052618ca3d758fffd0cf50559be774391 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Fri, 19 Dec 2014 11:47:48 +1300 Subject: Remove ExprSlice by hacking the compiler [breaking-change] The `mut` in slices is now redundant. Mutability is 'inferred' from position. This means that if mutability is only obvious from the type, you will need to use explicit calls to the slicing methods. --- src/libsyntax/parse/parser.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/libsyntax/parse/parser.rs') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index ec1e966926a..2f43661eebe 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -25,7 +25,7 @@ use ast::{DeclLocal, DefaultBlock, UnDeref, BiDiv, EMPTY_CTXT, EnumDef, Explicit use ast::{Expr, Expr_, ExprAddrOf, ExprMatch, ExprAgain}; use ast::{ExprAssign, ExprAssignOp, ExprBinary, ExprBlock, ExprBox}; use ast::{ExprBreak, ExprCall, ExprCast}; -use ast::{ExprField, ExprTupField, ExprClosure, ExprIf, ExprIfLet, ExprIndex, ExprSlice}; +use ast::{ExprField, ExprTupField, ExprClosure, ExprIf, ExprIfLet, ExprIndex}; use ast::{ExprLit, ExprLoop, ExprMac, ExprRange}; use ast::{ExprMethodCall, ExprParen, ExprPath}; use ast::{ExprRepeat, ExprRet, ExprStruct, ExprTup, ExprUnary}; @@ -66,7 +66,7 @@ use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple}; use ast::{Visibility, WhereClause}; use ast; use ast_util::{mod, as_prec, ident_to_path, operator_prec}; -use codemap::{mod, Span, BytePos, Spanned, spanned, mk_sp}; +use codemap::{mod, Span, BytePos, Spanned, spanned, mk_sp, DUMMY_SP}; use diagnostic; use ext::tt::macro_parser; use parse; @@ -2135,9 +2135,16 @@ impl<'a> Parser<'a> { expr: P, start: Option>, end: Option>, - mutbl: Mutability) + _mutbl: Mutability) -> ast::Expr_ { - ExprSlice(expr, start, end, mutbl) + // FIXME: we could give more accurate span info here. + let (lo, hi) = match (&start, &end) { + (&Some(ref s), &Some(ref e)) => (s.span.lo, e.span.hi), + (&Some(ref s), &None) => (s.span.lo, s.span.hi), + (&None, &Some(ref e)) => (e.span.lo, e.span.hi), + (&None, &None) => (DUMMY_SP.lo, DUMMY_SP.hi), + }; + ExprIndex(expr, self.mk_expr(lo, hi, ExprRange(start, end))) } pub fn mk_range(&mut self, -- cgit 1.4.1-3-g733a5