diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2014-12-19 11:47:48 +1300 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2014-12-30 13:06:25 +1300 |
| commit | 4e2afb0052618ca3d758fffd0cf50559be774391 (patch) | |
| tree | 1d15ea3b8b2c53b1e8f1599578325af3840edc04 /src/libsyntax/parse/parser.rs | |
| parent | ed8f5039115308ca9d5591126e4d8a77864d4730 (diff) | |
| download | rust-4e2afb0052618ca3d758fffd0cf50559be774391.tar.gz rust-4e2afb0052618ca3d758fffd0cf50559be774391.zip | |
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.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 15 |
1 files changed, 11 insertions, 4 deletions
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<Expr>, start: Option<P<Expr>>, end: Option<P<Expr>>, - 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, |
