diff options
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/absolute-paths-in-nested-use-groups.rs | 22 | ||||
| -rw-r--r-- | src/test/compile-fail/feature-gate-use_nested_groups.rs | 31 | ||||
| -rw-r--r-- | src/test/run-pass/use-nested-groups.rs | 35 | ||||
| -rw-r--r-- | src/test/ui/owl-import-generates-unused-import-lint.rs | 22 | ||||
| -rw-r--r-- | src/test/ui/owl-import-generates-unused-import-lint.stderr | 14 | ||||
| -rw-r--r-- | src/test/ui/similar-tokens.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/similar-tokens.stderr | 6 |
7 files changed, 128 insertions, 4 deletions
diff --git a/src/test/compile-fail/absolute-paths-in-nested-use-groups.rs b/src/test/compile-fail/absolute-paths-in-nested-use-groups.rs new file mode 100644 index 00000000000..8e5ba489c56 --- /dev/null +++ b/src/test/compile-fail/absolute-paths-in-nested-use-groups.rs @@ -0,0 +1,22 @@ +// Copyright 2017 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. + +#![feature(use_nested_groups)] +#![allow(unused_imports)] + +mod foo {} + +use foo::{ + ::bar, //~ ERROR crate root in paths can only be used in start position + super::bar, //~ ERROR `super` in paths can only be used in start position + self::bar, //~ ERROR `self` in paths can only be used in start position +}; + +fn main() {} diff --git a/src/test/compile-fail/feature-gate-use_nested_groups.rs b/src/test/compile-fail/feature-gate-use_nested_groups.rs new file mode 100644 index 00000000000..56413a999d7 --- /dev/null +++ b/src/test/compile-fail/feature-gate-use_nested_groups.rs @@ -0,0 +1,31 @@ +// Copyright 2017 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. + +#![allow(unused_imports, dead_code)] + +mod a { + pub enum B {} + pub enum C {} + + pub mod d { + pub enum E {} + pub enum F {} + + pub mod g { + pub enum H {} + } + } +} + +use a::{B, d::{*, g::H}}; //~ ERROR glob imports in `use` groups are experimental + //~^ ERROR nested groups in `use` are experimental + //~^^ ERROR paths in `use` groups are experimental + +fn main() {} diff --git a/src/test/run-pass/use-nested-groups.rs b/src/test/run-pass/use-nested-groups.rs new file mode 100644 index 00000000000..74a82afd462 --- /dev/null +++ b/src/test/run-pass/use-nested-groups.rs @@ -0,0 +1,35 @@ +// Copyright 2017 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. + +#![feature(use_nested_groups)] + +mod a { + pub enum B {} + + pub mod d { + pub enum E {} + pub enum F {} + + pub mod g { + pub enum H {} + pub enum I {} + } + } +} + +use a::{B, d::{self, *, g::H}}; + +fn main() { + let _: B; + let _: E; + let _: F; + let _: H; + let _: d::g::I; +} diff --git a/src/test/ui/owl-import-generates-unused-import-lint.rs b/src/test/ui/owl-import-generates-unused-import-lint.rs new file mode 100644 index 00000000000..dc30c318352 --- /dev/null +++ b/src/test/ui/owl-import-generates-unused-import-lint.rs @@ -0,0 +1,22 @@ +// Copyright 2017 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. + +#![feature(use_nested_groups)] +#![deny(unused_imports)] + +mod foo { + pub enum Bar {} +} + +use foo::{*, *}; //~ ERROR unused import: `*` + +fn main() { + let _: Bar; +} diff --git a/src/test/ui/owl-import-generates-unused-import-lint.stderr b/src/test/ui/owl-import-generates-unused-import-lint.stderr new file mode 100644 index 00000000000..79089b2a93c --- /dev/null +++ b/src/test/ui/owl-import-generates-unused-import-lint.stderr @@ -0,0 +1,14 @@ +error: unused import: `*` + --> $DIR/owl-import-generates-unused-import-lint.rs:18:14 + | +18 | use foo::{*, *}; //~ ERROR unused import: `*` + | ^ + | +note: lint level defined here + --> $DIR/owl-import-generates-unused-import-lint.rs:12:9 + | +12 | #![deny(unused_imports)] + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/similar-tokens.rs b/src/test/ui/similar-tokens.rs index b16d584ed42..eb7eab9e42d 100644 --- a/src/test/ui/similar-tokens.rs +++ b/src/test/ui/similar-tokens.rs @@ -14,6 +14,6 @@ mod x { } // `.` is similar to `,` so list parsing should continue to closing `}` -use x::{A. B}; //~ ERROR expected one of `,` or `as`, found `.` +use x::{A. B}; //~ ERROR expected one of `,`, `::`, or `as`, found `.` fn main() {} diff --git a/src/test/ui/similar-tokens.stderr b/src/test/ui/similar-tokens.stderr index 1b9eb1d8ef5..b4968b1018f 100644 --- a/src/test/ui/similar-tokens.stderr +++ b/src/test/ui/similar-tokens.stderr @@ -1,8 +1,8 @@ -error: expected one of `,` or `as`, found `.` +error: expected one of `,`, `::`, or `as`, found `.` --> $DIR/similar-tokens.rs:17:10 | -17 | use x::{A. B}; //~ ERROR expected one of `,` or `as`, found `.` - | ^ expected one of `,` or `as` here +17 | use x::{A. B}; //~ ERROR expected one of `,`, `::`, or `as`, found `.` + | ^ expected one of `,`, `::`, or `as` here error: aborting due to previous error |
