Add tests for newly introduced syntax
Also add some (regression) tests for discovered parser oddities
This commit is contained in:
parent
662082cb7e
commit
c1a238c4f5
@ -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<P<Expr>>) -> PResult<P<Expr>> {
|
||||
pub fn parse_assoc_expr_with(&mut self,
|
||||
min_prec: usize,
|
||||
lhs: Option<P<Expr>>)
|
||||
-> PResult<P<Expr>> {
|
||||
let mut lhs = if lhs.is_some() {
|
||||
lhs.unwrap()
|
||||
} else if self.token == token::DotDot {
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
22
src/test/parse-fail/assoc-oddities-1.rs
Normal file
22
src/test/parse-fail/assoc-oddities-1.rs
Normal file
@ -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 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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
|
||||
}
|
16
src/test/parse-fail/assoc-oddities-2.rs
Normal file
16
src/test/parse-fail/assoc-oddities-2.rs
Normal file
@ -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 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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
|
||||
}
|
16
src/test/parse-fail/assoc-oddities-3.rs
Normal file
16
src/test/parse-fail/assoc-oddities-3.rs
Normal file
@ -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 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user