diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2016-05-22 17:51:22 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2016-05-28 20:27:57 +0300 |
| commit | 2abdf963441dad5e5ec516af8ee2f9b459f9e47d (patch) | |
| tree | 903a774d07993a87ffbe0c7f3f0ec77e1cec4d16 /src/test | |
| parent | f1776fe244d8603006536dceb7a21967e1c21f9c (diff) | |
| download | rust-2abdf963441dad5e5ec516af8ee2f9b459f9e47d.tar.gz rust-2abdf963441dad5e5ec516af8ee2f9b459f9e47d.zip | |
Add an AST sanity checking pass and use it to catch some illegal lifetime/label names
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/label-static.rs | 15 | ||||
| -rw-r--r-- | src/test/compile-fail/lifetime-underscore.rs | 27 |
2 files changed, 42 insertions, 0 deletions
diff --git a/src/test/compile-fail/label-static.rs b/src/test/compile-fail/label-static.rs new file mode 100644 index 00000000000..a0fb25ea06e --- /dev/null +++ b/src/test/compile-fail/label-static.rs @@ -0,0 +1,15 @@ +// Copyright 2016 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() { + 'static: loop { //~ ERROR invalid label name `'static` + break 'static //~ ERROR invalid label name `'static` + } +} diff --git a/src/test/compile-fail/lifetime-underscore.rs b/src/test/compile-fail/lifetime-underscore.rs new file mode 100644 index 00000000000..102d3576e54 --- /dev/null +++ b/src/test/compile-fail/lifetime-underscore.rs @@ -0,0 +1,27 @@ +// Copyright 2016 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. + +#![deny(lifetime_underscore)] + +fn _f<'_>() //~ ERROR invalid lifetime name `'_` +//~^ WARN this was previously accepted + -> &'_ u8 //~ ERROR invalid lifetime name `'_` + //~^ WARN this was previously accepted +{ + panic!(); +} + +fn main() { + '_: loop { //~ ERROR invalid label name `'_` + //~^ WARN this was previously accepted + break '_ //~ ERROR invalid label name `'_` + //~^ WARN this was previously accepted + } +} |
