diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2016-04-17 03:48:40 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2016-04-17 03:48:40 +0300 |
| commit | e7bc939f1ee2ada3e3f679fd42c8e08d8a22996f (patch) | |
| tree | 804e4a3221a669c42cbf6c4744c0f8b36c42c1d2 /src/test | |
| parent | 6fa61b810dc95ca3e8bbda1681229f855f214fc4 (diff) | |
| download | rust-e7bc939f1ee2ada3e3f679fd42c8e08d8a22996f.tar.gz rust-e7bc939f1ee2ada3e3f679fd42c8e08d8a22996f.zip | |
syntax: Parse import prefixes as paths
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/import-prefix-macro-1.rs | 26 | ||||
| -rw-r--r-- | src/test/compile-fail/import-prefix-macro-2.rs | 26 | ||||
| -rw-r--r-- | src/test/compile-fail/import-ty-params.rs | 25 | ||||
| -rw-r--r-- | src/test/compile-fail/self_type_keyword-2.rs | 13 | ||||
| -rw-r--r-- | src/test/compile-fail/self_type_keyword.rs | 3 | ||||
| -rw-r--r-- | src/test/parse-fail/use-ends-with-mod-sep.rs | 2 | ||||
| -rw-r--r-- | src/test/run-pass/import-prefix-macro.rs | 35 |
7 files changed, 126 insertions, 4 deletions
diff --git a/src/test/compile-fail/import-prefix-macro-1.rs b/src/test/compile-fail/import-prefix-macro-1.rs new file mode 100644 index 00000000000..beb15a11a96 --- /dev/null +++ b/src/test/compile-fail/import-prefix-macro-1.rs @@ -0,0 +1,26 @@ +// 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. + +mod a { + pub mod b { + pub mod c { + pub struct S; + pub struct Z; + } + } +} + +macro_rules! import { + ($p: path) => (use $p {S, Z}); //~ERROR expected one of `::`, `;`, or `as`, found `{` +} + +import! { a::b::c } + +fn main() {} diff --git a/src/test/compile-fail/import-prefix-macro-2.rs b/src/test/compile-fail/import-prefix-macro-2.rs new file mode 100644 index 00000000000..56c6273aa9a --- /dev/null +++ b/src/test/compile-fail/import-prefix-macro-2.rs @@ -0,0 +1,26 @@ +// 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. + +mod a { + pub mod b { + pub mod c { + pub struct S; + pub struct Z; + } + } +} + +macro_rules! import { + ($p: path) => (use ::$p {S, Z}); //~ERROR expected identifier, found `a::b::c` +} + +import! { a::b::c } + +fn main() {} diff --git a/src/test/compile-fail/import-ty-params.rs b/src/test/compile-fail/import-ty-params.rs new file mode 100644 index 00000000000..66d4d6d0621 --- /dev/null +++ b/src/test/compile-fail/import-ty-params.rs @@ -0,0 +1,25 @@ +// 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. + +mod a { + pub mod b { + pub mod c { + pub struct S<T>(T); + } + } +} + +macro_rules! import { + ($p: path) => (use $p;); +} + +import! { a::b::c::S<u8> } //~ERROR type or lifetime parameter is found in import path + +fn main() {} diff --git a/src/test/compile-fail/self_type_keyword-2.rs b/src/test/compile-fail/self_type_keyword-2.rs new file mode 100644 index 00000000000..613f54eb331 --- /dev/null +++ b/src/test/compile-fail/self_type_keyword-2.rs @@ -0,0 +1,13 @@ +// 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. + +use self::Self as Foo; //~ ERROR unresolved import `self::Self` + +pub fn main() {} diff --git a/src/test/compile-fail/self_type_keyword.rs b/src/test/compile-fail/self_type_keyword.rs index 62966737874..b28f48bb105 100644 --- a/src/test/compile-fail/self_type_keyword.rs +++ b/src/test/compile-fail/self_type_keyword.rs @@ -39,9 +39,6 @@ pub fn main() { } } -use self::Self as Foo; -//~^ ERROR expected identifier, found keyword `Self` - use std::option::Option as Self; //~^ ERROR expected identifier, found keyword `Self` diff --git a/src/test/parse-fail/use-ends-with-mod-sep.rs b/src/test/parse-fail/use-ends-with-mod-sep.rs index 143886e2337..e6a10d43e29 100644 --- a/src/test/parse-fail/use-ends-with-mod-sep.rs +++ b/src/test/parse-fail/use-ends-with-mod-sep.rs @@ -10,4 +10,4 @@ // compile-flags: -Z parse-only -use std::any::; //~ ERROR expected identifier or `{` or `*`, found `;` +use std::any::; //~ ERROR expected identifier, found `;` diff --git a/src/test/run-pass/import-prefix-macro.rs b/src/test/run-pass/import-prefix-macro.rs new file mode 100644 index 00000000000..cfe4ff78e62 --- /dev/null +++ b/src/test/run-pass/import-prefix-macro.rs @@ -0,0 +1,35 @@ +// 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. + +mod a { + pub mod b { + pub mod c { + pub struct S; + pub struct Z; + } + pub struct W; + } +} + +macro_rules! import { + (1 $p: path) => (use $p;); + (2 $p: path) => (use $p::{Z};); + (3 $p: path) => (use $p::*;); +} + +import! { 1 a::b::c::S } +import! { 2 a::b::c } +import! { 3 a::b } + +fn main() { + let s = S; + let z = Z; + let w = W; +} |
