auto merge of #14388 : kballard/rust/nonfatal_lexer_errors, r=alexcrichton

Most errors that arise in the lexer can be recovered from. This allows
for more than one syntax error to be reported at a time.
This commit is contained in:
bors 2014-05-24 00:01:25 -07:00
commit 6cf430147e
9 changed files with 148 additions and 211 deletions

View file

@ -8,8 +8,22 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-tidy-cr
// ignore-tidy-tab
fn main() {
// these literals are just silly.
''';
//~^ ERROR: character constant must be escaped
//~^ ERROR: character constant must be escaped: \'
// note that this is a literal "\n" byte
'
';
//~^^ ERROR: character constant must be escaped: \n
// note that this is a literal "\r" byte
' '; //~ ERROR: character constant must be escaped: \r
// note that this is a literal tab character here
' ';
//~^ ERROR: character constant must be escaped: \t
}

View file

@ -1,16 +0,0 @@
// Copyright 2013 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.
fn main() {
// note that this is a literal "\n" byte
'
';
//~^^ ERROR: character constant must be escaped
}

View file

@ -1,16 +0,0 @@
// Copyright 2013-2014 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.
// ignore-tidy-cr
fn main() {
// note that this is a literal "\r" byte
'
'; //~^ ERROR: character constant must be escaped
}

View file

@ -1,16 +0,0 @@
// Copyright 2013-2014 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.
// ignore-tidy-tab
fn main() {
// note that this is a literal tab character here
' ';
//~^ ERROR: character constant must be escaped
}

View file

@ -9,16 +9,17 @@
// except according to those terms.
trait Serializable<'self, T> { //~ ERROR: no longer a special lifetime
fn serialize(val : &'self T) -> Vec<u8> ;
fn deserialize(repr : &[u8]) -> &'self T;
trait Serializable<'self, T> { //~ ERROR no longer a special lifetime
fn serialize(val : &'self T) -> Vec<u8> ; //~ ERROR no longer a special lifetime
fn deserialize(repr : &[u8]) -> &'self T; //~ ERROR no longer a special lifetime
}
impl<'self> Serializable<str> for &'self str {
fn serialize(val : &'self str) -> Vec<u8> {
impl<'self> Serializable<str> for &'self str { //~ ERROR no longer a special lifetime
//~^ ERROR no longer a special lifetime
fn serialize(val : &'self str) -> Vec<u8> { //~ ERROR no longer a special lifetime
vec!(1)
}
fn deserialize(repr: &[u8]) -> &'self str {
fn deserialize(repr: &[u8]) -> &'self str { //~ ERROR no longer a special lifetime
"hi"
}
}

View file

@ -1,13 +0,0 @@
// Copyright 2013 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.
static c: char =
'\Uffffffff' //~ ERROR: illegal numeric character escape
;

View file

@ -11,3 +11,25 @@
static c: char =
'\u539_' //~ ERROR: illegal character in numeric character escape
;
static c2: char =
'\Uffffffff' //~ ERROR: illegal numeric character escape
;
static c3: char =
'\x1' //~ ERROR: numeric character escape is too short
;
static c4: char =
'\u23q' //~ ERROR: illegal character in numeric character escape
;
//~^^ ERROR: numeric character escape is too short
static s: &'static str =
"\x1" //~ ERROR: numeric character escape is too short
;
static s2: &'static str =
"\u23q" //~ ERROR: illegal character in numeric character escape
;
//~^^ ERROR: numeric character escape is too short