diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-01-21 11:56:00 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-01-21 11:56:00 -0800 |
| commit | df1cddf20a2a4ece854e5d8592ad3155a3313fd2 (patch) | |
| tree | 50bdd6498e1378cbeb48e80e35157152920e9c56 /src/test | |
| parent | 886c6f3534e6f03916eeff2ea8b235e85dd04b42 (diff) | |
| parent | 2d17a33878f1af0aa500a4e1ff6aa5c8689ab249 (diff) | |
| download | rust-df1cddf20a2a4ece854e5d8592ad3155a3313fd2.tar.gz rust-df1cddf20a2a4ece854e5d8592ad3155a3313fd2.zip | |
rollup merge of #20179: eddyb/blind-items
Conflicts: src/librustc/diagnostics.rs src/librustdoc/clean/mod.rs src/librustdoc/html/format.rs src/libsyntax/parse/parser.rs
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/auxiliary/blind-item-mixed-crate-use-item-foo.rs (renamed from src/test/compile-fail/issue-9957.rs) | 8 | ||||
| -rw-r--r-- | src/test/auxiliary/blind-item-mixed-crate-use-item-foo2.rs | 13 | ||||
| -rw-r--r-- | src/test/compile-fail-fulldeps/gated-plugin.rs | 3 | ||||
| -rw-r--r-- | src/test/compile-fail/blind-item-block-item-shadow.rs | 20 | ||||
| -rw-r--r-- | src/test/compile-fail/blind-item-block-middle.rs | 18 | ||||
| -rw-r--r-- | src/test/compile-fail/blind-item-item-shadow.rs (renamed from src/test/compile-fail/view-items-at-top.rs) | 12 | ||||
| -rw-r--r-- | src/test/compile-fail/blind-item-local-shadow.rs | 20 | ||||
| -rw-r--r-- | src/test/compile-fail/unnecessary-private.rs | 3 | ||||
| -rw-r--r-- | src/test/pretty/issue-4264.pp | 4 | ||||
| -rw-r--r-- | src/test/run-pass/blind-item-mixed-crate-use-item.rs | 33 | ||||
| -rw-r--r-- | src/test/run-pass/blind-item-mixed-use-item.rs | 27 |
11 files changed, 143 insertions, 18 deletions
diff --git a/src/test/compile-fail/issue-9957.rs b/src/test/auxiliary/blind-item-mixed-crate-use-item-foo.rs index b1204e82890..f129b4b77bb 100644 --- a/src/test/compile-fail/issue-9957.rs +++ b/src/test/auxiliary/blind-item-mixed-crate-use-item-foo.rs @@ -1,4 +1,4 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub extern crate core; //~ ERROR: `pub` visibility is not allowed +#![crate_type="lib"] -fn main() { - pub use std::usize; //~ ERROR: imports in functions are never reachable -} +pub const X: () = (); diff --git a/src/test/auxiliary/blind-item-mixed-crate-use-item-foo2.rs b/src/test/auxiliary/blind-item-mixed-crate-use-item-foo2.rs new file mode 100644 index 00000000000..91fa9124551 --- /dev/null +++ b/src/test/auxiliary/blind-item-mixed-crate-use-item-foo2.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. + +#![crate_type="lib"] + +pub const Y: () = (); diff --git a/src/test/compile-fail-fulldeps/gated-plugin.rs b/src/test/compile-fail-fulldeps/gated-plugin.rs index 89090d5f38a..be9e57e2d19 100644 --- a/src/test/compile-fail-fulldeps/gated-plugin.rs +++ b/src/test/compile-fail-fulldeps/gated-plugin.rs @@ -11,8 +11,7 @@ // aux-build:macro_crate_test.rs // ignore-stage1 -#[plugin] #[no_link] +#[plugin] #[no_link] extern crate macro_crate_test; //~^ ERROR compiler plugins are experimental and possibly buggy -extern crate macro_crate_test; fn main() {} diff --git a/src/test/compile-fail/blind-item-block-item-shadow.rs b/src/test/compile-fail/blind-item-block-item-shadow.rs new file mode 100644 index 00000000000..d4adaa042b2 --- /dev/null +++ b/src/test/compile-fail/blind-item-block-item-shadow.rs @@ -0,0 +1,20 @@ +// 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. + +mod foo { pub struct Bar; } + +fn main() { + { + struct Bar; + use foo::Bar; + //~^ ERROR import `Bar` conflicts with type in this module + //~^^ ERROR import `Bar` conflicts with value in this module + } +} diff --git a/src/test/compile-fail/blind-item-block-middle.rs b/src/test/compile-fail/blind-item-block-middle.rs new file mode 100644 index 00000000000..fbb0730f014 --- /dev/null +++ b/src/test/compile-fail/blind-item-block-middle.rs @@ -0,0 +1,18 @@ +// 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. + +mod foo { struct bar; } + +fn main() { + let bar = 5; + //~^ ERROR declaration of `bar` shadows an enum variant or unit-like struct in scope + use foo::bar; + //~^ ERROR imports are not allowed after non-item statements +} diff --git a/src/test/compile-fail/view-items-at-top.rs b/src/test/compile-fail/blind-item-item-shadow.rs index 7b78a8d932b..9f21d6a9234 100644 --- a/src/test/compile-fail/view-items-at-top.rs +++ b/src/test/compile-fail/blind-item-item-shadow.rs @@ -1,4 +1,4 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -8,12 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate test; +mod foo { pub mod foo { } } -fn f() { -} +use foo::foo; //~ ERROR import `foo` conflicts with existing submodule -use test::net; //~ ERROR `use` and `extern crate` declarations must precede items - -fn main() { -} +fn main() {} diff --git a/src/test/compile-fail/blind-item-local-shadow.rs b/src/test/compile-fail/blind-item-local-shadow.rs new file mode 100644 index 00000000000..a28f5f6e557 --- /dev/null +++ b/src/test/compile-fail/blind-item-local-shadow.rs @@ -0,0 +1,20 @@ +// 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. + +mod bar { + pub fn foo() -> bool { true } +} + +fn main() { + let foo = |&:| false; + use bar::foo; + //~^ ERROR imports are not allowed after non-item statements + assert_eq!(foo(), false); +} diff --git a/src/test/compile-fail/unnecessary-private.rs b/src/test/compile-fail/unnecessary-private.rs index 6e6ffd23c4a..e3707292f24 100644 --- a/src/test/compile-fail/unnecessary-private.rs +++ b/src/test/compile-fail/unnecessary-private.rs @@ -1,4 +1,4 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -9,6 +9,7 @@ // except according to those terms. fn main() { + pub use std::uint; //~ ERROR: visibility has no effect pub struct A; //~ ERROR: visibility has no effect pub enum B {} //~ ERROR: visibility has no effect pub trait C { //~ ERROR: visibility has no effect diff --git a/src/test/pretty/issue-4264.pp b/src/test/pretty/issue-4264.pp index dac6e628d10..c18d076c0d3 100644 --- a/src/test/pretty/issue-4264.pp +++ b/src/test/pretty/issue-4264.pp @@ -1,8 +1,8 @@ #![no_std] -#[macro_use] -extern crate "std" as std; #[prelude_import] use std::prelude::v1::*; +#[macro_use] +extern crate "std" as std; // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. diff --git a/src/test/run-pass/blind-item-mixed-crate-use-item.rs b/src/test/run-pass/blind-item-mixed-crate-use-item.rs new file mode 100644 index 00000000000..80c73e5e60b --- /dev/null +++ b/src/test/run-pass/blind-item-mixed-crate-use-item.rs @@ -0,0 +1,33 @@ +// 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. + +// aux-build:blind-item-mixed-crate-use-item-foo.rs +// aux-build:blind-item-mixed-crate-use-item-foo2.rs + +mod m { + pub fn f<T>(_: T, _: (), _: ()) { } + pub fn g<T>(_: T, _: (), _: ()) { } +} + +const BAR: () = (); +struct Data; +use m::f; +extern crate "blind-item-mixed-crate-use-item-foo" as foo; + +fn main() { + const BAR2: () = (); + struct Data2; + use m::g; + + extern crate "blind-item-mixed-crate-use-item-foo2" as foo2; + + f(Data, BAR, foo::X); + g(Data2, BAR2, foo2::Y); +} diff --git a/src/test/run-pass/blind-item-mixed-use-item.rs b/src/test/run-pass/blind-item-mixed-use-item.rs new file mode 100644 index 00000000000..a3dad01acf1 --- /dev/null +++ b/src/test/run-pass/blind-item-mixed-use-item.rs @@ -0,0 +1,27 @@ +// 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. + +mod m { + pub fn f<T>(_: T, _: ()) { } + pub fn g<T>(_: T, _: ()) { } +} + +const BAR: () = (); +struct Data; +use m::f; + +fn main() { + const BAR2: () = (); + struct Data2; + use m::g; + + f(Data, BAR); + g(Data2, BAR2); +} |
