diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 22032476c9daf..6cee7b86a6106 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -50,8 +50,7 @@ use ast::{BiSub, StrStyle}; use ast::{SelfExplicit, SelfRegion, SelfStatic, SelfValue}; use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef}; use ast::{TtDelimited, TtSequence, TtToken}; -use ast::{Ty, Ty_, TypeBinding}; -use ast::{TyMac}; +use ast::{Ty, Ty_, TypeBinding, TyMac}; use ast::{TyFixedLengthVec, TyBareFn, TyTypeof, TyInfer}; use ast::{TyParam, TyParamBound, TyParen, TyPath, TyPolyTraitRef, TyPtr}; use ast::{TyRptr, TyTup, TyU32, TyVec}; @@ -2658,7 +2657,10 @@ impl<'a> Parser<'a> { } /// Parse an associative expression with operators of at least `min_prec` precedence - pub fn parse_assoc_expr_with(&mut self, min_prec: usize, lhs: Option>) -> PResult> { + pub fn parse_assoc_expr_with(&mut self, + min_prec: usize, + lhs: Option>) + -> PResult> { let mut lhs = if lhs.is_some() { lhs.unwrap() } else if self.token == token::DotDot { diff --git a/src/test/compile-fail/placement-expr-unsafe.rs b/src/test/compile-fail/placement-expr-unsafe.rs index 50a840e6c9b7f..bf6f4c52f1f9c 100644 --- a/src/test/compile-fail/placement-expr-unsafe.rs +++ b/src/test/compile-fail/placement-expr-unsafe.rs @@ -17,8 +17,8 @@ fn main() { use std::boxed::HEAP; let p: *const i32 = &42; - let _ = in HEAP { *p }; //~ ERROR requires unsafe + let _ = HEAP <- *p; //~ ERROR requires unsafe let p: *const _ = &HEAP; - let _ = in *p { 42 }; //~ ERROR requires unsafe + let _ = *p <- 42; //~ ERROR requires unsafe } diff --git a/src/test/compile-fail/placement-expr-unstable.rs b/src/test/compile-fail/placement-expr-unstable.rs index d981b71a8132d..23fc8e7a07e23 100644 --- a/src/test/compile-fail/placement-expr-unstable.rs +++ b/src/test/compile-fail/placement-expr-unstable.rs @@ -18,7 +18,7 @@ extern crate core; fn main() { use std::boxed::HEAP; //~ ERROR use of unstable library feature - let _ = in HEAP { //~ ERROR use of unstable library feature + let _ = HEAP <- { //~ ERROR use of unstable library feature ::core::raw::Slice { //~ ERROR use of unstable library feature data: &42, //~ ERROR use of unstable library feature len: 1 //~ ERROR use of unstable library feature diff --git a/src/test/parse-fail/assoc-oddities-1.rs b/src/test/parse-fail/assoc-oddities-1.rs new file mode 100644 index 0000000000000..5c0c47de58aed --- /dev/null +++ b/src/test/parse-fail/assoc-oddities-1.rs @@ -0,0 +1,22 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn that_odd_parse() { + // following lines below parse and must not fail + x = if c { a } else { b }(); + x <- if c { a } else { b }[n]; + x = if true { 1 } else { 0 } as *mut _; + // however this does not parse and probably should fail to retain compat? + // NB: `..` here is arbitrary, failure happens/should happen ∀ops that aren’t `=` or `<-` + // see assoc-oddities-2 and assoc-oddities-3 + ..if c { a } else { b }[n]; //~ ERROR expected one of +} diff --git a/src/test/parse-fail/assoc-oddities-2.rs b/src/test/parse-fail/assoc-oddities-2.rs new file mode 100644 index 0000000000000..5679328edc998 --- /dev/null +++ b/src/test/parse-fail/assoc-oddities-2.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn that_odd_parse() { + // see assoc-oddities-1 for explanation + x..if c { a } else { b }[n]; //~ ERROR expected one of +} diff --git a/src/test/parse-fail/assoc-oddities-3.rs b/src/test/parse-fail/assoc-oddities-3.rs new file mode 100644 index 0000000000000..0d4f21f0dca26 --- /dev/null +++ b/src/test/parse-fail/assoc-oddities-3.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn that_odd_parse() { + // see assoc-oddities-1 for explanation + x + if c { a } else { b }[n]; //~ ERROR expected one of +}